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
128#if !defined(WSPI_SUPPORTS_MEMMAP)
129#error "low level does not define WSPI_SUPPORTS_MEMMAP"
132#if !defined(WSPI_DEFAULT_CFG_MASKS)
133#error "low level does not define WSPI_DEFAULT_CFG_MASKS"
164#if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
170#if (WSPI_USE_MUTUAL_EXCLUSION == TRUE) || defined(__DOXYGEN__)
176#if defined(WSPI_DRIVER_EXT_FIELDS)
177 WSPI_DRIVER_EXT_FIELDS
187#if (WSPI_DEFAULT_CFG_MASKS == TRUE) || defined(__DOXYGEN__)
196#define WSPI_CFG_CMD_MODE_MASK (7LU << 0LU)
197#define WSPI_CFG_CMD_MODE_NONE (0LU << 0LU)
198#define WSPI_CFG_CMD_MODE_ONE_LINE (1LU << 0LU)
199#define WSPI_CFG_CMD_MODE_TWO_LINES (2LU << 0LU)
200#define WSPI_CFG_CMD_MODE_FOUR_LINES (3LU << 0LU)
201#define WSPI_CFG_CMD_MODE_EIGHT_LINES (4LU << 0LU)
203#define WSPI_CFG_CMD_DTR (1LU << 3LU)
205#define WSPI_CFG_CMD_SIZE_MASK (3LU << 4LU)
206#define WSPI_CFG_CMD_SIZE_8 (0LU << 4LU)
207#define WSPI_CFG_CMD_SIZE_16 (1LU << 4LU)
208#define WSPI_CFG_CMD_SIZE_24 (2LU << 4LU)
209#define WSPI_CFG_CMD_SIZE_32 (3LU << 4LU)
211#define WSPI_CFG_ADDR_MODE_MASK (7LU << 8LU)
212#define WSPI_CFG_ADDR_MODE_NONE (0LU << 8LU)
213#define WSPI_CFG_ADDR_MODE_ONE_LINE (1LU << 8LU)
214#define WSPI_CFG_ADDR_MODE_TWO_LINES (2LU << 8LU)
215#define WSPI_CFG_ADDR_MODE_FOUR_LINES (3LU << 8LU)
216#define WSPI_CFG_ADDR_MODE_EIGHT_LINES (4LU << 8LU)
218#define WSPI_CFG_ADDR_DTR (1LU << 11LU)
220#define WSPI_CFG_ADDR_SIZE_MASK (3LU << 12LU)
221#define WSPI_CFG_ADDR_SIZE_8 (0LU << 12LU)
222#define WSPI_CFG_ADDR_SIZE_16 (1LU << 12LU)
223#define WSPI_CFG_ADDR_SIZE_24 (2LU << 12LU)
224#define WSPI_CFG_ADDR_SIZE_32 (3LU << 12LU)
226#define WSPI_CFG_ALT_MODE_MASK (7LU << 16LU)
227#define WSPI_CFG_ALT_MODE_NONE (0LU << 16LU)
228#define WSPI_CFG_ALT_MODE_ONE_LINE (1LU << 16LU)
229#define WSPI_CFG_ALT_MODE_TWO_LINES (2LU << 16LU)
230#define WSPI_CFG_ALT_MODE_FOUR_LINES (3LU << 16LU)
231#define WSPI_CFG_ALT_MODE_EIGHT_LINES (4LU << 16LU)
233#define WSPI_CFG_ALT_DTR (1LU << 19LU)
235#define WSPI_CFG_ALT_SIZE_MASK (3LU << 20LU)
236#define WSPI_CFG_ALT_SIZE_8 (0LU << 20LU)
237#define WSPI_CFG_ALT_SIZE_16 (1LU << 20LU)
238#define WSPI_CFG_ALT_SIZE_24 (2LU << 20LU)
239#define WSPI_CFG_ALT_SIZE_32 (3LU << 20LU)
241#define WSPI_CFG_DATA_MODE_MASK (7LU << 24LU)
242#define WSPI_CFG_DATA_MODE_NONE (0LU << 24LU)
243#define WSPI_CFG_DATA_MODE_ONE_LINE (1LU << 24LU)
244#define WSPI_CFG_DATA_MODE_TWO_LINES (2LU << 24LU)
245#define WSPI_CFG_DATA_MODE_FOUR_LINES (3LU << 24LU)
246#define WSPI_CFG_DATA_MODE_EIGHT_LINES (4LU << 24LU)
248#define WSPI_CFG_DATA_DTR (1LU << 27LU)
250#define WSPI_CFG_DQS_ENABLE (1LU << 29LU)
252#define WSPI_CFG_SIOO (1LU << 31LU)
254#define WSPI_CFG_ALL_DTR (WSPI_CFG_CMD_DTR | \
255 WSPI_CFG_ADDR_DTR | \
274#define wspiStartCommandI(wspip, cmdp) { \
275 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) == \
276 WSPI_CFG_DATA_MODE_NONE, \
277 "data mode specified"); \
278 (wspip)->state = WSPI_SEND; \
279 wspi_lld_command(wspip, cmdp); \
294#define wspiStartSendI(wspip, cmdp, n, txbuf) { \
295 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \
296 WSPI_CFG_DATA_MODE_NONE, \
297 "data mode required"); \
298 (wspip)->state = WSPI_SEND; \
299 wspi_lld_send(wspip, cmdp, n, txbuf); \
314#define wspiStartReceiveI(wspip, cmdp, n, rxbuf) { \
315 osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \
316 WSPI_CFG_DATA_MODE_NONE, \
317 "data mode required"); \
318 (wspip)->state = WSPI_RECEIVE; \
319 wspi_lld_receive(wspip, cmdp, n, rxbuf); \
322#if (WSPI_SUPPORTS_MEMMAP == TRUE) || defined(__DOXYGEN__)
335#define wspiMapFlashI(wspip, cmdp, addrp) \
336 wspi_lld_map_flash(wspip, cmdp, addrp)
347#define wspiUnmapFlashI(wspip) \
348 wspi_lld_unmap_flash(wspip)
356#if (WSPI_USE_WAIT == TRUE) || defined(__DOXYGEN__)
365#define _wspi_wakeup_isr(wspip, msg) { \
366 osalSysLockFromISR(); \
367 osalThreadResumeI(&(wspip)->thread, msg); \
368 osalSysUnlockFromISR(); \
371#define _wspi_wakeup_isr(wspip, msg)
388#define _wspi_isr_code(wspip) { \
389 if ((wspip)->config->end_cb) { \
390 (wspip)->state = WSPI_COMPLETE; \
391 (wspip)->config->end_cb(wspip); \
392 if ((wspip)->state == WSPI_COMPLETE) \
393 (wspip)->state = WSPI_READY; \
396 (wspip)->state = WSPI_READY; \
397 _wspi_wakeup_isr(wspip, MSG_OK); \
414#define _wspi_error_code(wspip) { \
415 if ((wspip)->config->error_cb) { \
416 (wspip)->state = WSPI_COMPLETE; \
417 (wspip)->config->error_cb(wspip); \
418 if ((wspip)->state == WSPI_COMPLETE) \
419 (wspip)->state = WSPI_READY; \
422 (wspip)->state = WSPI_READY; \
423 _wspi_wakeup_isr(wspip, MSG_RESET); \
440 size_t n,
const uint8_t *txbuf);
442 size_t n, uint8_t *rxbuf);
443#if WSPI_USE_WAIT == TRUE
446 size_t n,
const uint8_t *txbuf);
448 size_t n, uint8_t *rxbuf);
450#if WSPI_SUPPORTS_MEMMAP == TRUE
456#if WSPI_USE_MUTUAL_EXCLUSION == TRUE
int32_t msg_t
Type of a message.
void * thread_reference_t
Type of a thread reference.
uint32_t mutex_t
Type of a mutex.
#define wspi_lld_driver_fields
Low level fields of the WSPI driver structure.
void wspiObjectInit(WSPIDriver *wspip)
Initializes the standard part of a WSPIDriver structure.
void wspiMapFlash(WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp)
Maps in memory space a WSPI flash device.
#define wspi_lld_config_fields
Low level fields of the WSPI configuration structure.
struct hal_wspi_driver WSPIDriver
Type of a structure representing an WSPI driver.
void wspiAcquireBus(WSPIDriver *wspip)
Gains exclusive access to the WSPI bus.
wspistate_t
Driver state machine possible states.
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 wspiInit(void)
WSPI Driver initialization.
void wspiStartCommand(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
msg_t wspiStart(WSPIDriver *wspip, const WSPIConfig *config)
Configures and activates the WSPI peripheral.
bool wspiReceive(WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
Sends a command then receives data over the WSPI bus.
void wspiReleaseBus(WSPIDriver *wspip)
Releases exclusive access to the WSPI bus.
bool wspiCommand(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
bool 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 wspiUnmapFlash(WSPIDriver *wspip)
Unmaps from memory space a WSPI flash device.
void(* wspicallback_t)(WSPIDriver *wspip)
Type of a WSPI notification callback.
struct hal_wspi_config WSPIConfig
Type of a structure representing an WSPI driver configuration.
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.
void wspiStop(WSPIDriver *wspip)
Deactivates the WSPI peripheral.
PLATFORM WSPI subsystem low level driver header.
Driver configuration structure.
wspicallback_t error_cb
Operation error callback or NULL.
wspicallback_t end_cb
Operation complete callback or NULL.
Structure representing an WSPI driver.
const WSPIConfig * config
Current configuration data.
thread_reference_t thread
Waiting thread.
wspistate_t state
Driver state.
mutex_t mutex
Mutex protecting the peripheral.
Type of a WSPI command descriptor.
uint32_t dummy
Number of dummy cycles to be inserted.
uint32_t cfg
Transfer configuration field.
uint32_t alt
Alternate phase data.
uint32_t addr
Address phase data.
uint32_t cmd
Command phase data.