-
-
Notifications
You must be signed in to change notification settings - Fork 725
/
Copy pathsam_ba_cdc.h
91 lines (75 loc) · 2.36 KB
/
sam_ba_cdc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
Copyright (c) 2015 Arduino LLC. All right reserved.
Copyright (c) 2015 Atmel Corporation/Thibaut VIARD. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _SAM_BA_USB_CDC_H_
#define _SAM_BA_USB_CDC_H_
#include <stdint.h>
#include "sam_ba_usb.h"
typedef struct
{
uint32_t dwDTERate;
uint8_t bCharFormat;
uint8_t bParityType;
uint8_t bDataBits;
} usb_cdc_line_coding_t;
/* CDC Class Specific Request Code */
#define GET_LINE_CODING 0x21A1
#define SET_LINE_CODING 0x2021
#define SET_CONTROL_LINE_STATE 0x2221
extern usb_cdc_line_coding_t line_coding;
/**
* \brief Sends a single byte through USB CDC
*
* \param Data to send
* \return number of data sent
*/
int cdc_putc(/*P_USB_CDC pCdc,*/ int value);
/**
* \brief Reads a single byte through USB CDC
*
* \return Data read through USB
*/
int cdc_getc(/*P_USB_CDC pCdc*/);
/**
* \brief Checks if a character has been received on USB CDC
*
* \return \c 1 if a byte is ready to be read.
*/
bool cdc_is_rx_ready(/*P_USB_CDC pCdc*/);
/**
* \brief Sends buffer on USB CDC
*
* \param data pointer
* \param number of data to send
* \return number of data sent
*/
uint32_t cdc_write_buf(/*P_USB_CDC pCdc,*/ void const* data, uint32_t length);
/**
* \brief Gets data on USB CDC
*
* \param data pointer
* \param number of data to read
* \return number of data read
*/
uint32_t cdc_read_buf(/*P_USB_CDC pCdc,*/ void* data, uint32_t length);
/**
* \brief Gets specified number of bytes on USB CDC
*
* \param data pointer
* \param number of data to read
* \return number of data read
*/
uint32_t cdc_read_buf_xmd(/*P_USB_CDC pCdc,*/ void* data, uint32_t length);
#endif // _SAM_BA_USB_CDC_H_