Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
Cascoda posix exchange for communicating with ca821x via usb. More...
Go to the source code of this file.
Macros | |
#define | TEST_ENABLE 1 |
Enumerations | |
enum | usb_exchange_errors { usb_exchange_err_usb = 1 , usb_exchange_err_ca821x , usb_exchange_err_generic } |
Functions | |
ca_error | usb_exchange_init (ca821x_errorhandler callback, const char *path, struct ca821x_dev *pDeviceRef, char *serial_num) |
Initialise the usb exchange. More... | |
void | usb_exchange_deinit (struct ca821x_dev *pDeviceRef) |
Deinitialise the usb exchange, so that it can be reinitialised by another process, or reopened later. More... | |
int | usb_exchange_reset (unsigned long resettime, struct ca821x_dev *pDeviceRef) |
Send a hard reset to the ca821x. More... | |
ca_error | usb_exchange_enumerate (util_device_found aCallback, void *aContext) |
Function to enumerate all of the USB connected devices, calling aCallback with a struct describing each one. More... | |
void | test_frag_loopback () |
Run to test fragmentation. More... | |
Cascoda posix exchange for communicating with ca821x via usb.
#define TEST_ENABLE 1 |
enum usb_exchange_errors |
void test_frag_loopback | ( | ) |
Run to test fragmentation.
Crashes upon fail.
void usb_exchange_deinit | ( | struct ca821x_dev * | pDeviceRef | ) |
Deinitialise the usb exchange, so that it can be reinitialised by another process, or reopened later.
pDeviceRef | Pointer to initialised ca821x_device_ref struct |
ca_error usb_exchange_enumerate | ( | util_device_found | aCallback, |
void * | aContext | ||
) |
Function to enumerate all of the USB connected devices, calling aCallback with a struct describing each one.
The struct passed to aCallback will only be valid for the duration that the function is called. This function will not return until every callback has been called.
aCallback | The callback to call with each result |
aContext | The generic void pointer to provide to the callback when it is called |
CA_ERROR_SUCCESS | Enumeration successful |
CA_ERROR_NOT_FOUND | No devices found |
ca_error usb_exchange_init | ( | ca821x_errorhandler | callback, |
const char * | path, | ||
struct ca821x_dev * | pDeviceRef, | ||
char * | serial_num | ||
) |
Initialise the usb exchange.
If callback is specified, then it will be used to report any fatal errors back to the application, which can react as required (i.e. crash gracefully or attempt to reset the ca821x)
If path is specified, then the exchange will attempt to open that device, and fail if it cannot. The path of a device can be obtained with usb_exchange_enumerate.
If serial_num is specified, then the exchange will run an additional check when iterating through all devices, looking for one with matching serial number; Otherwise it will carry out the normal iteration and try to open the first available device.
[in] | callback | Function pointer to an error-handling callback (can be NULL) |
[in] | path | String representing an exchange & system specific path to a device (can be NULL) |
[in] | pDeviceRef | Pointer to initialised ca821x_device_ref struct |
[in] | serial_num | Serial number of the target device (can be NULL) |
CA_ERROR_SUCCESS | success |
CA_ERROR_NOT_FOUND | No available devices found (or device at path not found) |
CA_ERROR_NO_ACCESS | The specified path cannot be opened (e.g. no permissions, already in use) |
CA_ERROR_ALREADY | The pDeviceRef is already initialised |
int usb_exchange_reset | ( | unsigned long | resettime, |
struct ca821x_dev * | pDeviceRef | ||
) |
Send a hard reset to the ca821x.
This should not be necessary, but is provided in case the ca821x becomes unresponsive to spi.
[in] | resettime | The length of time (in ms) to hold the reset pin active for. 1ms is usually a suitable value for this. |
[in] | pDeviceRef | Pointer to initialised ca821x_device_ref struct |