Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
SPI Communication Driver Definitions/Declarations. More...
Macros | |
#define | SPI_T_TIMEOUT 500 |
Timeout for synchronous responses [ms]. More... | |
#define | SPI_T_BACKOFF 10 |
Backoff Time when receiving SPI_NACK [us]. More... | |
#define | SPI_T_HOLD_8210 100 |
Hold time before transmitting for the CA-8210 [us]. More... | |
#define | SPI_T_CSHOLD 50 |
Time to hold the chip select active before re-checking the IRQ [us]. More... | |
#define | SPI_RX_FIFO_SIZE 7 |
Maximum Size of Rx FIFO SPI_Receive_Buffer. More... | |
#define | SPI_RX_FIFO_RESV 4 |
Number of SPI RX FIFOs to be reserved for piggyback messages. More... | |
Functions | |
ca_error | SPI_Exchange (const struct MAC_Message *pTxBuffer, struct ca821x_dev *pDeviceRef) |
Exchange Messages across SPI. More... | |
ca_error | SPI_Send (const uint8_t *buf, u8_t *response, struct ca821x_dev *pDeviceRef) |
Send Request over SPI. More... | |
struct MAC_Message * | SPI_PeekFullBuf (void) |
Get a MAC_Message buffer containing a received SPI Message. More... | |
void | SPI_DequeueFullBuf (void) |
Remove a processed Full Buffer from the SPI Queue. More... | |
bool | SPI_IsFifoFull (void) |
Query whether the SPI message FIFO is full or not. More... | |
bool | SPI_IsFifoAlmostFull (void) |
Query whether the SPI message FIFO is almost full or not. More... | |
bool | SPI_IsFifoEmpty (void) |
Query whether the SPI message FIFO is empty or not. More... | |
bool | SPI_IsExchangeWithCA821xInProgress (void) |
Query whether an SPI exchange operation with the CA821x is currently in progress. More... | |
bool | SPI_IsSyncChainInFlight (void) |
Query whether the SPI driver is currently locked in a Sync chain. More... | |
void | SPI_StartSyncChain (struct ca821x_dev *pDeviceRef) |
Start a 'Sync Chain' For more efficient and safer chains of sync message communication with the CA821x. More... | |
void | SPI_StopSyncChain (struct ca821x_dev *pDeviceRef) |
Stop the sync chain after starting with SPI_StartSyncChain. More... | |
void | SPI_Initialise (void) |
Initialise SPI buffers and call BSP SPI init. More... | |
void | SPI_ExchangeComplete (void) |
Function to be called from the BSP when an exchange operation has been completed. More... | |
bool | SPI_GetExternallyInUseStatus (void) |
Checks if the SPI is being used by something other than the RF chip. More... | |
SPI Communication Driver Definitions/Declarations.
#define SPI_RX_FIFO_RESV 4 |
Number of SPI RX FIFOs to be reserved for piggyback messages.
#define SPI_RX_FIFO_SIZE 7 |
Maximum Size of Rx FIFO SPI_Receive_Buffer.
#define SPI_T_BACKOFF 10 |
Backoff Time when receiving SPI_NACK [us].
#define SPI_T_CSHOLD 50 |
Time to hold the chip select active before re-checking the IRQ [us].
#define SPI_T_HOLD_8210 100 |
Hold time before transmitting for the CA-8210 [us].
#define SPI_T_TIMEOUT 500 |
Timeout for synchronous responses [ms].
void SPI_DequeueFullBuf | ( | void | ) |
Remove a processed Full Buffer from the SPI Queue.
This frees up the buffer for receiving future SPI Messages and also knocks over the queue so that the next message can be processed.
RFIRQ must be enabled when calling.
ca_error SPI_Exchange | ( | const struct MAC_Message * | pTxBuffer, |
struct ca821x_dev * | pDeviceRef | ||
) |
Exchange Messages across SPI.
As the SPI is operating in full duplex mode, every exchange consists of both a transmission and reception. This function transmits pTxBuffer while populating an appropriate Rx buffer with the received message.
RFIRQ must be disabled when calling.
pTxBuffer | - Pointer to Transmit Buffer or NULLP |
pDeviceRef | - Pointer to initialised ca821x_dev struct |
void SPI_ExchangeComplete | ( | void | ) |
Function to be called from the BSP when an exchange operation has been completed.
bool SPI_GetExternallyInUseStatus | ( | void | ) |
Checks if the SPI is being used by something other than the RF chip.
true | if SPI is being used externally, false otherwise. |
void SPI_Initialise | ( | void | ) |
Initialise SPI buffers and call BSP SPI init.
bool SPI_IsExchangeWithCA821xInProgress | ( | void | ) |
Query whether an SPI exchange operation with the CA821x is currently in progress.
This is used in the DISPATCH_ReadCA821x function to determine whether a new read operation should be started. If an exchange is currently in progress, it should not be.
bool SPI_IsFifoAlmostFull | ( | void | ) |
Query whether the SPI message FIFO is almost full or not.
If it is almost full, then messages should not be further read from the slave asynchronously.
This is controlled by the SPI_RX_FIFO_RESV preprocessor macro.
RFIRQ must be disabled when calling.
true | if FIFO is almost full, false if there is space for more async messages |
bool SPI_IsFifoEmpty | ( | void | ) |
Query whether the SPI message FIFO is empty or not.
RFIRQ must be enabled when calling.
true | if FIFO is empty, false if there are any messages stored |
bool SPI_IsFifoFull | ( | void | ) |
Query whether the SPI message FIFO is full or not.
If it is full, then messages should not be further read from the slave.
RFIRQ must be enabled when calling.
true | if FIFO is full, false if there is space for another message |
bool SPI_IsSyncChainInFlight | ( | void | ) |
Query whether the SPI driver is currently locked in a Sync chain.
Not for application usage.
RFIRQ must be disabled when calling.
A Sync chain is a method to restrict the incoming messages from the CA-821x on a constrained platform. If this is in action, then it is important that messages are not received via IRQ. This function is used in cascoda_dispatch.c to prevent sync chain responses from being processed.
true | if sync chain is locked, false if unlocked. |
struct MAC_Message* SPI_PeekFullBuf | ( | void | ) |
Get a MAC_Message buffer containing a received SPI Message.
Calling this function does not remove the buffer from the queue, so after the buffer has been processed, SPI_DequeueFullBuffer should be used.
RFIRQ must be enabled when calling.
A | full SPI Buffer, or NULL if none are available. |
ca_error SPI_Send | ( | const uint8_t * | buf, |
u8_t * | response, | ||
struct ca821x_dev * | pDeviceRef | ||
) |
Send Request over SPI.
This function is used by DISPATCH_ToCA821x as the downstream path to interface with the CA-821x.
RFIRQ must be enabled when calling.
buf | - Message to transmit, length is encoded in cascoda TLV form |
response | - Buffer to fill with response |
pDeviceRef | - Pointer to initialised ca821x_dev struct |
void SPI_StartSyncChain | ( | struct ca821x_dev * | pDeviceRef | ) |
Start a 'Sync Chain' For more efficient and safer chains of sync message communication with the CA821x.
This function should be called before starting to send a group of synchronous messages, and SPI_StopSyncChain must be called afterwards.
Asynchronous requests MUST NOT be made while the sync chain is active. This prevents any asynchronous messages from being received, making timing and buffers more consistent.
RFIRQ must be enabled when calling.
pDeviceRef | Pointer to initialised ca821x_dev struct |
void SPI_StopSyncChain | ( | struct ca821x_dev * | pDeviceRef | ) |
Stop the sync chain after starting with SPI_StartSyncChain.
RFIRQ must be enabled when calling.
pDeviceRef | Pointer to initialised ca821x_dev struct |