Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
ca821x-generic-exchange.h File Reference

The common part of every exchange, handling message management and calling the interface-specific implementations. More...

Include dependency graph for ca821x-generic-exchange.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MAX_BUF_SIZE   256
 

Functions

ca_error init_generic (struct ca821x_dev *pDeviceRef)
 Initialise the generic part of a pDeviceRef. More...
 
ca_error deinit_generic (struct ca821x_dev *pDeviceRef)
 Deinitialise an initialised pDeviceRef struct. More...
 
ca_error exchange_handle_error (ca_error error, struct ca821x_dev *pDeviceRef)
 Attempt to recover from an exchange error silently. More...
 
void * ca821x_io_worker (void *arg)
 io worker thread function. More...
 
ca_error ca821x_exchange_commands (const uint8_t *buf, size_t len, uint8_t *response, struct ca821x_dev *pDeviceRef)
 Handle an exchange with the ca821x. More...
 

Detailed Description

The common part of every exchange, handling message management and calling the interface-specific implementations.

Macro Definition Documentation

◆ MAX_BUF_SIZE

#define MAX_BUF_SIZE   256

Function Documentation

◆ ca821x_exchange_commands()

ca_error ca821x_exchange_commands ( const uint8_t *  buf,
size_t  len,
uint8_t *  response,
struct ca821x_dev pDeviceRef 
)

Handle an exchange with the ca821x.

Used as the downstream function for ca821x-api.

Parameters
bufThe buffer to send
lenThe length of the buffer to send, including header bytes
responseThe buffer to use for the response message to synchronous messages
pDeviceRefan initialised pDeviceRef struct.
Returns
status
Return values
CA_ERROR_SUCCESSSuccess
CA_ERROR_INVALID_STATEInvalid state, such as uninitialised.
CA_ERROR_TIMEOUTResponse was not received to synchronous command in reasonable timeframe.

◆ ca821x_io_worker()

void* ca821x_io_worker ( void *  arg)

io worker thread function.

Handles reads/writes to the exchange, buffering and debuffering messages as required.

Parameters
argan initialised pDeviceRef struct.
Returns
0

◆ deinit_generic()

ca_error deinit_generic ( struct ca821x_dev pDeviceRef)

Deinitialise an initialised pDeviceRef struct.

Parameters
pDeviceRefan initialised pDeviceRef struct.
Returns
CA_ERROR_SUCCESS upon success, error upon failure

◆ exchange_handle_error()

ca_error exchange_handle_error ( ca_error  error,
struct ca821x_dev pDeviceRef 
)

Attempt to recover from an exchange error silently.

Parameters
errorThe error code that caused the crash
pDeviceRefThe initialised pDeviceRef struct related to the error.
Returns
CA_ERROR_SUCCESS

◆ init_generic()

ca_error init_generic ( struct ca821x_dev pDeviceRef)

Initialise the generic part of a pDeviceRef.

Parameters
pDeviceRefAn allocated and partially initialised pDeviceRef struct
Returns
CA_ERROR_SUCCESS upon success, error upon failure