mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-29 01:20:19 +00:00
add tud_n_cdc_get_line_state and tud_n_cdc_get_line_coding
This commit is contained in:
parent
8c79073fa6
commit
1b15449db6
@ -88,10 +88,25 @@ STATIC_VAR cdcd_data_t cdcd_data[CONTROLLER_DEVICE_NUMBER];
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_n_cdc_connected(uint8_t rhport)
|
bool tud_n_cdc_connected(uint8_t rhport)
|
||||||
{
|
{
|
||||||
// Either RTS or DTR active considered as connected
|
// Either RTS (bit 1) or DTR (bit 0) active considered as connected
|
||||||
|
// May only check for DTR only
|
||||||
return (cdcd_data[rhport].line_state != 0);
|
return (cdcd_data[rhport].line_state != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t tud_n_cdc_get_line_state (uint8_t rhport)
|
||||||
|
{
|
||||||
|
return cdcd_data[rhport].line_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tud_n_cdc_get_line_coding (uint8_t rhport, cdc_line_coding_t* coding)
|
||||||
|
{
|
||||||
|
(*coding) = cdcd_line_coding[rhport];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// READ API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
uint32_t tud_n_cdc_available(uint8_t rhport)
|
uint32_t tud_n_cdc_available(uint8_t rhport)
|
||||||
{
|
{
|
||||||
return fifo_count(&_rx_ff);
|
return fifo_count(&_rx_ff);
|
||||||
@ -108,6 +123,10 @@ uint32_t tud_n_cdc_read(uint8_t rhport, void* buffer, uint32_t bufsize)
|
|||||||
return fifo_read_n(&_rx_ff, buffer, bufsize);
|
return fifo_read_n(&_rx_ff, buffer, bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// WRITE API
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
uint32_t tud_n_cdc_write_char(uint8_t rhport, char ch)
|
uint32_t tud_n_cdc_write_char(uint8_t rhport, char ch)
|
||||||
{
|
{
|
||||||
return fifo_write(&_tx_ff, &ch) ? 1 : 0;
|
return fifo_write(&_tx_ff, &ch) ? 1 : 0;
|
||||||
|
@ -56,29 +56,33 @@
|
|||||||
// APPLICATION API (Multiple Root Ports)
|
// APPLICATION API (Multiple Root Ports)
|
||||||
// Should be used only with MCU that support more than 1 ports
|
// Should be used only with MCU that support more than 1 ports
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_n_cdc_connected (uint8_t rhport);
|
bool tud_n_cdc_connected (uint8_t rhport);
|
||||||
uint32_t tud_n_cdc_available (uint8_t rhport);
|
uint8_t tud_n_cdc_get_line_state (uint8_t rhport);
|
||||||
|
void tud_n_cdc_get_line_coding (uint8_t rhport, cdc_line_coding_t* coding);
|
||||||
|
|
||||||
int8_t tud_n_cdc_read_char (uint8_t rhport);
|
uint32_t tud_n_cdc_available (uint8_t rhport);
|
||||||
uint32_t tud_n_cdc_read (uint8_t rhport, void* buffer, uint32_t bufsize);
|
int8_t tud_n_cdc_read_char (uint8_t rhport);
|
||||||
|
uint32_t tud_n_cdc_read (uint8_t rhport, void* buffer, uint32_t bufsize);
|
||||||
|
|
||||||
uint32_t tud_n_cdc_write_char (uint8_t rhport, char ch);
|
uint32_t tud_n_cdc_write_char (uint8_t rhport, char ch);
|
||||||
uint32_t tud_n_cdc_write (uint8_t rhport, void const* buffer, uint32_t bufsize);
|
uint32_t tud_n_cdc_write (uint8_t rhport, void const* buffer, uint32_t bufsize);
|
||||||
bool tud_n_cdc_flush (uint8_t rhport);
|
bool tud_n_cdc_flush (uint8_t rhport);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API (Single Port)
|
// APPLICATION API (Single Port)
|
||||||
// Should be used with MCU supporting only 1 USB port for code simplicity
|
// Should be used with MCU supporting only 1 USB port for code simplicity
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static inline bool tud_cdc_connected (void) { return tud_n_cdc_connected(0); }
|
static inline bool tud_cdc_connected (void) { return tud_n_cdc_connected(0); }
|
||||||
static inline uint32_t tud_cdc_available (void) { return tud_n_cdc_available(0); }
|
static inline uint8_t tud_cdc_get_line_state (uint8_t rhport) { return tud_n_cdc_get_line_state(0); }
|
||||||
|
static inline void tud_cdc_get_line_coding (uint8_t rhport, cdc_line_coding_t* coding) { return tud_cdc_get_line_coding(0, coding); }
|
||||||
|
|
||||||
static inline int8_t tud_cdc_read_char (void) { return tud_n_cdc_read_char(0); }
|
static inline uint32_t tud_cdc_available (void) { return tud_n_cdc_available(0); }
|
||||||
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize) { return tud_n_cdc_read(0, buffer, bufsize); }
|
static inline int8_t tud_cdc_read_char (void) { return tud_n_cdc_read_char(0); }
|
||||||
|
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize) { return tud_n_cdc_read(0, buffer, bufsize); }
|
||||||
|
|
||||||
static inline uint32_t tud_cdc_write_char (char ch) { return tud_n_cdc_write_char(0, ch); }
|
static inline uint32_t tud_cdc_write_char (char ch) { return tud_n_cdc_write_char(0, ch); }
|
||||||
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize) { return tud_n_cdc_write(0, buffer, bufsize); }
|
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize) { return tud_n_cdc_write(0, buffer, bufsize); }
|
||||||
static inline bool tud_cdc_flush (void) { return tud_n_cdc_flush(0); }
|
static inline bool tud_cdc_flush (void) { return tud_n_cdc_flush(0); }
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION CALLBACK API (WEAK is optional)
|
// APPLICATION CALLBACK API (WEAK is optional)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user