git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9493 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
03deeba187
commit
1bfe485767
|
@ -36,7 +36,7 @@
|
||||||
#define PAGE_SIZE 256U
|
#define PAGE_SIZE 256U
|
||||||
#define PAGE_MASK (PAGE_SIZE - 1U)
|
#define PAGE_MASK (PAGE_SIZE - 1U)
|
||||||
|
|
||||||
#if N25Q128_USE_SUB_SECTORS == TRUE
|
#if M25Q_USE_SUB_SECTORS == TRUE
|
||||||
#define SECTOR_SIZE 0x00001000U
|
#define SECTOR_SIZE 0x00001000U
|
||||||
#define CMD_SECTOR_ERASE M25Q_CMD_SUBSECTOR_ERASE
|
#define CMD_SECTOR_ERASE M25Q_CMD_SUBSECTOR_ERASE
|
||||||
#else
|
#else
|
||||||
|
@ -79,7 +79,7 @@ static flash_descriptor_t descriptor = {
|
||||||
.attributes = FLASH_ATTR_ERASED_IS_ONE | FLASH_ATTR_REWRITABLE |
|
.attributes = FLASH_ATTR_ERASED_IS_ONE | FLASH_ATTR_REWRITABLE |
|
||||||
FLASH_ATTR_SUSPEND_ERASE_CAPABLE,
|
FLASH_ATTR_SUSPEND_ERASE_CAPABLE,
|
||||||
.page_size = 256U,
|
.page_size = 256U,
|
||||||
#if N25Q128_USE_SUB_SECTORS == TRUE
|
#if M25Q_USE_SUB_SECTORS == TRUE
|
||||||
.sectors_count = 4096U,
|
.sectors_count = 4096U,
|
||||||
#else
|
#else
|
||||||
.sectors_count = 256U,
|
.sectors_count = 256U,
|
||||||
|
@ -93,7 +93,7 @@ static flash_descriptor_t descriptor = {
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if (M25Q_USE_SPI == TRUE) && (M25Q_SHARED_SPI == TRUE)
|
#if (M25Q_BUS_MODE == M25Q_BUS_MODE_SPI) && (M25Q_SHARED_SPI == TRUE)
|
||||||
void flash_bus_acquire(M25QDriver *devp) {
|
void flash_bus_acquire(M25QDriver *devp) {
|
||||||
|
|
||||||
spiAcquireBus(devp->config->spip);
|
spiAcquireBus(devp->config->spip);
|
||||||
|
@ -107,7 +107,7 @@ void flash_bus_release(M25QDriver *devp) {
|
||||||
#else
|
#else
|
||||||
#define flash_bus_acquire(devp)
|
#define flash_bus_acquire(devp)
|
||||||
#define flash_bus_release(devp)
|
#define flash_bus_release(devp)
|
||||||
#endif /* (M25Q_USE_SPI == TRUE) && (M25Q_SHARED_SPI == TRUE) */
|
#endif /* (M25Q_BUS_MODE == M25Q_BUS_MODE_SPI) && (M25Q_SHARED_SPI == TRUE) */
|
||||||
|
|
||||||
static void flash_short_cmd(M25QDriver *devp, uint8_t cmd) {
|
static void flash_short_cmd(M25QDriver *devp, uint8_t cmd) {
|
||||||
uint8_t buf[1];
|
uint8_t buf[1];
|
||||||
|
|
|
@ -69,21 +69,31 @@
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Status register bits
|
* @name Flags status register bits
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
#define N25Q128_STS_PROGRAM_ERASE 0x80U
|
#define M25Q_FLAGS_PROGRAM_ERASE 0x80U
|
||||||
#define N25Q128_STS_ERASE_SUSPEND 0x40U
|
#define M25Q_FLAGS_ERASE_SUSPEND 0x40U
|
||||||
#define N25Q128_STS_ERASE_ERROR 0x20U
|
#define M25Q_FLAGS_ERASE_ERROR 0x20U
|
||||||
#define N25Q128_STS_PROGRAM_ERROR 0x10U
|
#define M25Q_FLAGS_PROGRAM_ERROR 0x10U
|
||||||
#define N25Q128_STS_VPP_ERROR 0x08U
|
#define M25Q_FLAGS_VPP_ERROR 0x08U
|
||||||
#define N25Q128_STS_PROGRAM_SUSPEND 0x04U
|
#define M25Q_FLAGS_PROGRAM_SUSPEND 0x04U
|
||||||
#define N25Q128_STS_PROTECTION_ERROR 0x02U
|
#define M25Q_FLAGS_PROTECTION_ERROR 0x02U
|
||||||
#define N25Q128_STS_RESERVED 0x01U
|
#define M25Q_FLAGS_RESERVED 0x01U
|
||||||
#define N25Q128_STS_ALL_ERRORS (N25Q128_STS_ERASE_ERROR | \
|
#define M25Q_FLAGS_ALL_ERRORS (M25Q_FLAGS_ERASE_ERROR | \
|
||||||
N25Q128_STS_PROGRAM_ERROR | \
|
M25Q_FLAGS_PROGRAM_ERROR | \
|
||||||
N25Q128_STS_VPP_ERROR | \
|
M25Q_FLAGS_VPP_ERROR | \
|
||||||
N25Q128_STS_PROTECTION_ERROR)
|
M25Q_FLAGS_PROTECTION_ERROR)
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Bus interface.
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#define M25Q_BUS_MODE_SPI 0
|
||||||
|
#define M25Q_BUS_MODE_QSPI1L 1
|
||||||
|
#define M25Q_BUS_MODE_QSPI2L 2
|
||||||
|
#define M25Q_BUS_MODE_QSPI4L 4
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -95,11 +105,10 @@
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @brief SPI fallback switch.
|
* @brief Physical transport interface.
|
||||||
* @details If enabled makes the driver use SPI rather than QSPI.
|
|
||||||
*/
|
*/
|
||||||
#if !defined(M25Q_USE_SPI) || defined(__DOXYGEN__)
|
#if !defined(M25Q_USE_SPI) || defined(__DOXYGEN__)
|
||||||
#define M25Q_USE_SPI FALSE
|
#define M25Q_BUS_MODE M25Q_BUS_MODE_QSPI4L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,20 +124,18 @@
|
||||||
/**
|
/**
|
||||||
* @brief Delays insertions.
|
* @brief Delays insertions.
|
||||||
* @details If enabled this options inserts delays into the flash waiting
|
* @details If enabled this options inserts delays into the flash waiting
|
||||||
* routines releasing some extra CPU time for the threads with
|
* routines releasing some extra CPU time for threads with lower
|
||||||
* lower priority, this may slow down the driver a bit however.
|
* priority, this may slow down the driver a bit however.
|
||||||
* This option is recommended also when the SPI driver does not
|
|
||||||
* use a DMA channel and heavily loads the CPU.
|
|
||||||
*/
|
*/
|
||||||
#if !defined(N25Q128_NICE_WAITING) || defined(__DOXYGEN__)
|
#if !defined(M25Q_NICE_WAITING) || defined(__DOXYGEN__)
|
||||||
#define N25Q128_NICE_WAITING TRUE
|
#define M25Q_NICE_WAITING TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Uses 4kB sub-sectors rather than 64kB sectors.
|
* @brief Uses 4kB sub-sectors rather than 64kB sectors.
|
||||||
*/
|
*/
|
||||||
#if !defined(N25Q128_USE_SUB_SECTORS) || defined(__DOXYGEN__)
|
#if !defined(M25Q_USE_SUB_SECTORS) || defined(__DOXYGEN__)
|
||||||
#define N25Q128_USE_SUB_SECTORS FALSE
|
#define M25Q_USE_SUB_SECTORS FALSE
|
||||||
#endif
|
#endif
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -136,15 +143,17 @@
|
||||||
/* Derived constants and error checks. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if M25Q_USE_SPI && !HAL_USE_SPI
|
#if (M25Q_BUS_MODE == M25Q_BUS_MODE_SPI) && (HAL_USE_SPI == FALSE)
|
||||||
#error "M25Q_USE_SPI=TRUE requires HAL_USE_SPI"
|
#error "M25Q_BUS_MODE_SPI requires HAL_USE_SPI"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !M25Q_USE_SPI && !HAL_USE_QSPI
|
#if (M25Q_BUS_MODE != M25Q_BUS_MODE_SPI) && (HAL_USE_QSPI == FALSE)
|
||||||
#error "M25Q_USE_SPI=FALSE requires HAL_USE_QSPI"
|
#error "M25Q_BUS_MODE_QSPIxL requires HAL_USE_QSPI"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if M25Q_USE_SPI && M25Q_SHARED_SPI && !SPI_USE_MUTUAL_EXCLUSION
|
#if (M25Q_BUS_MODE == M25Q_BUS_MODE_SPI) && \
|
||||||
|
(M25Q_SHARED_SPI == TRUE) && \
|
||||||
|
(SPI_USE_MUTUAL_EXCLUSION == FALSE)
|
||||||
#error "M25Q_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
|
#error "M25Q_SHARED_SPI requires SPI_USE_MUTUAL_EXCLUSION"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -156,7 +165,7 @@
|
||||||
* @brief Type of a M25Q configuration structure.
|
* @brief Type of a M25Q configuration structure.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if !M25Q_USE_SPI || defined(__DOXYGEN__)
|
#if (M25Q_BUS_MODE != M25Q_BUS_MODE_SPI) || defined(__DOXYGEN__)
|
||||||
/**
|
/**
|
||||||
* @brief QSPI driver associated to this instance.
|
* @brief QSPI driver associated to this instance.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue