diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-05-17 10:22:22 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2016-05-17 10:22:22 +0000 |
commit | 1bfe4857677be78771c63a113f5c0b3fdfa92a2f (patch) | |
tree | bcae37b8c8750d5b8a274ba18450ac7b310f107a | |
parent | 03deeba18703fcaaf3ed34849f400a6ca9499ae1 (diff) | |
download | ChibiOS-1bfe4857677be78771c63a113f5c0b3fdfa92a2f.tar.gz ChibiOS-1bfe4857677be78771c63a113f5c0b3fdfa92a2f.tar.bz2 ChibiOS-1bfe4857677be78771c63a113f5c0b3fdfa92a2f.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9493 35acf78f-673a-0410-8e92-d51de3d6d3f4
-rw-r--r-- | os/ex/Micron/m25q.c | 8 | ||||
-rw-r--r-- | os/ex/Micron/m25q.h | 69 |
2 files changed, 43 insertions, 34 deletions
diff --git a/os/ex/Micron/m25q.c b/os/ex/Micron/m25q.c index 1d72cdf4f..09965fe53 100644 --- a/os/ex/Micron/m25q.c +++ b/os/ex/Micron/m25q.c @@ -36,7 +36,7 @@ #define PAGE_SIZE 256U #define PAGE_MASK (PAGE_SIZE - 1U) -#if N25Q128_USE_SUB_SECTORS == TRUE +#if M25Q_USE_SUB_SECTORS == TRUE #define SECTOR_SIZE 0x00001000U #define CMD_SECTOR_ERASE M25Q_CMD_SUBSECTOR_ERASE #else @@ -79,7 +79,7 @@ static flash_descriptor_t descriptor = { .attributes = FLASH_ATTR_ERASED_IS_ONE | FLASH_ATTR_REWRITABLE | FLASH_ATTR_SUSPEND_ERASE_CAPABLE, .page_size = 256U, -#if N25Q128_USE_SUB_SECTORS == TRUE +#if M25Q_USE_SUB_SECTORS == TRUE .sectors_count = 4096U, #else .sectors_count = 256U, @@ -93,7 +93,7 @@ static flash_descriptor_t descriptor = { /* 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) { spiAcquireBus(devp->config->spip); @@ -107,7 +107,7 @@ void flash_bus_release(M25QDriver *devp) { #else #define flash_bus_acquire(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) { uint8_t buf[1]; diff --git a/os/ex/Micron/m25q.h b/os/ex/Micron/m25q.h index e732da682..049ee7ff6 100644 --- a/os/ex/Micron/m25q.h +++ b/os/ex/Micron/m25q.h @@ -69,21 +69,31 @@ /** @} */ /** - * @name Status register bits + * @name Flags status register bits * @{ */ -#define N25Q128_STS_PROGRAM_ERASE 0x80U -#define N25Q128_STS_ERASE_SUSPEND 0x40U -#define N25Q128_STS_ERASE_ERROR 0x20U -#define N25Q128_STS_PROGRAM_ERROR 0x10U -#define N25Q128_STS_VPP_ERROR 0x08U -#define N25Q128_STS_PROGRAM_SUSPEND 0x04U -#define N25Q128_STS_PROTECTION_ERROR 0x02U -#define N25Q128_STS_RESERVED 0x01U -#define N25Q128_STS_ALL_ERRORS (N25Q128_STS_ERASE_ERROR | \ - N25Q128_STS_PROGRAM_ERROR | \ - N25Q128_STS_VPP_ERROR | \ - N25Q128_STS_PROTECTION_ERROR) +#define M25Q_FLAGS_PROGRAM_ERASE 0x80U +#define M25Q_FLAGS_ERASE_SUSPEND 0x40U +#define M25Q_FLAGS_ERASE_ERROR 0x20U +#define M25Q_FLAGS_PROGRAM_ERROR 0x10U +#define M25Q_FLAGS_VPP_ERROR 0x08U +#define M25Q_FLAGS_PROGRAM_SUSPEND 0x04U +#define M25Q_FLAGS_PROTECTION_ERROR 0x02U +#define M25Q_FLAGS_RESERVED 0x01U +#define M25Q_FLAGS_ALL_ERRORS (M25Q_FLAGS_ERASE_ERROR | \ + M25Q_FLAGS_PROGRAM_ERROR | \ + M25Q_FLAGS_VPP_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. - * @details If enabled makes the driver use SPI rather than QSPI. + * @brief Physical transport interface. */ #if !defined(M25Q_USE_SPI) || defined(__DOXYGEN__) -#define M25Q_USE_SPI FALSE +#define M25Q_BUS_MODE M25Q_BUS_MODE_QSPI4L #endif /** @@ -115,20 +124,18 @@ /** * @brief Delays insertions. * @details If enabled this options inserts delays into the flash waiting - * routines releasing some extra CPU time for the threads with - * lower 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. + * routines releasing some extra CPU time for threads with lower + * priority, this may slow down the driver a bit however. */ -#if !defined(N25Q128_NICE_WAITING) || defined(__DOXYGEN__) -#define N25Q128_NICE_WAITING TRUE +#if !defined(M25Q_NICE_WAITING) || defined(__DOXYGEN__) +#define M25Q_NICE_WAITING TRUE #endif /** * @brief Uses 4kB sub-sectors rather than 64kB sectors. */ -#if !defined(N25Q128_USE_SUB_SECTORS) || defined(__DOXYGEN__) -#define N25Q128_USE_SUB_SECTORS FALSE +#if !defined(M25Q_USE_SUB_SECTORS) || defined(__DOXYGEN__) +#define M25Q_USE_SUB_SECTORS FALSE #endif /** @} */ @@ -136,15 +143,17 @@ /* Derived constants and error checks. */ /*===========================================================================*/ -#if M25Q_USE_SPI && !HAL_USE_SPI -#error "M25Q_USE_SPI=TRUE requires HAL_USE_SPI" +#if (M25Q_BUS_MODE == M25Q_BUS_MODE_SPI) && (HAL_USE_SPI == FALSE) +#error "M25Q_BUS_MODE_SPI requires HAL_USE_SPI" #endif -#if !M25Q_USE_SPI && !HAL_USE_QSPI -#error "M25Q_USE_SPI=FALSE requires HAL_USE_QSPI" +#if (M25Q_BUS_MODE != M25Q_BUS_MODE_SPI) && (HAL_USE_QSPI == FALSE) +#error "M25Q_BUS_MODE_QSPIxL requires HAL_USE_QSPI" #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" #endif @@ -156,7 +165,7 @@ * @brief Type of a M25Q configuration structure. */ 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. */ |