ChibiOS/HAL  7.0.3
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)
 Wakes up the waiting thread. More...
 
#define _wspi_isr_code(wspip)
 Common 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...
 
void wspiCommand (WSPIDriver *wspip, const wspi_command_t *cmdp)
 Sends a command without data phase. More...
 
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. More...
 
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. 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

Variables

WSPIDriver WSPID1
 WSPID1 driver identifier. More...
 

Macro Definition Documentation

#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.

#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.

#define wspiStartCommandI (   wspip,
  cmdp 
)
Value:
{ \
osalDbgAssert(((cmdp)->cfg & WSPI_CFG_DATA_MODE_MASK) == \
WSPI_CFG_DATA_MODE_NONE, \
"data mode specified"); \
(wspip)->state = WSPI_ACTIVE; \
wspi_lld_command(wspip, cmdp); \
}
void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp)
Sends a command without data phase.
Definition: hal_wspi_lld.c:123
#define osalDbgAssert(c, remark)
Condition assertion.
Definition: osal.h:258

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 269 of file hal_wspi.h.

Referenced by wspiCommand(), and wspiStartCommand().

#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_ACTIVE; \
wspi_lld_send(wspip, cmdp, n, txbuf); \
}
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.
Definition: hal_wspi_lld.c:140
#define osalDbgAssert(c, remark)
Condition assertion.
Definition: osal.h:258

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 289 of file hal_wspi.h.

Referenced by wspiSend(), and wspiStartSend().

#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_ACTIVE; \
wspi_lld_receive(wspip, cmdp, n, rxbuf); \
}
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.
Definition: hal_wspi_lld.c:160
#define osalDbgAssert(c, remark)
Condition assertion.
Definition: osal.h:258

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 309 of file hal_wspi.h.

Referenced by wspiReceive(), and wspiStartReceive().

#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 330 of file hal_wspi.h.

Referenced by wspiMapFlash().

#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 342 of file hal_wspi.h.

Referenced by wspiUnmapFlash().

#define _wspi_wakeup_isr (   wspip)
Value:
{ \
osalThreadResumeI(&(wspip)->thread, MSG_OK); \
}
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
Definition: osal.h:550
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
Definition: osal.h:560
void osalThreadResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition: osal.c:230

Wakes up the waiting thread.

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

Definition at line 359 of file hal_wspi.h.

#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; \
}
#define _wspi_wakeup_isr(wspip)
Wakes up the waiting thread.
Definition: hal_wspi.h:359

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 382 of file hal_wspi.h.

#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.

#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.

#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

typedef struct hal_wspi_driver WSPIDriver

Type of a structure representing an WSPI driver.

Definition at line 82 of file hal_wspi.h.

typedef struct hal_wspi_config WSPIConfig

Type of a structure representing an WSPI driver configuration.

Definition at line 87 of file hal_wspi.h.

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 95 of file hal_wspi.h.

Enumeration Type Documentation

Driver state machine possible states.

Enumerator
WSPI_UNINIT 

Not initialized.

WSPI_STOP 

Stopped.

WSPI_READY 

Ready.

WSPI_ACTIVE 

Exchanging data.

WSPI_COMPLETE 

Asynchronous operation complete.

WSPI_MEMMAP 

In memory mapped mode.

Definition at line 70 of file hal_wspi.h.

Function Documentation

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:

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:

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.

Referenced by bus_acquire().

Here is the call graph for this function:

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.

Referenced by bus_stop().

Here is the call graph for this function:

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:

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:

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:

void 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
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 219 of file hal_wspi.c.

References wspi_command_t::cfg, hal_wspi_driver::config, hal_wspi_config::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), hal_wspi_driver::state, hal_wspi_driver::thread, WSPI_READY, and wspiStartCommandI.

Referenced by bus_cmd(), and bus_cmd_addr().

Here is the call graph for this function:

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.

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
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 249 of file hal_wspi.c.

References wspi_command_t::cfg, hal_wspi_driver::config, hal_wspi_config::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), hal_wspi_driver::state, hal_wspi_driver::thread, WSPI_READY, and wspiStartSendI.

Referenced by bus_cmd_addr_send(), and bus_cmd_send().

Here is the call graph for this function:

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.

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
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 281 of file hal_wspi.c.

References wspi_command_t::cfg, hal_wspi_driver::config, hal_wspi_config::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), hal_wspi_driver::state, hal_wspi_driver::thread, WSPI_READY, and wspiStartReceiveI.

Referenced by bus_cmd_addr_dummy_receive(), bus_cmd_addr_receive(), bus_cmd_dummy_receive(), and bus_cmd_receive().

Here is the call graph for this function:

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 313 of file hal_wspi.c.

References wspi_command_t::cfg, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), hal_wspi_driver::state, WSPI_MEMMAP, WSPI_READY, and wspiMapFlashI.

Referenced by snorMemoryMap().

Here is the call graph for this function:

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 339 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:

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 366 of file hal_wspi.c.

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

Referenced by bus_acquire().

Here is the call graph for this function:

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 382 of file hal_wspi.c.

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

Referenced by bus_release().

Here is the call graph for this function:

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 wspiObjectInit().

Referenced by wspiInit().

Here is the call graph for this function:

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, and WSPI_STOP.

Referenced by wspiStart().

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, and WSPI_READY.

Referenced by wspiStop().

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.

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.

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.

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.

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

WSPIDriver WSPID1

WSPID1 driver identifier.

Definition at line 39 of file hal_wspi_lld.c.