ArduinoCore-samd/bootloaders/zero/sam_ba_cdc.h
2015-10-10 15:57:00 +02:00

91 lines
2.4 KiB
C

/*
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_