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

Various types used by the cascoda posix api. More...

#include <pthread.h>
#include <stdint.h>
#include <unistd.h>
#include "ca821x-posix/ca821x-posix-config.h"
#include "ca821x-posix/ca821x-posix-evbme.h"
#include "ca821x_api.h"
#include "ca821x_error.h"
Include dependency graph for ca821x-types.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  ca821x_util_init_extra_arg
 Extra argument to the function ca821x_util_init(). More...
 
struct  buffer_queue_item
 Single item in a singly-linked list of data buffers. More...
 
struct  buffer_queue
 Queue struct for singly-linked list of buffer_queue_items. More...
 
struct  ca821x_exchange_base
 Base structure for exchange private data collections. More...
 
struct  ca_device_info
 Struct for getting info of connected devices (primarily for enumerating them) More...
 

Typedefs

typedef ca_error(* ca821x_errorhandler) (ca_error error, struct ca821x_dev *pDeviceRef)
 Error callback. More...
 
typedef ca_error(* exchange_user_callback) (const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
 Optional Exchange User Callback. More...
 
typedef ca_error(* exchange_write) (const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
 Exchange write function. More...
 
typedef ca_error(* exchange_write_isready) (struct ca821x_dev *pDeviceRef)
 Exchange write isready function. More...
 
typedef ssize_t(* exchange_read) (struct ca821x_dev *pDeviceRef, uint8_t *buf)
 Exchange read function. More...
 
typedef void(* exchange_signal_read) (struct ca821x_dev *pDeviceRef)
 Exchange signalling function to trigger read return. More...
 
typedef void(* exchange_flush_unread) (struct ca821x_dev *pDeviceRef)
 Exchange signalling function to flush external buffers. More...
 
typedef void(* util_device_found) (struct ca_device_info *aDeviceInfo, void *aContext)
 Function type for handling enumerated devices when finding them. More...
 

Enumerations

enum  ca821x_exchange_type { ca821x_exchange_kernel = 1 , ca821x_exchange_usb , ca821x_exchange_uart }
 Enumeration for identifying the underlying exchange interface type. More...
 

Detailed Description

Various types used by the cascoda posix api.

Typedef Documentation

◆ ca821x_errorhandler

typedef ca_error(* ca821x_errorhandler) (ca_error error, struct ca821x_dev *pDeviceRef)

Error callback.

Optional callback for the application layer to handle any exchange errors which would otherwise cause a crash.

Returns
Cascoda error code

◆ exchange_flush_unread

typedef void(* exchange_flush_unread) (struct ca821x_dev *pDeviceRef)

Exchange signalling function to flush external buffers.

Function for the exchange to implement. The implementation should clear all external buffers, discarding any messages that were left behind from past executions.

This function will be called when the device is opened.

Parameters
pDeviceRefa Pointer to the relevant pDeviceRef struct

◆ exchange_read

typedef ssize_t(* exchange_read) (struct ca821x_dev *pDeviceRef, uint8_t *buf)

Exchange read function.

Function for the exchange to implement. The implementation should read from the ca821x and copy the data into buf. This function should block as necessary to reduce CPU load (although returning a length of zero is still functionally correct).

If the function does block, it must be able to be woken by a call to the associated exchange_signal_read implementation.

Parameters
bufbuffer containing the message read from the ca821x
pDeviceRefa Pointer to the relevant pDeviceRef struct
Returns
the length of the returned data

◆ exchange_signal_read

typedef void(* exchange_signal_read) (struct ca821x_dev *pDeviceRef)

Exchange signalling function to trigger read return.

Function for the exchange to implement. The implementation should cause the associated exchange_read function to stop blocking and return.

Parameters
pDeviceRefa Pointer to the relevant pDeviceRef struct

◆ exchange_user_callback

typedef ca_error(* exchange_user_callback) (const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)

Optional Exchange User Callback.

Optional callback for the application layer to handle any non-ca821x communication with a device over the same protocol. Any command IDs which are not recognised as a valid ca821x SPI command will be passed to this callback.

Returns
Cascoda error code

◆ exchange_write

typedef ca_error(* exchange_write) (const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)

Exchange write function.

Function for the exchange to implement. The implementation should send the data in 'buf' to the ca821x.

Parameters
bufbuffer containing the message to send to the ca821x
lenlength of the buffer data
pDeviceRefa Pointer to the relevant pDeviceRef struct
Returns
Cascoda error code

◆ exchange_write_isready

typedef ca_error(* exchange_write_isready) (struct ca821x_dev *pDeviceRef)

Exchange write isready function.

Function for the exchange to implement. The implementation should return true (nonzero) if it is ready to send, or 0 if not.

Parameters
pDeviceRefa Pointer to the relevant pDeviceRef struct
Returns
Status
Return values
CA_ERROR_SUCCESSThe exchange is ready to send a packet
CA_ERROR_BUSYThe exhange is not ready to send a packet

◆ util_device_found

typedef void(* util_device_found) (struct ca_device_info *aDeviceInfo, void *aContext)

Function type for handling enumerated devices when finding them.

Parameters
aDeviceInfoThe information about the found device
aContextGeneric context pointer requested when callback was provided

Enumeration Type Documentation

◆ ca821x_exchange_type

Enumeration for identifying the underlying exchange interface type.

Enumerator
ca821x_exchange_kernel 

kernel driver's debugfs node

ca821x_exchange_usb 

USB HID device.

ca821x_exchange_uart 

UART device.