Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Loading...
Searching...
No Matches
ca821x-types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020, Cascoda Ltd.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors
16 * may be used to endorse or promote products derived from this software without
17 * specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
36#ifndef CA821X_TYPES_H_
37#define CA821X_TYPES_H_
38
39#include <pthread.h>
40#include <stdint.h>
41#include <unistd.h>
42
43#include "ca821x-posix/ca821x-posix-config.h"
45#include "ca821x_api.h"
46#include "ca821x_error.h"
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
61typedef ca_error (*ca821x_errorhandler)(ca_error error, struct ca821x_dev *pDeviceRef);
62
75typedef ca_error (*exchange_user_callback)(const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef);
76
89typedef ca_error (*exchange_write)(const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef);
90
103typedef ca_error (*exchange_write_isready)(struct ca821x_dev *pDeviceRef);
104
121typedef ssize_t (*exchange_read)(struct ca821x_dev *pDeviceRef, uint8_t *buf);
122
133typedef void (*exchange_signal_read)(struct ca821x_dev *pDeviceRef);
134
147typedef void (*exchange_flush_unread)(struct ca821x_dev *pDeviceRef);
148
157{
158 char *generic;
161 char *force;
162};
163
171
174{
175 size_t len;
176 uint8_t *buf;
179};
180
183{
185 pthread_mutex_t q_mutex;
186 pthread_cond_t q_cond;
187};
188
219
224{
226 const char *path;
227 const char *device_name;
228 const char *app_name;
229 const char *version;
230 const char *serialno;
231
234};
235
241typedef void (*util_device_found)(struct ca_device_info *aDeviceInfo, void *aContext);
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif /* CA821X_TYPES_H_ */
EVBME host API commands.
void(* util_device_found)(struct ca_device_info *aDeviceInfo, void *aContext)
Function type for handling enumerated devices when finding them.
Definition ca821x-types.h:241
void(* exchange_flush_unread)(struct ca821x_dev *pDeviceRef)
Exchange signalling function to flush external buffers.
Definition ca821x-types.h:147
void(* exchange_signal_read)(struct ca821x_dev *pDeviceRef)
Exchange signalling function to trigger read return.
Definition ca821x-types.h:133
ca_error(* exchange_write_isready)(struct ca821x_dev *pDeviceRef)
Exchange write isready function.
Definition ca821x-types.h:103
ca_error(* exchange_write)(const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
Exchange write function.
Definition ca821x-types.h:89
ca821x_exchange_type
Enumeration for identifying the underlying exchange interface type.
Definition ca821x-types.h:166
@ ca821x_exchange_usb
USB HID device.
Definition ca821x-types.h:168
@ ca821x_exchange_uart
UART device.
Definition ca821x-types.h:169
@ ca821x_exchange_kernel
kernel driver's debugfs node
Definition ca821x-types.h:167
ca_error(* exchange_user_callback)(const uint8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
Optional Exchange User Callback.
Definition ca821x-types.h:75
ssize_t(* exchange_read)(struct ca821x_dev *pDeviceRef, uint8_t *buf)
Exchange read function.
Definition ca821x-types.h:121
ca_error(* ca821x_errorhandler)(ca_error error, struct ca821x_dev *pDeviceRef)
Error callback.
Definition ca821x-types.h:61
The main ca821x-api include file.
Global error declarations for use across the Cascoda SDK.
ca_error
Cascoda error type.
Definition ca821x_error.h:51
Definition ca821x-posix-evbme.h:57
Single item in a singly-linked list of data buffers.
Definition ca821x-types.h:174
uint8_t * buf
Buffer pointer.
Definition ca821x-types.h:176
size_t len
Length of buffer.
Definition ca821x-types.h:175
struct ca821x_dev * pDeviceRef
Data's target/originating device.
Definition ca821x-types.h:177
struct buffer_queue_item * next
Next queue item.
Definition ca821x-types.h:178
Queue struct for singly-linked list of buffer_queue_items.
Definition ca821x-types.h:183
pthread_cond_t q_cond
Definition ca821x-types.h:186
pthread_mutex_t q_mutex
Definition ca821x-types.h:185
struct buffer_queue_item * head
Definition ca821x-types.h:184
CA-821x Device reference struct.
Definition ca821x_api.h:123
Base structure for exchange private data collections.
Definition ca821x-types.h:191
exchange_write_isready write_isready_func
Exchange write isready callback.
Definition ca821x-types.h:197
struct buffer_queue in_buffer_queue out_buffer_queue
queues
Definition ca821x-types.h:211
enum ca821x_exchange_type exchange_type
Which exchange is connected to this device.
Definition ca821x-types.h:192
pthread_mutex_t sync_mutex
mutex for synchronous exchanges
Definition ca821x-types.h:207
int flash_fd
File descriptor for persistent storage file.
Definition ca821x-types.h:215
uint32_t base_address
Base address of persistent storage.
Definition ca821x-types.h:216
exchange_user_callback user_callback
User unhandled command callback.
Definition ca821x-types.h:195
exchange_write write_func
Exchange write callback.
Definition ca821x-types.h:196
pthread_cond_t sync_cond
condition variable for synchronous exchanges
Definition ca821x-types.h:206
exchange_read read_func
Exchange read callback.
Definition ca821x-types.h:199
exchange_flush_unread flush_func
Exchange flush callback.
Definition ca821x-types.h:200
pthread_t io_thread
Thread for io handling.
Definition ca821x-types.h:203
exchange_signal_read signal_func
Exchange write signalling callback.
Definition ca821x-types.h:198
pthread_mutex_t flag_mutex
mutex for generic flag handling
Definition ca821x-types.h:205
int io_thread_runflag
flag to shutdown io thread
Definition ca821x-types.h:204
struct EVBME_callbacks evbme_callbacks
EVBME Callback struct.
Definition ca821x-types.h:213
ca821x_errorhandler error_callback
Exchange error callback.
Definition ca821x-types.h:194
uint32_t used_size
Size of used persistent storage.
Definition ca821x-types.h:217
Struct for getting info of connected devices (primarily for enumerating them)
Definition ca821x-types.h:224
bool available
Is the device available for use (or not, eg.
Definition ca821x-types.h:233
const char * serialno
Serial number of the device.
Definition ca821x-types.h:230
bool external_flash_available
Does the device have an external flash chip.
Definition ca821x-types.h:232
const char * version
Version string of the device.
Definition ca821x-types.h:229
enum ca821x_exchange_type exchange_type
Exchange type for this device.
Definition ca821x-types.h:225
const char * app_name
Name of the application running on the device, eg 'ot-cli'.
Definition ca821x-types.h:228
const char * device_name
Name of the device, eg 'Chili2'.
Definition ca821x-types.h:227
const char * path
Exchange & system specific 'path', unique to this device.
Definition ca821x-types.h:226
Extra argument to the function ca821x_util_init().
Definition ca821x-types.h:157
char * serial_num
Serial number.
Definition ca821x-types.h:159
char * com_port_num
COM port.
Definition ca821x-types.h:160
char * force
–force option
Definition ca821x-types.h:161