Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
uart-exchange-windows.c File Reference
#include "ca821x-generic-exchange.h"
#include "ca821x-posix-util-internal.h"
#include "uart-exchange.h"
#include <Windows.h>
#include <assert.h>
#include <stdio.h>
#include <time.h>
Include dependency graph for uart-exchange-windows.c:

Classes

struct  uart_exchange_info
 Private data for the UART exchange. More...
 
struct  uart_dev_ll_node
 Structure representing a node in a linked list, used to store the port number of every detected serial device. More...
 

Macros

#define CASCODA_UART_BAUDRATE   115200
 
#define SMALLEST_ALLOWED_PORT_NUMBER   2
 
#define LARGEST_ALLOWED_PORT_NUMBER   255
 

Enumerations

enum  events_array_index { UNBLOCKING_READ_EVENT = 0 , SERIAL_ACTIVITY_EVENT , NUM_EVENTS }
 The two types of events that are watched. More...
 
enum  serial_op_completion_info { OPERATION_PERFORMED_SYNCHRONOUSLY = 0 , OPERATION_PERFORMED_ASYNCHRONOUSLY , OPERATION_FAILED }
 Different ways a serial read or write operation can occur. More...
 

Functions

ca_error uart_exchange_init (ca821x_errorhandler callback, struct ca821x_dev *pDeviceRef, union ca821x_util_init_extra_arg arg)
 
void uart_exchange_deinit (struct ca821x_dev *pDeviceRef)
 Deinitialise the uart exchange, so that it can be reinitialised by another process, or reopened later. More...
 
ca_error uart_exchange_enumerate (util_device_found aCallback, void *aContext)
 Function to enumerate all of the UART devices configured (in the CASCODA_UART environment variable), calling aCallback with a struct describing each one. More...
 
int uart_exchange_reset (unsigned long resettime, struct ca821x_dev *pDeviceRef)
 Send a hard reset to the ca821x. More...
 

Macro Definition Documentation

◆ CASCODA_UART_BAUDRATE

#define CASCODA_UART_BAUDRATE   115200

◆ LARGEST_ALLOWED_PORT_NUMBER

#define LARGEST_ALLOWED_PORT_NUMBER   255

◆ SMALLEST_ALLOWED_PORT_NUMBER

#define SMALLEST_ALLOWED_PORT_NUMBER   2

Enumeration Type Documentation

◆ events_array_index

The two types of events that are watched.

Enumerator
UNBLOCKING_READ_EVENT 
SERIAL_ACTIVITY_EVENT 
NUM_EVENTS 

◆ serial_op_completion_info

Different ways a serial read or write operation can occur.

Enumerator
OPERATION_PERFORMED_SYNCHRONOUSLY 
OPERATION_PERFORMED_ASYNCHRONOUSLY 
OPERATION_FAILED 

Function Documentation

◆ uart_exchange_deinit()

void uart_exchange_deinit ( struct ca821x_dev pDeviceRef)

Deinitialise the uart exchange, so that it can be reinitialised by another process, or reopened later.

Parameters
pDeviceRefPointer to initialised ca821x_device_ref struct

◆ uart_exchange_enumerate()

ca_error uart_exchange_enumerate ( util_device_found  aCallback,
void *  aContext 
)

Function to enumerate all of the UART devices configured (in the CASCODA_UART environment variable), 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.

Parameters
aCallbackThe callback to call with each result
aContextThe generic void pointer to provide to the callback when it is called
Return values
CA_ERROR_SUCCESSEnumeration successful
CA_ERROR_NOT_FOUNDNo devices found

◆ uart_exchange_init()

ca_error uart_exchange_init ( ca821x_errorhandler  callback,
struct ca821x_dev pDeviceRef,
union ca821x_util_init_extra_arg  arg 
)

◆ uart_exchange_reset()

int uart_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.

Parameters
[in]resettimeThe length of time (in ms) to hold the reset pin active for. 1ms is usually a suitable value for this.
[in]pDeviceRefPointer to initialised ca821x_device_ref struct