ChibiOS/HAL 9.0.0
|
Generic SPI Driver (legacy). More...
Generic SPI Driver (legacy).
This module implements a generic SPI (Serial Peripheral Interface) driver allowing bidirectional and monodirectional transfers, complex atomic transactions are supported as well.
HAL_USE_SPI
option must be enabled in halconf.h
.The driver implements a state machine internally, not all the driver functionalities can be used in any moment, any transition not explicitly shown in the following diagram has to be considered an error and shall be captured by an assertion (if enabled).
The driver is not thread safe for performance reasons, if you need to access the SPI bus from multiple threads then use the spiAcquireBus()
and spiReleaseBus()
APIs in order to gain exclusive access.
Chip Select modes | |
#define | SPI_SELECT_MODE_NONE |
#define | SPI_SELECT_MODE_PAD 1 /** @brief Legacy mode. */ |
#define | SPI_SELECT_MODE_PORT 2 /** @brief Fastest mode. */ |
#define | SPI_SELECT_MODE_LINE 3 /** @brief Packed mode. */ |
#define | SPI_SELECT_MODE_LLD 4 /** @brief LLD-defined mode.*/ |
SPI configuration options | |
#define | SPI_USE_WAIT TRUE |
Enables synchronous APIs. | |
#define | SPI_USE_MUTUAL_EXCLUSION TRUE |
Enables the spiAcquireBus() and spiReleaseBus() APIs. | |
#define | SPI_SELECT_MODE SPI_SELECT_MODE_PAD |
Handling method for SPI CS line. |
Macro Functions | |
#define | spiIsBufferComplete(spip) |
Buffer state. | |
#define | spiSelectI(spip) |
Asserts the slave select signal and prepares for transfers. | |
#define | spiUnselectI(spip) |
Deasserts the slave select signal. | |
#define | spiStartIgnoreI(spip, n) |
Ignores data on the SPI bus. | |
#define | spiStartExchangeI(spip, n, txbuf, rxbuf) |
Exchanges data on the SPI bus. | |
#define | spiStartSendI(spip, n, txbuf) |
Sends data over the SPI bus. | |
#define | spiStartReceiveI(spip, n, rxbuf) |
Receives data from the SPI bus. | |
#define | spiPolledExchange(spip, frame) |
Exchanges one frame using a polled wait. |
Low level driver helper macros | |
#define | _spi_wakeup_isr(spip) |
Wakes up the waiting thread. | |
#define | _spi_isr_code(spip) |
Common ISR code when circular mode is not supported. | |
#define | _spi_isr_half_code(spip) |
Half buffer filled ISR code in circular mode. | |
#define | _spi_isr_full_code(spip) |
Full buffer filled ISR code in circular mode. |
PLATFORM configuration options | |
#define | PLATFORM_SPI_USE_SPI1 FALSE |
SPI1 driver enable switch. |
Data Structures | |
struct | hal_spi_config |
Driver configuration structure. More... | |
struct | hal_spi_driver |
Structure representing an SPI driver. More... |
Macros | |
#define | SPI_SUPPORTS_CIRCULAR TRUE |
Circular mode support flag. | |
#define | spi_lld_driver_fields |
Low level fields of the SPI driver structure. | |
#define | spi_lld_config_fields |
Low level fields of the SPI configuration structure. |
Typedefs | |
typedef struct hal_spi_driver | SPIDriver |
Type of a structure representing an SPI driver. | |
typedef struct hal_spi_config | SPIConfig |
Type of a SPI driver configuration structure. | |
typedef void(* | spicallback_t) (SPIDriver *spip) |
SPI notification callback type. |
Enumerations | |
enum | spistate_t { SPI_UNINIT = 0 , SPI_STOP = 1 , SPI_READY = 2 , SPI_ACTIVE = 3 , SPI_COMPLETE = 4 } |
Driver state machine possible states. More... |
Functions | |
void | spiInit (void) |
SPI Driver initialization. | |
void | spiObjectInit (SPIDriver *spip) |
Initializes the standard part of a SPIDriver structure. | |
msg_t | spiStart (SPIDriver *spip, const SPIConfig *config) |
Configures and activates the SPI peripheral. | |
void | spiStop (SPIDriver *spip) |
Deactivates the SPI peripheral. | |
void | spiSelect (SPIDriver *spip) |
Asserts the slave select signal and prepares for transfers. | |
void | spiUnselect (SPIDriver *spip) |
Deasserts the slave select signal. | |
void | spiStartIgnore (SPIDriver *spip, size_t n) |
Ignores data on the SPI bus. | |
void | spiStartExchange (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf) |
Exchanges data on the SPI bus. | |
void | spiStartSend (SPIDriver *spip, size_t n, const void *txbuf) |
Sends data over the SPI bus. | |
void | spiStartReceive (SPIDriver *spip, size_t n, void *rxbuf) |
Receives data from the SPI bus. | |
void | spiAbortI (SPIDriver *spip) |
Aborts the ongoing SPI operation. | |
void | spiAbort (SPIDriver *spip) |
Aborts the ongoing SPI operation, if any. | |
void | spiIgnore (SPIDriver *spip, size_t n) |
Ignores data on the SPI bus. | |
void | spiExchange (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf) |
Exchanges data on the SPI bus. | |
void | spiSend (SPIDriver *spip, size_t n, const void *txbuf) |
Sends data over the SPI bus. | |
void | spiReceive (SPIDriver *spip, size_t n, void *rxbuf) |
Receives data from the SPI bus. | |
void | spiAcquireBus (SPIDriver *spip) |
Gains exclusive access to the SPI bus. | |
void | spiReleaseBus (SPIDriver *spip) |
Releases exclusive access to the SPI bus. | |
void | spi_lld_init (void) |
Low level SPI driver initialization. | |
void | spi_lld_start (SPIDriver *spip) |
Configures and activates the SPI peripheral. | |
void | spi_lld_stop (SPIDriver *spip) |
Deactivates the SPI peripheral. | |
void | spi_lld_select (SPIDriver *spip) |
Asserts the slave select signal and prepares for transfers. | |
void | spi_lld_unselect (SPIDriver *spip) |
Deasserts the slave select signal. | |
void | spi_lld_ignore (SPIDriver *spip, size_t n) |
Ignores data on the SPI bus. | |
void | spi_lld_exchange (SPIDriver *spip, size_t n, const void *txbuf, void *rxbuf) |
Exchanges data on the SPI bus. | |
void | spi_lld_send (SPIDriver *spip, size_t n, const void *txbuf) |
Sends data over the SPI bus. | |
void | spi_lld_receive (SPIDriver *spip, size_t n, void *rxbuf) |
Receives data from the SPI bus. | |
void | spi_lld_abort (SPIDriver *spip) |
Aborts the ongoing SPI operation, if any. | |
uint16_t | spi_lld_polled_exchange (SPIDriver *spip, uint16_t frame) |
Exchanges one frame using a polled wait. |
Variables | |
SPIDriver | SPID1 |
SPI1 driver identifier. |
#define SPI_SELECT_MODE_NONE |
Definition at line 38 of file hal_spi_v1.h.
#define SPI_SELECT_MODE_PAD 1 /** @brief Legacy mode. */ |
Definition at line 39 of file hal_spi_v1.h.
#define SPI_SELECT_MODE_PORT 2 /** @brief Fastest mode. */ |
Definition at line 40 of file hal_spi_v1.h.
#define SPI_SELECT_MODE_LINE 3 /** @brief Packed mode. */ |
Definition at line 41 of file hal_spi_v1.h.
#define SPI_SELECT_MODE_LLD 4 /** @brief LLD-defined mode.*/ |
Definition at line 42 of file hal_spi_v1.h.
#define SPI_USE_WAIT TRUE |
Enables synchronous APIs.
Definition at line 58 of file hal_spi_v1.h.
#define SPI_USE_MUTUAL_EXCLUSION TRUE |
Enables the spiAcquireBus()
and spiReleaseBus()
APIs.
Definition at line 66 of file hal_spi_v1.h.
#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD |
Handling method for SPI CS line.
Definition at line 74 of file hal_spi_v1.h.
#define spiIsBufferComplete | ( | spip | ) |
Buffer state.
[in] | spip | pointer to the SPIDriver object |
false | if the driver filled/sent the first half of the buffer. |
true | if the driver filled/sent the second half of the buffer. |
Definition at line 231 of file hal_spi_v1.h.
#define spiSelectI | ( | spip | ) |
Asserts the slave select signal and prepares for transfers.
[in] | spip | pointer to the SPIDriver object |
Definition at line 241 of file hal_spi_v1.h.
Referenced by spiSelect().
#define spiUnselectI | ( | spip | ) |
Deasserts the slave select signal.
The previously selected peripheral is unselected.
[in] | spip | pointer to the SPIDriver object |
Definition at line 254 of file hal_spi_v1.h.
Referenced by spiUnselect().
#define spiStartIgnoreI | ( | spip, | |
n ) |
Ignores data on the SPI bus.
This asynchronous function starts the transmission of a series of idle words on the SPI bus and ignores the received data.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be ignored |
Definition at line 311 of file hal_spi_v1.h.
Referenced by spiIgnore(), and spiStartIgnore().
#define spiStartExchangeI | ( | spip, | |
n, | |||
txbuf, | |||
rxbuf ) |
Exchanges data on the SPI bus.
This asynchronous function starts a simultaneous transmit/receive operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be exchanged |
[in] | txbuf | the pointer to the transmit buffer |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 333 of file hal_spi_v1.h.
Referenced by spiExchange(), and spiStartExchange().
#define spiStartSendI | ( | spip, | |
n, | |||
txbuf ) |
Sends data over the SPI bus.
This asynchronous function starts a transmit operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 353 of file hal_spi_v1.h.
Referenced by spiSend(), and spiStartSend().
#define spiStartReceiveI | ( | spip, | |
n, | |||
rxbuf ) |
Receives data from the SPI bus.
This asynchronous function starts a receive operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to receive |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 373 of file hal_spi_v1.h.
Referenced by spiReceive(), and spiStartReceive().
#define spiPolledExchange | ( | spip, | |
frame ) |
Exchanges one frame using a polled wait.
This synchronous function exchanges one frame using a polled synchronization method. This function is useful when exchanging small amount of data on high speed channels, usually in this situation is much more efficient just wait for completion using polling than suspending the thread waiting for an interrupt.
[in] | spip | pointer to the SPIDriver object |
[in] | frame | the data frame to send over the SPI bus |
Definition at line 391 of file hal_spi_v1.h.
#define _spi_wakeup_isr | ( | spip | ) |
Wakes up the waiting thread.
[in] | spip | pointer to the SPIDriver object |
Definition at line 406 of file hal_spi_v1.h.
#define _spi_isr_code | ( | spip | ) |
Common ISR code when circular mode is not supported.
This code handles the portable part of the ISR code:
[in] | spip | pointer to the SPIDriver object |
Definition at line 429 of file hal_spi_v1.h.
#define _spi_isr_half_code | ( | spip | ) |
Half buffer filled ISR code in circular mode.
This code handles the portable part of the ISR code:
[in] | spip | pointer to the SPIDriver object |
Definition at line 453 of file hal_spi_v1.h.
#define _spi_isr_full_code | ( | spip | ) |
Full buffer filled ISR code in circular mode.
This code handles the portable part of the ISR code:
[in] | spip | pointer to the SPIDriver object |
Definition at line 472 of file hal_spi_v1.h.
#define SPI_SUPPORTS_CIRCULAR TRUE |
Circular mode support flag.
Definition at line 37 of file hal_spi_lld.h.
#define PLATFORM_SPI_USE_SPI1 FALSE |
SPI1 driver enable switch.
If set to TRUE
the support for SPI1 is included.
FALSE
. Definition at line 53 of file hal_spi_lld.h.
#define spi_lld_driver_fields |
Low level fields of the SPI driver structure.
Definition at line 72 of file hal_spi_lld.h.
#define spi_lld_config_fields |
Low level fields of the SPI configuration structure.
Definition at line 79 of file hal_spi_lld.h.
typedef struct hal_spi_driver SPIDriver |
Type of a structure representing an SPI driver.
Definition at line 117 of file hal_spi_v1.h.
typedef struct hal_spi_config SPIConfig |
Type of a SPI driver configuration structure.
Definition at line 121 of file hal_spi_v1.h.
typedef void(* spicallback_t) (SPIDriver *spip) |
SPI notification callback type.
[in] | spip | pointer to the SPIDriver object triggering the callback |
Definition at line 129 of file hal_spi_v1.h.
enum spistate_t |
Driver state machine possible states.
Enumerator | |
---|---|
SPI_UNINIT | Not initialized. |
SPI_STOP | Stopped. |
SPI_READY | Ready. |
SPI_ACTIVE | Exchanging data. |
SPI_COMPLETE | Asynchronous operation complete. |
Definition at line 106 of file hal_spi_v1.h.
void spiInit | ( | void | ) |
SPI Driver initialization.
halInit()
, there is no need to explicitly initialize the driver.Definition at line 54 of file hal_spi_v1.inc.
References spi_lld_init().
Referenced by halInit().
void spiObjectInit | ( | SPIDriver * | spip | ) |
Initializes the standard part of a SPIDriver
structure.
[out] | spip | pointer to the SPIDriver object |
Definition at line 66 of file hal_spi_v1.inc.
References hal_spi_driver::config, hal_spi_driver::mutex, osalMutexObjectInit(), SPI_STOP, hal_spi_driver::state, and hal_spi_driver::thread.
Referenced by spi_lld_init().
Configures and activates the SPI peripheral.
Definition at line 90 of file hal_spi_v1.inc.
References hal_spi_driver::config, HAL_RET_SUCCESS, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), spi_lld_start(), SPI_READY, SPI_STOP, and hal_spi_driver::state.
Referenced by __xsnor_bus_acquire(), mmcConnect(), mmcDisconnect(), mmcStartSequentialRead(), mmcStartSequentialWrite(), mmcSync(), snorStart(), and xsnorStart().
void spiStop | ( | SPIDriver * | spip | ) |
Deactivates the SPI peripheral.
[in] | spip | pointer to the SPIDriver object |
Definition at line 126 of file hal_spi_v1.inc.
References hal_spi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), spi_lld_stop(), SPI_READY, SPI_STOP, and hal_spi_driver::state.
Referenced by bus_stop(), mmcConnect(), mmcDisconnect(), mmcStop(), and xsnorStop().
void spiSelect | ( | SPIDriver * | spip | ) |
Asserts the slave select signal and prepares for transfers.
[in] | spip | pointer to the SPIDriver object |
Definition at line 149 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiSelectI, and hal_spi_driver::state.
Referenced by __xsnor_bus_cmd(), __xsnor_bus_cmd_addr(), __xsnor_bus_cmd_addr_dummy_receive(), __xsnor_bus_cmd_addr_receive(), __xsnor_bus_cmd_addr_send(), __xsnor_bus_cmd_dummy_receive(), __xsnor_bus_cmd_receive(), __xsnor_bus_cmd_send(), bus_cmd(), bus_cmd_addr(), bus_cmd_addr_dummy_receive(), bus_cmd_addr_receive(), bus_cmd_addr_send(), bus_cmd_dummy_receive(), bus_cmd_receive(), bus_cmd_send(), mmc_read_CxD(), mmc_send_command_R1(), mmc_send_command_R3(), mmcDisconnect(), mmcStartSequentialRead(), mmcStartSequentialWrite(), and mmcSync().
void spiUnselect | ( | SPIDriver * | spip | ) |
Deasserts the slave select signal.
The previously selected peripheral is unselected.
[in] | spip | pointer to the SPIDriver object |
Definition at line 167 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiUnselectI, and hal_spi_driver::state.
Referenced by __xsnor_bus_cmd(), __xsnor_bus_cmd_addr(), __xsnor_bus_cmd_addr_dummy_receive(), __xsnor_bus_cmd_addr_receive(), __xsnor_bus_cmd_addr_send(), __xsnor_bus_cmd_dummy_receive(), __xsnor_bus_cmd_receive(), __xsnor_bus_cmd_send(), bus_cmd(), bus_cmd_addr(), bus_cmd_addr_dummy_receive(), bus_cmd_addr_receive(), bus_cmd_addr_send(), bus_cmd_dummy_receive(), bus_cmd_receive(), bus_cmd_send(), mmc_read_CxD(), mmc_send_command_R1(), mmc_send_command_R3(), mmcDisconnect(), mmcSequentialRead(), mmcSequentialWrite(), mmcStartSequentialRead(), mmcStartSequentialWrite(), mmcStopSequentialRead(), mmcStopSequentialWrite(), and mmcSync().
void spiStartIgnore | ( | SPIDriver * | spip, |
size_t | n ) |
Ignores data on the SPI bus.
This asynchronous function starts the transmission of a series of idle words on the SPI bus and ignores the received data.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be ignored |
Definition at line 190 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiStartIgnoreI, and hal_spi_driver::state.
void spiStartExchange | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf, | ||
void * | rxbuf ) |
Exchanges data on the SPI bus.
This asynchronous function starts a simultaneous transmit/receive operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be exchanged |
[in] | txbuf | the pointer to the transmit buffer |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 217 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiStartExchangeI, and hal_spi_driver::state.
void spiStartSend | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf ) |
Sends data over the SPI bus.
This asynchronous function starts a transmit operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 244 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiStartSendI, and hal_spi_driver::state.
void spiStartReceive | ( | SPIDriver * | spip, |
size_t | n, | ||
void * | rxbuf ) |
Receives data from the SPI bus.
This asynchronous function starts a receive operation.
spiSelect()
or spiSelectI()
. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to receive |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 269 of file hal_spi_v1.inc.
References osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), SPI_READY, spiStartReceiveI, and hal_spi_driver::state.
void spiAbortI | ( | SPIDriver * | spip | ) |
Aborts the ongoing SPI operation.
[in] | spip | pointer to the SPIDriver object |
Definition at line 287 of file hal_spi_v1.inc.
References MSG_OK, osalDbgAssert, osalDbgCheck, osalDbgCheckClassI, osalThreadResumeI(), SPI_ACTIVE, SPI_COMPLETE, spi_lld_abort(), SPI_READY, hal_spi_driver::state, and hal_spi_driver::thread.
void spiAbort | ( | SPIDriver * | spip | ) |
Aborts the ongoing SPI operation, if any.
[in] | spip | pointer to the SPIDriver object |
Definition at line 309 of file hal_spi_v1.inc.
References osalDbgAssert, osalOsRescheduleS(), osalSysLock(), osalSysUnlock(), SPI_ACTIVE, SPI_READY, spiAbortI, and hal_spi_driver::state.
void spiIgnore | ( | SPIDriver * | spip, |
size_t | n ) |
Ignores data on the SPI bus.
This synchronous function performs the transmission of a series of idle words on the SPI bus and ignores the received data.
SPI_USE_WAIT
must be enabled.[in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be ignored |
Definition at line 335 of file hal_spi_v1.inc.
References hal_spi_config::circular, hal_spi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), SPI_READY, spiStartIgnoreI, hal_spi_driver::state, and hal_spi_driver::thread.
Referenced by __xsnor_bus_cmd_addr_dummy_receive(), __xsnor_bus_cmd_dummy_receive(), bus_cmd_addr_dummy_receive(), bus_cmd_dummy_receive(), mmc_read_CxD(), mmcConnect(), mmcSequentialRead(), and mmcSequentialWrite().
void spiExchange | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf, | ||
void * | rxbuf ) |
Exchanges data on the SPI bus.
This synchronous function performs a simultaneous transmit/receive operation.
SPI_USE_WAIT
must be enabled. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be exchanged |
[in] | txbuf | the pointer to the transmit buffer |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 365 of file hal_spi_v1.inc.
References hal_spi_config::circular, hal_spi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), SPI_READY, spiStartExchangeI, hal_spi_driver::state, and hal_spi_driver::thread.
void spiSend | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf ) |
Sends data over the SPI bus.
This synchronous function performs a transmit operation.
SPI_USE_WAIT
must be enabled. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 395 of file hal_spi_v1.inc.
References hal_spi_config::circular, hal_spi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), SPI_READY, spiStartSendI, hal_spi_driver::state, and hal_spi_driver::thread.
Referenced by __xsnor_bus_cmd(), __xsnor_bus_cmd_addr_send(), __xsnor_bus_cmd_dummy_receive(), __xsnor_bus_cmd_receive(), __xsnor_bus_cmd_send(), __xsnor_spi_cmd_addr(), bus_cmd(), bus_cmd_addr_send(), bus_cmd_dummy_receive(), bus_cmd_receive(), bus_cmd_send(), mmc_send_hdr(), mmcSequentialWrite(), mmcStopSequentialRead(), mmcStopSequentialWrite(), and snor_spi_cmd_addr().
void spiReceive | ( | SPIDriver * | spip, |
size_t | n, | ||
void * | rxbuf ) |
Receives data from the SPI bus.
This synchronous function performs a receive operation.
SPI_USE_WAIT
must be enabled. [in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to receive |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 423 of file hal_spi_v1.inc.
References hal_spi_config::circular, hal_spi_driver::config, osalDbgAssert, osalDbgCheck, osalSysLock(), osalSysUnlock(), osalThreadSuspendS(), SPI_READY, spiStartReceiveI, hal_spi_driver::state, and hal_spi_driver::thread.
Referenced by __xsnor_bus_cmd_addr_dummy_receive(), __xsnor_bus_cmd_addr_receive(), __xsnor_bus_cmd_dummy_receive(), __xsnor_bus_cmd_receive(), bus_cmd_addr_dummy_receive(), bus_cmd_addr_receive(), bus_cmd_dummy_receive(), bus_cmd_receive(), mmc_read_CxD(), mmc_recvr1(), mmc_recvr3(), mmc_wait_idle(), mmcSequentialRead(), and mmcSequentialWrite().
void spiAcquireBus | ( | SPIDriver * | spip | ) |
Gains exclusive access to the SPI bus.
This function tries to gain ownership to the SPI bus, if the bus is already being used then the invoking thread is queued.
SPI_USE_MUTUAL_EXCLUSION
must be enabled.[in] | spip | pointer to the SPIDriver object |
Definition at line 450 of file hal_spi_v1.inc.
References hal_spi_driver::mutex, osalDbgCheck, and osalMutexLock().
Referenced by __xsnor_bus_acquire(), mmc_connect(), mmc_disconnect(), mmc_read(), mmc_sync(), and mmc_write().
void spiReleaseBus | ( | SPIDriver * | spip | ) |
Releases exclusive access to the SPI bus.
SPI_USE_MUTUAL_EXCLUSION
must be enabled.[in] | spip | pointer to the SPIDriver object |
Definition at line 466 of file hal_spi_v1.inc.
References hal_spi_driver::mutex, osalDbgCheck, and osalMutexUnlock().
Referenced by __xsnor_bus_release(), mmc_connect(), mmc_disconnect(), mmc_read(), mmc_sync(), and mmc_write().
void spi_lld_init | ( | void | ) |
Low level SPI driver initialization.
Definition at line 65 of file hal_spi_lld.c.
References SPID1, and spiObjectInit().
Referenced by spiInit().
void spi_lld_start | ( | SPIDriver * | spip | ) |
Configures and activates the SPI peripheral.
[in] | spip | pointer to the SPIDriver object |
Definition at line 80 of file hal_spi_lld.c.
References osalDbgAssert, SPI_STOP, SPID1, and hal_spi_driver::state.
Referenced by spiStart().
void spi_lld_stop | ( | SPIDriver * | spip | ) |
Deactivates the SPI peripheral.
[in] | spip | pointer to the SPIDriver object |
Definition at line 110 of file hal_spi_lld.c.
References osalDbgAssert, SPI_READY, SPID1, and hal_spi_driver::state.
Referenced by spiStop().
void spi_lld_select | ( | SPIDriver * | spip | ) |
Asserts the slave select signal and prepares for transfers.
[in] | spip | pointer to the SPIDriver object |
Definition at line 138 of file hal_spi_lld.c.
void spi_lld_unselect | ( | SPIDriver * | spip | ) |
Deasserts the slave select signal.
The previously selected peripheral is unselected.
[in] | spip | pointer to the SPIDriver object |
Definition at line 152 of file hal_spi_lld.c.
void spi_lld_ignore | ( | SPIDriver * | spip, |
size_t | n ) |
Ignores data on the SPI bus.
This asynchronous function starts the transmission of a series of idle words on the SPI bus and ignores the received data.
[in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be ignored |
Definition at line 170 of file hal_spi_lld.c.
Referenced by spiStartIgnoreI().
void spi_lld_exchange | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf, | ||
void * | rxbuf ) |
Exchanges data on the SPI bus.
This asynchronous function starts a simultaneous transmit/receive operation.
[in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to be exchanged |
[in] | txbuf | the pointer to the transmit buffer |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 192 of file hal_spi_lld.c.
Referenced by spiStartExchangeI().
void spi_lld_send | ( | SPIDriver * | spip, |
size_t | n, | ||
const void * | txbuf ) |
Sends data over the SPI bus.
This asynchronous function starts a transmit operation.
[in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to send |
[in] | txbuf | the pointer to the transmit buffer |
Definition at line 215 of file hal_spi_lld.c.
Referenced by spiStartSendI().
void spi_lld_receive | ( | SPIDriver * | spip, |
size_t | n, | ||
void * | rxbuf ) |
Receives data from the SPI bus.
This asynchronous function starts a receive operation.
[in] | spip | pointer to the SPIDriver object |
[in] | n | number of words to receive |
[out] | rxbuf | the pointer to the receive buffer |
Definition at line 236 of file hal_spi_lld.c.
Referenced by spiStartReceiveI().
void spi_lld_abort | ( | SPIDriver * | spip | ) |
Aborts the ongoing SPI operation, if any.
[in] | spip | pointer to the SPIDriver object |
Definition at line 252 of file hal_spi_lld.c.
Referenced by spiAbortI().
uint16_t spi_lld_polled_exchange | ( | SPIDriver * | spip, |
uint16_t | frame ) |
Exchanges one frame using a polled wait.
This synchronous function exchanges one frame using a polled synchronization method. This function is useful when exchanging small amount of data on high speed channels, usually in this situation is much more efficient just wait for completion using polling than suspending the thread waiting for an interrupt.
[in] | spip | pointer to the SPIDriver object |
[in] | frame | the data frame to send over the SPI bus |
Definition at line 272 of file hal_spi_lld.c.
SPIDriver SPID1 |
SPI1 driver identifier.
Definition at line 41 of file hal_spi_lld.c.
Referenced by spi_lld_init(), spi_lld_start(), and spi_lld_stop().