28 #if (HAL_USE_WSPI == TRUE) || defined(__DOXYGEN__) 46 #if !defined(WSPI_USE_WAIT) || defined(__DOXYGEN__) 47 #define WSPI_USE_WAIT TRUE 54 #if !defined(WSPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) 55 #define WSPI_USE_MUTUAL_EXCLUSION TRUE 127 #if !defined(WSPI_SUPPORTS_MEMMAP) 128 #error "low level does not define WSPI_SUPPORTS_MEMMAP" 131 #if !defined(WSPI_DEFAULT_CFG_MASKS) 132 #error "low level does not define WSPI_DEFAULT_CFG_MASKS" 144 wspi_lld_config_fields;
159 #if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__) 165 #if (WSPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__) 171 #if defined(WSPI_DRIVER_EXT_FIELDS) 172 WSPI_DRIVER_EXT_FIELDS
182 #if (WSPI_DEFAULT_CFG_MASKS == TRUE) || defined(__DOXYGEN__) 191 #define WSPI_CFG_CMD_MODE_MASK (7LU << 0LU) 192 #define WSPI_CFG_CMD_MODE_NONE (0LU << 0LU) 193 #define WSPI_CFG_CMD_MODE_ONE_LINE (1LU << 0LU) 194 #define WSPI_CFG_CMD_MODE_TWO_LINES (2LU << 0LU) 195 #define WSPI_CFG_CMD_MODE_FOUR_LINES (3LU << 0LU) 196 #define WSPI_CFG_CMD_MODE_EIGHT_LINES (4LU << 0LU) 198 #define WSPI_CFG_CMD_DTR (1LU << 3LU) 200 #define WSPI_CFG_CMD_SIZE_MASK (3LU << 4LU) 201 #define WSPI_CFG_CMD_SIZE_8 (0LU << 4LU) 202 #define WSPI_CFG_CMD_SIZE_16 (1LU << 4LU) 203 #define WSPI_CFG_CMD_SIZE_24 (2LU << 4LU) 204 #define WSPI_CFG_CMD_SIZE_32 (3LU << 4LU) 206 #define WSPI_CFG_ADDR_MODE_MASK (7LU << 8LU) 207 #define WSPI_CFG_ADDR_MODE_NONE (0LU << 8LU) 208 #define WSPI_CFG_ADDR_MODE_ONE_LINE (1LU << 8LU) 209 #define WSPI_CFG_ADDR_MODE_TWO_LINES (2LU << 8LU) 210 #define WSPI_CFG_ADDR_MODE_FOUR_LINES (3LU << 8LU) 211 #define WSPI_CFG_ADDR_MODE_EIGHT_LINES (4LU << 8LU) 213 #define WSPI_CFG_ADDR_DTR (1LU << 11LU) 215 #define WSPI_CFG_ADDR_SIZE_MASK (3LU << 12LU) 216 #define WSPI_CFG_ADDR_SIZE_8 (0LU << 12LU) 217 #define WSPI_CFG_ADDR_SIZE_16 (1LU << 12LU) 218 #define WSPI_CFG_ADDR_SIZE_24 (2LU << 12LU) 219 #define WSPI_CFG_ADDR_SIZE_32 (3LU << 12LU) 221 #define WSPI_CFG_ALT_MODE_MASK (7LU << 16LU) 222 #define WSPI_CFG_ALT_MODE_NONE (0LU << 16LU) 223 #define WSPI_CFG_ALT_MODE_ONE_LINE (1LU << 16LU) 224 #define WSPI_CFG_ALT_MODE_TWO_LINES (2LU << 16LU) 225 #define WSPI_CFG_ALT_MODE_FOUR_LINES (3LU << 16LU) 226 #define WSPI_CFG_ALT_MODE_EIGHT_LINES (4LU << 16LU) 228 #define WSPI_CFG_ALT_DTR (1LU << 19LU) 230 #define WSPI_CFG_ALT_SIZE_MASK (3LU << 20LU) 231 #define WSPI_CFG_ALT_SIZE_8 (0LU << 20LU) 232 #define WSPI_CFG_ALT_SIZE_16 (1LU << 20LU) 233 #define WSPI_CFG_ALT_SIZE_24 (2LU << 20LU) 234 #define WSPI_CFG_ALT_SIZE_32 (3LU << 20LU) 236 #define WSPI_CFG_DATA_MODE_MASK (7LU << 24LU) 237 #define WSPI_CFG_DATA_MODE_NONE (0LU << 24LU) 238 #define WSPI_CFG_DATA_MODE_ONE_LINE (1LU << 24LU) 239 #define WSPI_CFG_DATA_MODE_TWO_LINES (2LU << 24LU) 240 #define WSPI_CFG_DATA_MODE_FOUR_LINES (3LU << 24LU) 241 #define WSPI_CFG_DATA_MODE_EIGHT_LINES (4LU << 24LU) 243 #define WSPI_CFG_DATA_DTR (1LU << 27LU) 245 #define WSPI_CFG_DQS_ENABLE (1LU << 29LU) 247 #define WSPI_CFG_SIOO (1LU << 31LU) 249 #define WSPI_CFG_ALL_DTR (WSPI_CFG_CMD_DTR | \ 250 WSPI_CFG_ADDR_DTR | \ 269 #define wspiStartCommandI(wspip, cmdp) { \ 270 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) == \ 271 WSPI_CFG_DATA_MODE_NONE, \ 272 "data mode specified"); \ 273 (wspip)->state = WSPI_ACTIVE; \ 274 wspi_lld_command(wspip, cmdp); \ 289 #define wspiStartSendI(wspip, cmdp, n, txbuf) { \ 290 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \ 291 WSPI_CFG_DATA_MODE_NONE, \ 292 "data mode required"); \ 293 (wspip)->state = WSPI_ACTIVE; \ 294 wspi_lld_send(wspip, cmdp, n, txbuf); \ 309 #define wspiStartReceiveI(wspip, cmdp, n, rxbuf) { \ 310 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \ 311 WSPI_CFG_DATA_MODE_NONE, \ 312 "data mode required"); \ 313 (wspip)->state = WSPI_ACTIVE; \ 314 wspi_lld_receive(wspip, cmdp, n, rxbuf); \ 317 #if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__) 330 #define wspiMapFlashI(wspip, cmdp, addrp) \ 331 wspi_lld_map_flash(wspip, cmdp, addrp) 342 #define wspiUnmapFlashI(wspip) \ 343 wspi_lld_unmap_flash(wspip) 351 #if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__) 359 #define _wspi_wakeup_isr(wspip) { \ 360 osalSysLockFromISR(); \ 361 osalThreadResumeI(&(wspip)->thread, MSG_OK); \ 362 osalSysUnlockFromISR(); \ 365 #define _wspi_wakeup_isr(wspip) 382 #define _wspi_isr_code(wspip) { \ 383 if ((wspip)->config->end_cb) { \ 384 (wspip)->state = WSPI_COMPLETE; \ 385 (wspip)->config->end_cb(wspip); \ 386 if ((wspip)->state == WSPI_COMPLETE) \ 387 (wspip)->state = WSPI_READY; \ 390 (wspip)->state = WSPI_READY; \ 391 _wspi_wakeup_isr(wspip); \ 408 size_t n,
const uint8_t *txbuf);
410 size_t n, uint8_t *rxbuf);
411 #if WSPI_USE_WAIT == TRUE 414 size_t n,
const uint8_t *txbuf);
416 size_t n, uint8_t *rxbuf);
418 #if WSPI_SUPPORTS_MEMMAP == TRUE 424 #if WSPI_USE_MUTUAL_EXCLUSION == TRUE void wspiMapFlash(WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp)
Maps in memory space a WSPI flash device.
wspicallback_t end_cb
Operation complete callback or NULL.
void wspiStartSend(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the WSPI bus.
void wspiAcquireBus(WSPIDriver *wspip)
Gains exclusive access to the WSPI bus.
uint32_t dummy
Number of dummy cycles to be inserted.
Structure representing an WSPI driver.
void wspiStart(WSPIDriver *wspip, const WSPIConfig *config)
Configures and activates the WSPI peripheral.
void wspiSend(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
Sends a command with data over the WSPI bus.
void wspiStop(WSPIDriver *wspip)
Deactivates the WSPI peripheral.
Driver configuration structure.
void wspiInit(void)
WSPI Driver initialization.
void wspiReleaseBus(WSPIDriver *wspip)
Releases exclusive access to the WSPI bus.
void(* wspicallback_t)(WSPIDriver *wspip)
Type of a WSPI notification callback.
void wspiUnmapFlash(WSPIDriver *wspip)
Unmaps from memory space a WSPI flash device.
uint32_t addr
Address phase data.
void wspiStartReceive(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the WSPI bus.
const WSPIConfig * config
Current configuration data.
void wspiObjectInit(WSPIDriver *wspip)
Initializes the standard part of a WSPIDriver structure.
wspistate_t state
Driver state.
uint32_t alt
Alternate phase data.
thread_reference_t thread
Waiting thread.
uint32_t cmd
Command phase data.
mutex_t mutex
Mutex protecting the peripheral.
void * thread_reference_t
Type of a thread reference.
void wspiReceive(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the WSPI bus.
Type of a WSPI command descriptor.
void wspiCommand(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
void wspiStartCommand(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
uint32_t mutex_t
Type of a mutex.
PLATFORM WSPI subsystem low level driver header.
uint32_t cfg
Transfer configuration field.
#define wspi_lld_driver_fields
Low level fields of the WSPI driver structure.
wspistate_t
Driver state machine possible states.