Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
cascoda_serial.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019, 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  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
33 #ifndef CASCODA_SERIAL_H
34 #define CASCODA_SERIAL_H
35 
36 #include <stdbool.h>
38 #include "ca821x_api.h"
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 #if !defined(SERIAL_MAC_RX_LEN)
45 #define SERIAL_MAC_RX_LEN (254)
46 #endif
47 
50 {
56 };
57 
58 /******************************************************************************/
59 /****** Global Variables for Serial Message Buffers ******/
60 /******************************************************************************/
61 extern struct SerialBuffer SerialRxBuffer;
62 extern volatile bool SerialRxPending;
63 
66 extern int (*cascoda_serial_dispatch)(u8_t *buf, size_t len, struct ca821x_dev *pDeviceRef);
67 
68 /******************************************************************************/
69 /****** Functions in cascoda_serial_uart.c / cascoda_serial_usb.c ******/
70 /******************************************************************************/
71 
72 /******************************************************************************/
73 /***************************************************************************/
81 
82 /******************************************************************************/
83 /***************************************************************************/
90 
91 /******************************************************************************/
92 /***************************************************************************/
100 void MAC_Message_USB(u8_t CommandId, u8_t Count, const u8_t *pBuffer);
101 
102 /******************************************************************************/
103 /***************************************************************************/
111 void MAC_Message_UART(u8_t CommandId, u8_t Count, const u8_t *pBuffer);
112 
113 /******************************************************************************/
114 /***************************************************************************/
121 void EVBME_Message_USB(char *pBuffer, size_t Count);
122 
123 /******************************************************************************/
124 /***************************************************************************/
131 void EVBME_Message_UART(char *pBuffer, size_t Count);
132 #if defined(USE_UART)
136 void SerialSendRxRdy(void);
137 
141 void SerialSendRxFail(void);
142 
146 void SerialReadComplete(void);
147 
151 void SerialResetTxStalled(void);
152 
153 #endif
154 
155 #ifdef __cplusplus
156 }
157 #endif
158 
159 #endif // CASCODA_SERIAL_H
The main ca821x-api include file.
void MAC_Message_UART(u8_t CommandId, u8_t Count, const u8_t *pBuffer)
Send MCPS or MLME confirm or indication Upstream.
void EVBME_Message_UART(char *pBuffer, size_t Count)
Send EVBME_MESSAGE_Indication Upstream.
struct SerialBuffer SerialRxBuffer
#define SERIAL_MAC_RX_LEN
Maximum serial transfer payload length.
Definition: cascoda_serial.h:45
void MAC_Message_USB(u8_t CommandId, u8_t Count, const u8_t *pBuffer)
Send MCPS or MLME confirm or indication Upstream.
volatile bool SerialRxPending
int(* cascoda_serial_dispatch)(u8_t *buf, size_t len, struct ca821x_dev *pDeviceRef)
Function pointer called when a serial message is received.
Definition: cascoda_evbme.c:77
u8_t SerialGetCommand(void)
Load next command into SerialRxBuffer if possible Note: Not applicable to UART, as read into buffer v...
u8_t Serial_ReadInterface(void)
Read in next Command from Serial hardware.
void EVBME_Message_USB(char *pBuffer, size_t Count)
Send EVBME_MESSAGE_Indication Upstream.
Type definitions used by Cascoda baremetal drivers.
unsigned char u8_t
Definition: cascoda_types.h:46
int
Definition: check_headers.py:126
Structure of serial transfers.
Definition: cascoda_serial.h:50
u8_t CmdLen
Definition: cascoda_serial.h:53
u8_t Data[SERIAL_MAC_RX_LEN]
Data payload.
Definition: cascoda_serial.h:55
u8_t CmdId
Header according to API specification.
Definition: cascoda_serial.h:52
CA-821x Device reference struct.
Definition: ca821x_api.h:123