ChibiOS/HAL
6.1.0
|
Generic QSPI Driver. More...
Generic QSPI Driver.
This module defines an abstract interface for a Quad SPI communication interface.
HAL_USE_QSPI
option must be enabled in halconf.h
. QSPI configuration options | |
#define | QSPI_USE_WAIT TRUE |
Enables synchronous APIs. More... | |
#define | QSPI_USE_MUTUAL_EXCLUSION TRUE |
Enables the qspiAcquireBus() and qspiReleaseBus() APIs. More... | |
Macro Functions | |
#define | qspiStartCommandI(qspip, cmdp) |
Sends a command without data phase. More... | |
#define | qspiStartSendI(qspip, cmdp, n, txbuf) |
Sends data over the QSPI bus. More... | |
#define | qspiStartReceiveI(qspip, cmdp, n, rxbuf) |
Receives data from the QSPI bus. More... | |
#define | qspiMapFlashI(qspip, cmdp, addrp) qspi_lld_map_flash(qspip, cmdp, addrp) |
Maps in memory space a QSPI flash device. More... | |
#define | qspiUnmapFlashI(qspip) qspi_lld_unmap_flash(qspip) |
Maps in memory space a QSPI flash device. More... | |
Low level driver helper macros | |
#define | _qspi_wakeup_isr(qspip) |
Wakes up the waiting thread. More... | |
#define | _qspi_isr_code(qspip) |
Common ISR code. More... | |
QSPI capabilities | |
#define | QSPI_SUPPORTS_MEMMAP TRUE |
Configuration options | |
#define | PLATFORM_QSPI_USE_QSPI1 FALSE |
QSPID1 driver enable switch. More... | |
Typedefs | |
typedef struct QSPIDriver | QSPIDriver |
Type of a structure representing an QSPI driver. More... | |
typedef void(* | qspicallback_t) (QSPIDriver *qspip) |
Type of a QSPI notification callback. More... | |
Data Structures | |
struct | qspi_command_t |
Type of a QSPI command descriptor. More... | |
struct | QSPIConfig |
Driver configuration structure. More... | |
struct | QSPIDriver |
Structure representing an QSPI driver. More... | |
Functions | |
void | qspiInit (void) |
QSPI Driver initialization. More... | |
void | qspiObjectInit (QSPIDriver *qspip) |
Initializes the standard part of a QSPIDriver structure. More... | |
void | qspiStart (QSPIDriver *qspip, const QSPIConfig *config) |
Configures and activates the QSPI peripheral. More... | |
void | qspiStop (QSPIDriver *qspip) |
Deactivates the QSPI peripheral. More... | |
void | qspiStartCommand (QSPIDriver *qspip, const qspi_command_t *cmdp) |
Sends a command without data phase. More... | |
void | qspiStartSend (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf) |
Sends a command with data over the QSPI bus. More... | |
void | qspiStartReceive (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf) |
Sends a command then receives data over the QSPI bus. More... | |
void | qspiCommand (QSPIDriver *qspip, const qspi_command_t *cmdp) |
Sends a command without data phase. More... | |
void | qspiSend (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf) |
Sends a command with data over the QSPI bus. More... | |
void | qspiReceive (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf) |
Sends a command then receives data over the QSPI bus. More... | |
void | qspiMapFlash (QSPIDriver *qspip, const qspi_command_t *cmdp, uint8_t **addrp) |
Maps in memory space a QSPI flash device. More... | |
void | qspiUnmapFlash (QSPIDriver *qspip) |
Unmaps from memory space a QSPI flash device. More... | |
void | qspiAcquireBus (QSPIDriver *qspip) |
Gains exclusive access to the QSPI bus. More... | |
void | qspiReleaseBus (QSPIDriver *qspip) |
Releases exclusive access to the QSPI bus. More... | |
void | qspi_lld_init (void) |
Low level QSPI driver initialization. More... | |
void | qspi_lld_start (QSPIDriver *qspip) |
Configures and activates the QSPI peripheral. More... | |
void | qspi_lld_stop (QSPIDriver *qspip) |
Deactivates the QSPI peripheral. More... | |
void | qspi_lld_command (QSPIDriver *qspip, const qspi_command_t *cmdp) |
Sends a command without data phase. More... | |
void | qspi_lld_send (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, const uint8_t *txbuf) |
Sends a command with data over the QSPI bus. More... | |
void | qspi_lld_receive (QSPIDriver *qspip, const qspi_command_t *cmdp, size_t n, uint8_t *rxbuf) |
Sends a command then receives data over the QSPI bus. More... | |
void | qspi_lld_map_flash (QSPIDriver *qspip, const qspi_command_t *cmdp, uint8_t **addrp) |
Maps in memory space a QSPI flash device. More... | |
void | qspi_lld_unmap_flash (QSPIDriver *qspip) |
Unmaps from memory space a QSPI flash device. More... | |
Enumerations |
Variables | |
QSPIDriver | QSPID1 |
QSPID1 driver identifier. More... | |
#define QSPI_USE_WAIT TRUE |
Enables synchronous APIs.
Definition at line 90 of file hal_qspi.h.
#define QSPI_USE_MUTUAL_EXCLUSION TRUE |
Enables the qspiAcquireBus()
and qspiReleaseBus()
APIs.
Definition at line 98 of file hal_qspi.h.
#define qspiStartCommandI | ( | qspip, | |
cmdp | |||
) |
Sends a command without data phase.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
Definition at line 154 of file hal_qspi.h.
Referenced by qspiCommand(), and qspiStartCommand().
#define qspiStartSendI | ( | qspip, | |
cmdp, | |||
n, | |||
txbuf | |||
) |
Sends data over the QSPI bus.
This asynchronous function starts a transmit operation.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send or zero if no data phase |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 174 of file hal_qspi.h.
Referenced by qspiSend(), and qspiStartSend().
#define qspiStartReceiveI | ( | qspip, | |
cmdp, | |||
n, | |||
rxbuf | |||
) |
Receives data from the QSPI bus.
This asynchronous function starts a receive operation.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to receive or zero if no data phase |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 194 of file hal_qspi.h.
Referenced by qspiReceive(), and qspiStartReceive().
#define qspiMapFlashI | ( | qspip, | |
cmdp, | |||
addrp | |||
) | qspi_lld_map_flash(qspip, cmdp, addrp) |
Maps in memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[out] | addrp | pointer to the memory start address of the mapped flash or NULL |
Definition at line 215 of file hal_qspi.h.
Referenced by qspiMapFlash().
#define qspiUnmapFlashI | ( | qspip | ) | qspi_lld_unmap_flash(qspip) |
Maps in memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 227 of file hal_qspi.h.
Referenced by qspiUnmapFlash().
#define _qspi_wakeup_isr | ( | qspip | ) |
Wakes up the waiting thread.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 244 of file hal_qspi.h.
#define _qspi_isr_code | ( | qspip | ) |
Common ISR code.
This code handles the portable part of the ISR code:
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 267 of file hal_qspi.h.
#define PLATFORM_QSPI_USE_QSPI1 FALSE |
QSPID1 driver enable switch.
If set to TRUE
the support for QSPID1 is included.
FALSE
. Definition at line 55 of file hal_qspi_lld.h.
typedef struct QSPIDriver QSPIDriver |
Type of a structure representing an QSPI driver.
Definition at line 70 of file hal_qspi_lld.h.
typedef void(* qspicallback_t) (QSPIDriver *qspip) |
Type of a QSPI notification callback.
[in] | qspip | pointer to the QSPIDriver object triggering the callback |
Definition at line 78 of file hal_qspi_lld.h.
enum qspistate_t |
Driver state machine possible states.
Enumerator | |
---|---|
QSPI_UNINIT |
Not initialized. |
QSPI_STOP |
Stopped. |
QSPI_READY |
Ready. |
QSPI_ACTIVE |
Exchanging data. |
QSPI_COMPLETE |
Asynchronous operation complete. |
QSPI_MEMMAP |
In memory mapped mode. |
Definition at line 113 of file hal_qspi.h.
void qspiInit | ( | void | ) |
QSPI Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 56 of file hal_qspi.c.
References qspi_lld_init().
Referenced by halInit().
void qspiObjectInit | ( | QSPIDriver * | qspip | ) |
Initializes the standard part of a QSPIDriver
structure.
[out] | qspip | pointer to the QSPIDriver object |
Definition at line 68 of file hal_qspi.c.
References QSPIDriver::config, QSPIDriver::mutex, osalMutexObjectInit(), QSPI_STOP, QSPIDriver::state, and QSPIDriver::thread.
Referenced by qspi_lld_init().
void qspiStart | ( | QSPIDriver * | qspip, |
const QSPIConfig * | config | ||
) |
Configures and activates the QSPI peripheral.
[in] | qspip | pointer to the QSPIDriver object |
[in] | config | pointer to the QSPIConfig object |
Definition at line 91 of file hal_qspi.c.
References QSPIDriver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), qspi_lld_start(), QSPI_READY, QSPI_STOP, and QSPIDriver::state.
void qspiStop | ( | QSPIDriver * | qspip | ) |
Deactivates the QSPI peripheral.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 116 of file hal_qspi.c.
References QSPIDriver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), qspi_lld_stop(), QSPI_READY, QSPI_STOP, and QSPIDriver::state.
void qspiStartCommand | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp | ||
) |
Sends a command without data phase.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
Definition at line 141 of file hal_qspi.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), QSPI_READY, qspiStartCommandI, and QSPIDriver::state.
void qspiStartSend | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
const uint8_t * | txbuf | ||
) |
Sends a command with data over the QSPI bus.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 165 of file hal_qspi.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), QSPI_READY, qspiStartSendI, and QSPIDriver::state.
void qspiStartReceive | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
uint8_t * | rxbuf | ||
) |
Sends a command then receives data over the QSPI bus.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 191 of file hal_qspi.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), QSPI_READY, qspiStartReceiveI, and QSPIDriver::state.
void qspiCommand | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp | ||
) |
Sends a command without data phase.
QSPI_USE_WAIT
must be enabled. end_cb
= NULL
).[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
Definition at line 219 of file hal_qspi.c.
References QSPIDriver::config, QSPIConfig::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), QSPI_READY, qspiStartCommandI, QSPIDriver::state, and QSPIDriver::thread.
void qspiSend | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
const uint8_t * | txbuf | ||
) |
Sends a command with data over the QSPI bus.
QSPI_USE_WAIT
must be enabled. end_cb
= NULL
).[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 249 of file hal_qspi.c.
References QSPIDriver::config, QSPIConfig::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), QSPI_READY, qspiStartSendI, QSPIDriver::state, and QSPIDriver::thread.
void qspiReceive | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
uint8_t * | rxbuf | ||
) |
Sends a command then receives data over the QSPI bus.
QSPI_USE_WAIT
must be enabled. end_cb
= NULL
).[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 281 of file hal_qspi.c.
References QSPIDriver::config, QSPIConfig::end_cb, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), QSPI_READY, qspiStartReceiveI, QSPIDriver::state, and QSPIDriver::thread.
void qspiMapFlash | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
uint8_t ** | addrp | ||
) |
Maps in memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[out] | addrp | pointer to the memory start address of the mapped flash or NULL |
Definition at line 313 of file hal_qspi.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), QSPI_MEMMAP, QSPI_READY, qspiMapFlashI, and QSPIDriver::state.
void qspiUnmapFlash | ( | QSPIDriver * | qspip | ) |
Unmaps from memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 339 of file hal_qspi.c.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), QSPI_MEMMAP, QSPI_READY, qspiUnmapFlashI, and QSPIDriver::state.
void qspiAcquireBus | ( | QSPIDriver * | qspip | ) |
Gains exclusive access to the QSPI bus.
This function tries to gain ownership to the QSPI bus, if the bus is already being used then the invoking thread is queued.
QSPI_USE_MUTUAL_EXCLUSION
must be enabled.[in] | qspip | pointer to the QSPIDriver object |
Definition at line 366 of file hal_qspi.c.
References QSPIDriver::mutex, osalDbgCheck, and osalMutexLock().
void qspiReleaseBus | ( | QSPIDriver * | qspip | ) |
Releases exclusive access to the QSPI bus.
QSPI_USE_MUTUAL_EXCLUSION
must be enabled.[in] | qspip | pointer to the QSPIDriver object |
Definition at line 382 of file hal_qspi.c.
References QSPIDriver::mutex, osalDbgCheck, and osalMutexUnlock().
void qspi_lld_init | ( | void | ) |
Low level QSPI driver initialization.
Definition at line 63 of file hal_qspi_lld.c.
References qspiObjectInit().
Referenced by qspiInit().
void qspi_lld_start | ( | QSPIDriver * | qspip | ) |
Configures and activates the QSPI peripheral.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 77 of file hal_qspi_lld.c.
References QSPI_STOP, and QSPIDriver::state.
Referenced by qspiStart().
void qspi_lld_stop | ( | QSPIDriver * | qspip | ) |
Deactivates the QSPI peripheral.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 99 of file hal_qspi_lld.c.
References QSPI_READY, and QSPIDriver::state.
Referenced by qspiStop().
void qspi_lld_command | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp | ||
) |
Sends a command without data phase.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
Definition at line 123 of file hal_qspi_lld.c.
void qspi_lld_send | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
const uint8_t * | txbuf | ||
) |
Sends a command with data over the QSPI bus.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 140 of file hal_qspi_lld.c.
void qspi_lld_receive | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
size_t | n, | ||
uint8_t * | rxbuf | ||
) |
Sends a command then receives data over the QSPI bus.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[in] | n | number of bytes to send |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 160 of file hal_qspi_lld.c.
void qspi_lld_map_flash | ( | QSPIDriver * | qspip, |
const qspi_command_t * | cmdp, | ||
uint8_t ** | addrp | ||
) |
Maps in memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
[in] | cmdp | pointer to the command descriptor |
[out] | addrp | pointer to the memory start address of the mapped flash or NULL |
Definition at line 182 of file hal_qspi_lld.c.
void qspi_lld_unmap_flash | ( | QSPIDriver * | qspip | ) |
Unmaps from memory space a QSPI flash device.
[in] | qspip | pointer to the QSPIDriver object |
Definition at line 200 of file hal_qspi_lld.c.
QSPIDriver QSPID1 |
QSPID1 driver identifier.
Definition at line 39 of file hal_qspi_lld.c.