ChibiOS  21.6.0
WSPI Driver

Generic WSPI Driver. More...

Collaboration diagram for WSPI Driver:

Detailed Description

Generic WSPI Driver.

This module defines an abstract interface for an wide SPI communication interface (Quad SPI, Octal SPI and similar).

Precondition
In order to use the WSPI driver the HAL_USE_WSPI option must be enabled in halconf.h.

Macros

#define wspi_lld_driver_fields
 Low level fields of the WSPI driver structure. More...
 
#define wspi_lld_config_fields
 Low level fields of the WSPI configuration structure. More...
 

WSPI configuration options

#define WSPI_USE_WAIT   TRUE
 Enables synchronous APIs. More...
 
#define WSPI_USE_MUTUAL_EXCLUSION   TRUE
 Enables the wspiAcquireBus() and wspiReleaseBus() APIs. More...
 

Transfer options

Note
The low level driver has the option to override the following definitions and use its own ones. In must take care to use the same name for the same function or compatibility is not ensured.
#define WSPI_CFG_CMD_MODE_MASK   (7LU << 0LU)
 
#define WSPI_CFG_CMD_MODE_NONE   (0LU << 0LU)
 
#define WSPI_CFG_CMD_MODE_ONE_LINE   (1LU << 0LU)
 
#define WSPI_CFG_CMD_MODE_TWO_LINES   (2LU << 0LU)
 
#define WSPI_CFG_CMD_MODE_FOUR_LINES   (3LU << 0LU)
 
#define WSPI_CFG_CMD_MODE_EIGHT_LINES   (4LU << 0LU)
 
#define WSPI_CFG_CMD_DTR   (1LU << 3LU)
 
#define WSPI_CFG_CMD_SIZE_MASK   (3LU << 4LU)
 
#define WSPI_CFG_CMD_SIZE_8   (0LU << 4LU)
 
#define WSPI_CFG_CMD_SIZE_16   (1LU << 4LU)
 
#define WSPI_CFG_CMD_SIZE_24   (2LU << 4LU)
 
#define WSPI_CFG_CMD_SIZE_32   (3LU << 4LU)
 
#define WSPI_CFG_ADDR_MODE_MASK   (7LU << 8LU)
 
#define WSPI_CFG_ADDR_MODE_NONE   (0LU << 8LU)
 
#define WSPI_CFG_ADDR_MODE_ONE_LINE   (1LU << 8LU)
 
#define WSPI_CFG_ADDR_MODE_TWO_LINES   (2LU << 8LU)
 
#define WSPI_CFG_ADDR_MODE_FOUR_LINES   (3LU << 8LU)
 
#define WSPI_CFG_ADDR_MODE_EIGHT_LINES   (4LU << 8LU)
 
#define WSPI_CFG_ADDR_DTR   (1LU << 11LU)
 
#define WSPI_CFG_ADDR_SIZE_MASK   (3LU << 12LU)
 
#define WSPI_CFG_ADDR_SIZE_8   (0LU << 12LU)
 
#define WSPI_CFG_ADDR_SIZE_16   (1LU << 12LU)
 
#define WSPI_CFG_ADDR_SIZE_24   (2LU << 12LU)
 
#define WSPI_CFG_ADDR_SIZE_32   (3LU << 12LU)
 
#define WSPI_CFG_ALT_MODE_MASK   (7LU << 16LU)
 
#define WSPI_CFG_ALT_MODE_NONE   (0LU << 16LU)
 
#define WSPI_CFG_ALT_MODE_ONE_LINE   (1LU << 16LU)
 
#define WSPI_CFG_ALT_MODE_TWO_LINES   (2LU << 16LU)
 
#define WSPI_CFG_ALT_MODE_FOUR_LINES   (3LU << 16LU)
 
#define WSPI_CFG_ALT_MODE_EIGHT_LINES   (4LU << 16LU)
 
#define WSPI_CFG_ALT_DTR   (1LU << 19LU)
 
#define WSPI_CFG_ALT_SIZE_MASK   (3LU << 20LU)
 
#define WSPI_CFG_ALT_SIZE_8   (0LU << 20LU)
 
#define WSPI_CFG_ALT_SIZE_16   (1LU << 20LU)
 
#define WSPI_CFG_ALT_SIZE_24   (2LU << 20LU)
 
#define WSPI_CFG_ALT_SIZE_32   (3LU << 20LU)
 
#define WSPI_CFG_DATA_MODE_MASK   (7LU << 24LU)
 
#define WSPI_CFG_DATA_MODE_NONE   (0LU << 24LU)
 
#define WSPI_CFG_DATA_MODE_ONE_LINE   (1LU << 24LU)
 
#define WSPI_CFG_DATA_MODE_TWO_LINES   (2LU << 24LU)
 
#define WSPI_CFG_DATA_MODE_FOUR_LINES   (3LU << 24LU)
 
#define WSPI_CFG_DATA_MODE_EIGHT_LINES   (4LU << 24LU)
 
#define WSPI_CFG_DATA_DTR   (1LU << 27LU)
 
#define WSPI_CFG_DQS_ENABLE   (1LU << 29LU)
 
#define WSPI_CFG_SIOO   (1LU << 31LU)
 
#define WSPI_CFG_ALL_DTR
 

Macro Functions

#define wspiStartCommandI(wspip, cmdp)
 Sends a command without data phase. More...
 
#define wspiStartSendI(wspip, cmdp, n, txbuf)
 Sends data over the WSPI bus. More...
 
#define wspiStartReceiveI(wspip, cmdp, n, rxbuf)
 Receives data from the WSPI bus. More...
 
#define wspiMapFlashI(wspip, cmdp, addrp)   wspi_lld_map_flash(wspip, cmdp, addrp)
 Maps in memory space a WSPI flash device. More...
 
#define wspiUnmapFlashI(wspip)   wspi_lld_unmap_flash(wspip)
 Maps in memory space a WSPI flash device. More...
 

Low level driver helper macros

#define _wspi_wakeup_isr(wspip, msg)
 Wakes up the waiting thread. More...
 
#define _wspi_isr_code(wspip)
 Common ISR code. More...
 
#define _wspi_error_code(wspip)
 Common error ISR code. More...
 

WSPI implementation capabilities

#define WSPI_SUPPORTS_MEMMAP   TRUE
 
#define WSPI_DEFAULT_CFG_MASKS   TRUE
 

Configuration options

#define PLATFORM_WSPI_USE_WSPI1   FALSE
 WSPID1 driver enable switch. More...
 

Typedefs

typedef struct hal_wspi_driver WSPIDriver
 Type of a structure representing an WSPI driver. More...
 
typedef struct hal_wspi_config WSPIConfig
 Type of a structure representing an WSPI driver configuration. More...
 
typedef void(* wspicallback_t) (WSPIDriver *wspip)
 Type of a WSPI notification callback. More...
 

Data Structures

struct  wspi_command_t
 Type of a WSPI command descriptor. More...
 
struct  hal_wspi_config
 Driver configuration structure. More...
 
struct  hal_wspi_driver
 Structure representing an WSPI driver. More...
 

Functions

void wspiInit (void)
 WSPI Driver initialization. More...
 
void wspiObjectInit (WSPIDriver *wspip)
 Initializes the standard part of a WSPIDriver structure. More...
 
void wspiStart (WSPIDriver *wspip, const WSPIConfig *config)
 Configures and activates the WSPI peripheral. More...
 
void wspiStop (WSPIDriver *wspip)
 Deactivates the WSPI peripheral. More...
 
void wspiStartCommand (WSPIDriver *wspip, const wspi_command_t *cmdp)
 Sends a command without data phase. More...
 
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. More...
 
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. More...
 
bool wspiCommand (WSPIDriver *wspip, const wspi_command_t *cmdp)
 Sends a command without data phase. More...
 
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. More...
 
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. More...
 
void wspiMapFlash (WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp)
 Maps in memory space a WSPI flash device. More...
 
void wspiUnmapFlash (WSPIDriver *wspip)
 Unmaps from memory space a WSPI flash device. More...
 
void wspiAcquireBus (WSPIDriver *wspip)
 Gains exclusive access to the WSPI bus. More...
 
void wspiReleaseBus (WSPIDriver *wspip)
 Releases exclusive access to the WSPI bus. More...
 
void wspi_lld_init (void)
 Low level WSPI driver initialization. More...
 
void wspi_lld_start (WSPIDriver *wspip)
 Configures and activates the WSPI peripheral. More...
 
void wspi_lld_stop (WSPIDriver *wspip)
 Deactivates the WSPI peripheral. More...
 
void wspi_lld_command (WSPIDriver *wspip, const wspi_command_t *cmdp)
 Sends a command without data phase. More...
 
void wspi_lld_send (WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, const uint8_t *txbuf)
 Sends a command with data over the WSPI bus. More...
 
void wspi_lld_receive (WSPIDriver *wspip, const wspi_command_t *cmdp, size_t n, uint8_t *rxbuf)
 Sends a command then receives data over the WSPI bus. More...
 
void wspi_lld_map_flash (WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp)
 Maps in memory space a WSPI flash device. More...
 
void wspi_lld_unmap_flash (WSPIDriver *wspip)
 Unmaps from memory space a WSPI flash device. More...
 

Enumerations

enum  wspistate_t {
  WSPI_UNINIT = 0, WSPI_STOP = 1, WSPI_READY = 2, WSPI_SEND = 3,
  WSPI_RECEIVE = 4, WSPI_COMPLETE = 5, WSPI_MEMMAP = 6
}
 Driver state machine possible states. More...
 

Variables

WSPIDriver WSPID1
 WSPID1 driver identifier. More...
 

Macro Definition Documentation

◆ WSPI_USE_WAIT

#define WSPI_USE_WAIT   TRUE

Enables synchronous APIs.

Note
Disabling this option saves both code and data space.

Definition at line 47 of file hal_wspi.h.

◆ WSPI_USE_MUTUAL_EXCLUSION

#define WSPI_USE_MUTUAL_EXCLUSION   TRUE

Enables the wspiAcquireBus() and wspiReleaseBus() APIs.

Note
Disabling this option saves both code and data space.

Definition at line 55 of file hal_wspi.h.

◆ wspiStartCommandI

#define wspiStartCommandI (   wspip,
  cmdp 
)
Value:
{ \
osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) == \
WSPI_CFG_DATA_MODE_NONE, \
"data mode specified"); \
(wspip)->state = WSPI_SEND; \
wspi_lld_command(wspip, cmdp); \
}

Sends a command without data phase.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 274 of file hal_wspi.h.

◆ wspiStartSendI

#define wspiStartSendI (   wspip,
  cmdp,
  n,
  txbuf 
)
Value:
{ \
osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \
WSPI_CFG_DATA_MODE_NONE, \
"data mode required"); \
(wspip)->state = WSPI_SEND; \
wspi_lld_send(wspip, cmdp, n, txbuf); \
}

Sends data over the WSPI bus.

This asynchronous function starts a transmit operation.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send or zero if no data phase
[in]txbufthe pointer to the transmit buffer
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 294 of file hal_wspi.h.

◆ wspiStartReceiveI

#define wspiStartReceiveI (   wspip,
  cmdp,
  n,
  rxbuf 
)
Value:
{ \
osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) != \
WSPI_CFG_DATA_MODE_NONE, \
"data mode required"); \
(wspip)->state = WSPI_RECEIVE; \
wspi_lld_receive(wspip, cmdp, n, rxbuf); \
}

Receives data from the WSPI bus.

This asynchronous function starts a receive operation.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to receive or zero if no data phase
[out]rxbufthe pointer to the receive buffer
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 314 of file hal_wspi.h.

◆ wspiMapFlashI

#define wspiMapFlashI (   wspip,
  cmdp,
  addrp 
)    wspi_lld_map_flash(wspip, cmdp, addrp)

Maps in memory space a WSPI flash device.

Precondition
The memory flash device must be initialized appropriately before mapping it in memory space.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[out]addrppointer to the memory start address of the mapped flash or NULL
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 335 of file hal_wspi.h.

◆ wspiUnmapFlashI

#define wspiUnmapFlashI (   wspip)    wspi_lld_unmap_flash(wspip)

Maps in memory space a WSPI flash device.

Postcondition
The memory flash device must be re-initialized for normal commands exchange.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 347 of file hal_wspi.h.

◆ _wspi_wakeup_isr

#define _wspi_wakeup_isr (   wspip,
  msg 
)
Value:
{ \
osalSysLockFromISR(); \
osalThreadResumeI(&(wspip)->thread, msg); \
osalSysUnlockFromISR(); \
}

Wakes up the waiting thread.

Parameters
[in]wspippointer to the WSPIDriver object
[in]msgthe wakeup message
Function Class:
Not an API, this function is for internal use only.

Definition at line 365 of file hal_wspi.h.

◆ _wspi_isr_code

#define _wspi_isr_code (   wspip)
Value:
{ \
if ((wspip)->config->end_cb) { \
(wspip)->state = WSPI_COMPLETE; \
(wspip)->config->end_cb(wspip); \
if ((wspip)->state == WSPI_COMPLETE) \
(wspip)->state = WSPI_READY; \
} \
else \
(wspip)->state = WSPI_READY; \
_wspi_wakeup_isr(wspip, MSG_OK); \
}

Common ISR code.

This code handles the portable part of the ISR code:

  • Callback invocation.
  • Waiting thread wakeup, if any.
  • Driver state transitions.
Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 388 of file hal_wspi.h.

◆ _wspi_error_code

#define _wspi_error_code (   wspip)
Value:
{ \
if ((wspip)->config->error_cb) { \
(wspip)->state = WSPI_COMPLETE; \
(wspip)->config->error_cb(wspip); \
if ((wspip)->state == WSPI_COMPLETE) \
(wspip)->state = WSPI_READY; \
} \
else \
(wspip)->state = WSPI_READY; \
_wspi_wakeup_isr(wspip, MSG_RESET); \
}

Common error ISR code.

This code handles the portable part of the ISR code:

  • Callback invocation.
  • Waiting thread wakeup, if any.
  • Driver state transitions.
Note
This macro is meant to be used in the low level drivers implementation only.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 414 of file hal_wspi.h.

◆ PLATFORM_WSPI_USE_WSPI1

#define PLATFORM_WSPI_USE_WSPI1   FALSE

WSPID1 driver enable switch.

If set to TRUE the support for WSPID1 is included.

Note
The default is FALSE.

Definition at line 56 of file hal_wspi_lld.h.

◆ wspi_lld_driver_fields

#define wspi_lld_driver_fields
Value:
/* Dummy field, it is not needed.*/ \
uint32_t dummy

Low level fields of the WSPI driver structure.

Definition at line 75 of file hal_wspi_lld.h.

◆ wspi_lld_config_fields

#define wspi_lld_config_fields
Value:
/* Dummy configuration, it is not needed.*/ \
uint32_t dummy

Low level fields of the WSPI configuration structure.

Definition at line 82 of file hal_wspi_lld.h.

Typedef Documentation

◆ WSPIDriver

typedef struct hal_wspi_driver WSPIDriver

Type of a structure representing an WSPI driver.

Definition at line 83 of file hal_wspi.h.

◆ WSPIConfig

typedef struct hal_wspi_config WSPIConfig

Type of a structure representing an WSPI driver configuration.

Definition at line 88 of file hal_wspi.h.

◆ wspicallback_t

typedef void(* wspicallback_t) (WSPIDriver *wspip)

Type of a WSPI notification callback.

Parameters
[in]wspippointer to the WSPIDriver object triggering the callback

Definition at line 96 of file hal_wspi.h.

Enumeration Type Documentation

◆ wspistate_t

Driver state machine possible states.

Enumerator
WSPI_UNINIT 

Not initialized.

WSPI_STOP 

Stopped.

WSPI_READY 

Ready.

WSPI_SEND 

Sending data.

WSPI_RECEIVE 

Receiving data.

WSPI_COMPLETE 

Asynchronous operation complete.

WSPI_MEMMAP 

In memory mapped mode.

Definition at line 70 of file hal_wspi.h.

Function Documentation

◆ wspiInit()

void wspiInit ( void  )

WSPI Driver initialization.

Note
This function is implicitly invoked by halInit(), there is no need to explicitly initialize the driver.
Function Class:
Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 56 of file hal_wspi.c.

References wspi_lld_init().

Referenced by halInit().

Here is the call graph for this function:

◆ wspiObjectInit()

void wspiObjectInit ( WSPIDriver wspip)

Initializes the standard part of a WSPIDriver structure.

Parameters
[out]wspippointer to the WSPIDriver object
Function Class:
Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 68 of file hal_wspi.c.

References hal_wspi_driver::config, hal_wspi_driver::mutex, osalMutexObjectInit(), hal_wspi_driver::state, hal_wspi_driver::thread, and WSPI_STOP.

Referenced by wspi_lld_init().

Here is the call graph for this function:

◆ wspiStart()

void wspiStart ( WSPIDriver wspip,
const WSPIConfig config 
)

Configures and activates the WSPI peripheral.

Parameters
[in]wspippointer to the WSPIDriver object
[in]configpointer to the WSPIConfig object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 91 of file hal_wspi.c.

References hal_wspi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, wspi_lld_start(), WSPI_READY, and WSPI_STOP.

Here is the call graph for this function:

◆ wspiStop()

void wspiStop ( WSPIDriver wspip)

Deactivates the WSPI peripheral.

Note
Deactivating the peripheral also enforces a release of the slave select line.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 116 of file hal_wspi.c.

References hal_wspi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, wspi_lld_stop(), WSPI_READY, and WSPI_STOP.

Here is the call graph for this function:

◆ wspiStartCommand()

void wspiStartCommand ( WSPIDriver wspip,
const wspi_command_t cmdp 
)

Sends a command without data phase.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 141 of file hal_wspi.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, WSPI_READY, and wspiStartCommandI.

Here is the call graph for this function:

◆ wspiStartSend()

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.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[in]txbufthe pointer to the transmit buffer
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 165 of file hal_wspi.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, WSPI_READY, and wspiStartSendI.

Here is the call graph for this function:

◆ wspiStartReceive()

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.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[out]rxbufthe pointer to the receive buffer
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 191 of file hal_wspi.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, WSPI_READY, and wspiStartReceiveI.

Here is the call graph for this function:

◆ wspiCommand()

bool wspiCommand ( WSPIDriver wspip,
const wspi_command_t cmdp 
)

Sends a command without data phase.

Precondition
In order to use this function the option WSPI_USE_WAIT must be enabled.
In order to use this function the driver must have been configured without callbacks (end_cb = NULL).
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
Returns
The operation status.
Return values
falseif the operation succeeded.
trueif the operation failed because HW issues.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 222 of file hal_wspi.c.

References wspi_command_t::cfg, and osalDbgCheck.

◆ wspiSend()

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.

Precondition
In order to use this function the option WSPI_USE_WAIT must be enabled.
In order to use this function the driver must have been configured without callbacks (end_cb = NULL).
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[in]txbufthe pointer to the transmit buffer
Returns
The operation status.
Return values
falseif the operation succeeded.
trueif the operation failed because HW issues.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 258 of file hal_wspi.c.

References wspi_command_t::cfg, and osalDbgCheck.

◆ wspiReceive()

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.

Precondition
In order to use this function the option WSPI_USE_WAIT must be enabled.
In order to use this function the driver must have been configured without callbacks (end_cb = NULL).
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[out]rxbufthe pointer to the receive buffer
Returns
The operation status.
Return values
falseif the operation succeeded.
trueif the operation failed because HW issues.
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 296 of file hal_wspi.c.

References wspi_command_t::cfg, and osalDbgCheck.

◆ wspiMapFlash()

void wspiMapFlash ( WSPIDriver wspip,
const wspi_command_t cmdp,
uint8_t **  addrp 
)

Maps in memory space a WSPI flash device.

Precondition
The memory flash device must be initialized appropriately before mapping it in memory space.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[out]addrppointer to the memory start address of the mapped flash or NULL
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 331 of file hal_wspi.c.

References wspi_command_t::cfg, and osalDbgCheck.

Referenced by snorMemoryMap().

◆ wspiUnmapFlash()

void wspiUnmapFlash ( WSPIDriver wspip)

Unmaps from memory space a WSPI flash device.

Postcondition
The memory flash device must be re-initialized for normal commands exchange.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 357 of file hal_wspi.c.

References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, WSPI_MEMMAP, WSPI_READY, and wspiUnmapFlashI.

Referenced by snorMemoryUnmap().

Here is the call graph for this function:

◆ wspiAcquireBus()

void wspiAcquireBus ( WSPIDriver wspip)

Gains exclusive access to the WSPI bus.

This function tries to gain ownership to the WSPI bus, if the bus is already being used then the invoking thread is queued.

Precondition
In order to use this function the option WSPI_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 384 of file hal_wspi.c.

References hal_wspi_driver::mutex, osalDbgCheck, and osalMutexLock().

Here is the call graph for this function:

◆ wspiReleaseBus()

void wspiReleaseBus ( WSPIDriver wspip)

Releases exclusive access to the WSPI bus.

Precondition
In order to use this function the option WSPI_USE_MUTUAL_EXCLUSION must be enabled.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 400 of file hal_wspi.c.

References hal_wspi_driver::mutex, osalDbgCheck, and osalMutexUnlock().

Here is the call graph for this function:

◆ wspi_lld_init()

void wspi_lld_init ( void  )

Low level WSPI driver initialization.

Function Class:
Not an API, this function is for internal use only.

Definition at line 63 of file hal_wspi_lld.c.

References WSPID1, and wspiObjectInit().

Referenced by wspiInit().

Here is the call graph for this function:

◆ wspi_lld_start()

void wspi_lld_start ( WSPIDriver wspip)

Configures and activates the WSPI peripheral.

Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 77 of file hal_wspi_lld.c.

References hal_wspi_driver::state, WSPI_STOP, and WSPID1.

Referenced by wspiStart().

◆ wspi_lld_stop()

void wspi_lld_stop ( WSPIDriver wspip)

Deactivates the WSPI peripheral.

Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 99 of file hal_wspi_lld.c.

References hal_wspi_driver::state, WSPI_READY, and WSPID1.

Referenced by wspiStop().

◆ wspi_lld_command()

void wspi_lld_command ( WSPIDriver wspip,
const wspi_command_t cmdp 
)

Sends a command without data phase.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
Function Class:
Not an API, this function is for internal use only.

Definition at line 123 of file hal_wspi_lld.c.

◆ wspi_lld_send()

void wspi_lld_send ( WSPIDriver wspip,
const wspi_command_t cmdp,
size_t  n,
const uint8_t *  txbuf 
)

Sends a command with data over the WSPI bus.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[in]txbufthe pointer to the transmit buffer
Function Class:
Not an API, this function is for internal use only.

Definition at line 140 of file hal_wspi_lld.c.

◆ wspi_lld_receive()

void wspi_lld_receive ( WSPIDriver wspip,
const wspi_command_t cmdp,
size_t  n,
uint8_t *  rxbuf 
)

Sends a command then receives data over the WSPI bus.

Postcondition
At the end of the operation the configured callback is invoked.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[in]nnumber of bytes to send
[out]rxbufthe pointer to the receive buffer
Function Class:
Not an API, this function is for internal use only.

Definition at line 160 of file hal_wspi_lld.c.

◆ wspi_lld_map_flash()

void wspi_lld_map_flash ( WSPIDriver wspip,
const wspi_command_t cmdp,
uint8_t **  addrp 
)

Maps in memory space a WSPI flash device.

Precondition
The memory flash device must be initialized appropriately before mapping it in memory space.
Parameters
[in]wspippointer to the WSPIDriver object
[in]cmdppointer to the command descriptor
[out]addrppointer to the memory start address of the mapped flash or NULL
Function Class:
Not an API, this function is for internal use only.

Definition at line 182 of file hal_wspi_lld.c.

◆ wspi_lld_unmap_flash()

void wspi_lld_unmap_flash ( WSPIDriver wspip)

Unmaps from memory space a WSPI flash device.

Postcondition
The memory flash device must be re-initialized for normal commands exchange.
Parameters
[in]wspippointer to the WSPIDriver object
Function Class:
Not an API, this function is for internal use only.

Definition at line 200 of file hal_wspi_lld.c.

Variable Documentation

◆ WSPID1

WSPIDriver WSPID1

WSPID1 driver identifier.

Definition at line 39 of file hal_wspi_lld.c.

Referenced by wspi_lld_init(), wspi_lld_start(), and wspi_lld_stop().

MSG_RESET
#define MSG_RESET
Wakeup caused by a reset condition.
Definition: chschd.h:42
WSPI_COMPLETE
@ WSPI_COMPLETE
Definition: hal_wspi.h:76
MSG_OK
#define MSG_OK
Normal wakeup message.
Definition: chschd.h:39
WSPI_SEND
@ WSPI_SEND
Definition: hal_wspi.h:74
WSPI_READY
@ WSPI_READY
Definition: hal_wspi.h:73
WSPI_RECEIVE
@ WSPI_RECEIVE
Definition: hal_wspi.h:75