Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/select.h>
#include <sys/time.h>
#include <unistd.h>
#include "ca821x-generic-exchange.h"
#include "ca821x-queue.h"
#include "kernel-exchange.h"
Classes | |
struct | kernel_exchange_priv |
Macros | |
#define | DebugFSMount "/sys/kernel/debug" |
#define | DriverNode "/ca8210" |
#define | DriverFilePath (DebugFSMount DriverNode) |
#define | CA8210_IOCTL_HARD_RESET (0) |
#define | POLL_DELAY 1 |
Max time to wait on rx data in seconds. More... | |
Functions | |
ssize_t | kernel_exchange_try_read (struct ca821x_dev *pDeviceRef, uint8_t *buf) |
void | flush_unread_ke (struct ca821x_dev *pDeviceRef) |
void | unblock_read (struct ca821x_dev *pDeviceRef) |
ca_error | kernel_exchange_init (ca821x_errorhandler callback, struct ca821x_dev *pDeviceRef) |
Initialise the kernel exchange, using the supplied errorhandling callback to report any errors back to the application, which can react as required (i.e. More... | |
void | kernel_exchange_deinit (struct ca821x_dev *pDeviceRef) |
Deinitialise the kernel exchange, so that it can be reinitialised by another process, or reopened later. More... | |
int | kernel_exchange_reset (unsigned long resettime, struct ca821x_dev *pDeviceRef) |
Send a hard reset to the ca8210. More... | |
ca_error | kernel_exchange_enumerate (util_device_found aCallback, void *aContext) |
Function to enumerate all of the kernel devices configured (currently max single device per system), calling aCallback with a struct describing each one. More... | |
#define CA8210_IOCTL_HARD_RESET (0) |
#define DebugFSMount "/sys/kernel/debug" |
#define DriverFilePath (DebugFSMount DriverNode) |
#define DriverNode "/ca8210" |
#define POLL_DELAY 1 |
Max time to wait on rx data in seconds.
void flush_unread_ke | ( | struct ca821x_dev * | pDeviceRef | ) |
void kernel_exchange_deinit | ( | struct ca821x_dev * | pDeviceRef | ) |
Deinitialise the kernel exchange, so that it can be reinitialised by another process, or reopened later.
pDeviceRef | Pointer to initialised ca821x_device_ref struct |
ca_error kernel_exchange_enumerate | ( | util_device_found | aCallback, |
void * | aContext | ||
) |
Function to enumerate all of the kernel devices configured (currently max single device per system), 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 kernel_exchange_init | ( | ca821x_errorhandler | callback, |
struct ca821x_dev * | pDeviceRef | ||
) |
Initialise the kernel exchange, using the supplied errorhandling callback to report any errors back to the application, which can react as required (i.e.
crash gracefully or attempt to reset the ca8210)
[in] | callback | Function pointer to an error-handling callback (can be NULL) |
[in] | pDeviceRef | Pointer to initialised ca821x_device_ref struct |
CA_ERROR_SUCCESS | Successful initialisation |
CA_ERROR_NOT_FOUND | Did not succeed |
int kernel_exchange_reset | ( | unsigned long | resettime, |
struct ca821x_dev * | pDeviceRef | ||
) |
Send a hard reset to the ca8210.
This should not be necessary, but is provided in case the ca8210 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 |
ssize_t kernel_exchange_try_read | ( | struct ca821x_dev * | pDeviceRef, |
uint8_t * | buf | ||
) |
void unblock_read | ( | struct ca821x_dev * | pDeviceRef | ) |