d_usartDMA.h
Go to the documentation of this file.
1 /*
2 MIT LICENSE
3 
4 Copyright 2014-2019 Inertial Sense, Inc. - http://inertialsense.com
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions :
7 
8 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 */
12 
13 #ifndef _D_USARTDMA_H_
14 #define _D_USARTDMA_H_
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #include "../ASF/sam/drivers/usart/usart.h"
21 #include "conf_d_usartDMA.h"
22 
23 typedef struct
24 {
25  uint32_t timeMsLast;
26  uint32_t txByteCount;
27  uint32_t rxByteCount;
28  uint32_t txBytesPerS;
29  uint32_t rxBytesPerS;
30  uint32_t status;
32 
34 
35 
36 //_____ P R O T O T Y P E S ________________________________________________
37 
41 
45 int serWrite( int serialNum, const unsigned char *buf, int size );
46 
51 // Buffer overrun can be detected when serRxUsed decreases outside of a serRead(), because
52 // the Rx PDCA (DMA) wrote past the read pointer.
53 int serRead( int serialNum, unsigned char *buf, int size );
54 
59 int serRxClear( int serialNum, int len );
60 
64 int serRxUsed( int serialNum );
65 
69 int serTxClear( int serialNum );
70 
74 int serTxUsed( int serialNum );
75 
79 int serRxFree( int serialNum );
80 
84 int serTxFree( int serialNum );
85 
89 int serFindCharacter( int serialNum, uint8_t ch);
90 
94 int validateBaudRate(unsigned int baudRate);
95 
99 int serSetBaudRate( int serialNum, int baudrate );
100 
104 int serGetBaudRate( int serialNum );
105 
109 int serInit( int serialNum, uint32_t baudRate, sam_usart_opt_t *options, uint32_t* overrunStatus );
110 
111 #ifdef __cplusplus
112 }
113 #endif
114 
115 #endif // _D_USARTDMA_H_
116 
int serWrite(int serialNum, const unsigned char *buf, int size)
Write data on USART. Returns number of bytes written.
Definition: d_usartDMA.c:443
int serGetBaudRate(int serialNum)
Read USART baudrate. Return value is the baudrate or -1 on failure.
Definition: d_usartDMA.c:1016
#define MAX_NUMBER_SERIAL_PORTS
int serTxFree(int serialNum)
Returns number of bytes available in Tx buffer.
Definition: d_usartDMA.c:313
bool d_usartDMA_callback_cdc_enable(void)
Definition: d_usartDMA.c:160
int serRxClear(int serialNum, int len)
Removes removes data from USART Rx buffer. Returns number of bytes removed. Length of -1 removes all ...
Definition: d_usartDMA.c:398
int validateBaudRate(unsigned int baudRate)
Returns -1 if the baudrate is not a standard baudrate.
Definition: d_usartDMA.c:980
void d_usartDMA_callback_cdc_disable(void)
Definition: d_usartDMA.c:166
int serRead(int serialNum, unsigned char *buf, int size)
Read data on USART. Returns number of bytes read. With use of the PDCA ring buffer, buffer overrun may occur if bytes are received is greater than bytes read plus buffer size.
Definition: d_usartDMA.c:782
int serTxClear(int serialNum)
Clear the entire Tx buffer, returns how much was cleared.
Definition: d_usartDMA.c:344
int serFindCharacter(int serialNum, uint8_t ch)
Returns number of characters in buffer before specified character.
Definition: d_usartDMA.c:884
int serInit(int serialNum, uint32_t baudRate, sam_usart_opt_t *options, uint32_t *overrunStatus)
Initialize serial port with specific USART/UART and DMA settings. If not NULL, the overrun status wil...
Definition: d_usartDMA.c:1560
int serTxUsed(int serialNum)
Returns number of bytes used in Tx buffer.
Definition: d_usartDMA.c:289
int serRxUsed(int serialNum)
Returns number of bytes used in Rx buffer.
Definition: d_usartDMA.c:301
port_monitor_helper_t g_portMonitorHelper[MAX_NUMBER_SERIAL_PORTS]
Definition: d_usartDMA.c:153
int serSetBaudRate(int serialNum, int baudrate)
Change USART baudrate. 0 on success, -1 on failure.
Definition: d_usartDMA.c:995
int serRxFree(int serialNum)
Returns number of bytes available in Rx buffer.
Definition: d_usartDMA.c:332
void d_usartDMA_callback_cdc_tx_empty_notify(void)
Definition: d_usartDMA.c:171


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57