mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
clean up
This commit is contained in:
parent
57433135ce
commit
3f3ef6f4e6
@ -48,7 +48,7 @@
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API (Multiple Interfaces)
|
// Application API (Multiple Interfaces)
|
||||||
// CFG_TUD_CDC > 1
|
// CFG_TUD_CDC > 1
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_cdc_n_connected (uint8_t itf);
|
bool tud_cdc_n_connected (uint8_t itf);
|
||||||
@ -68,26 +68,26 @@ uint32_t tud_cdc_n_write_str (uint8_t itf, char const* str);
|
|||||||
bool tud_cdc_n_write_flush (uint8_t itf);
|
bool tud_cdc_n_write_flush (uint8_t itf);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API (Interface0)
|
// Application API (Interface0)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static inline bool tud_cdc_connected (void) { return tud_cdc_n_connected(0); }
|
static inline bool tud_cdc_connected (void);
|
||||||
static inline uint8_t tud_cdc_get_line_state (void) { return tud_cdc_n_get_line_state(0); }
|
static inline uint8_t tud_cdc_get_line_state (void);
|
||||||
static inline void tud_cdc_get_line_coding (cdc_line_coding_t* coding) { return tud_cdc_n_get_line_coding(0, coding);}
|
static inline void tud_cdc_get_line_coding (cdc_line_coding_t* coding);
|
||||||
static inline void tud_cdc_set_wanted_char (char wanted) { tud_cdc_n_set_wanted_char(0, wanted); }
|
static inline void tud_cdc_set_wanted_char (char wanted);
|
||||||
|
|
||||||
static inline uint32_t tud_cdc_available (void) { return tud_cdc_n_available(0); }
|
static inline uint32_t tud_cdc_available (void);
|
||||||
static inline signed char tud_cdc_read_char (void) { return tud_cdc_n_read_char(0); }
|
static inline signed char tud_cdc_read_char (void);
|
||||||
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize) { return tud_cdc_n_read(0, buffer, bufsize); }
|
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize);
|
||||||
static inline void tud_cdc_read_flush (void) { tud_cdc_n_read_flush(0); }
|
static inline void tud_cdc_read_flush (void);
|
||||||
static inline signed char tud_cdc_peek (int pos) { return tud_cdc_n_peek(0, pos); }
|
static inline signed char tud_cdc_peek (int pos);
|
||||||
|
|
||||||
static inline uint32_t tud_cdc_write_char (char ch) { return tud_cdc_n_write_char(0, ch); }
|
static inline uint32_t tud_cdc_write_char (char ch);
|
||||||
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize) { return tud_cdc_n_write(0, buffer, bufsize); }
|
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize);
|
||||||
static inline uint32_t tud_cdc_write_str (char const* str) { return tud_cdc_n_write_str(0, str); }
|
static inline uint32_t tud_cdc_write_str (char const* str);
|
||||||
static inline bool tud_cdc_write_flush (void) { return tud_cdc_n_write_flush(0); }
|
static inline bool tud_cdc_write_flush (void);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION CALLBACK API (WEAK is optional)
|
// Application Callback API (weak is optional)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
// Invoked when received new data
|
// Invoked when received new data
|
||||||
@ -102,6 +102,74 @@ TU_ATTR_WEAK void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts);
|
|||||||
// Invoked when line coding is change via SET_LINE_CODING
|
// Invoked when line coding is change via SET_LINE_CODING
|
||||||
TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
|
TU_ATTR_WEAK void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* p_line_coding);
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Application API (Interface0) Implementation
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
static inline bool tud_cdc_connected (void)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_connected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint8_t tud_cdc_get_line_state (void)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_get_line_state(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tud_cdc_get_line_coding (cdc_line_coding_t* coding)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_get_line_coding(0, coding);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tud_cdc_set_wanted_char (char wanted)
|
||||||
|
{
|
||||||
|
tud_cdc_n_set_wanted_char(0, wanted);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_cdc_available (void)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_available(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline signed char tud_cdc_read_char (void)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_read_char(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_cdc_read (void* buffer, uint32_t bufsize)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_read(0, buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tud_cdc_read_flush (void)
|
||||||
|
{
|
||||||
|
tud_cdc_n_read_flush(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline signed char tud_cdc_peek (int pos)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_peek(0, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_cdc_write_char (char ch)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_write_char(0, ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_cdc_write (void const* buffer, uint32_t bufsize)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_write(0, buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_cdc_write_str (char const* str)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_write_str(0, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool tud_cdc_write_flush (void)
|
||||||
|
{
|
||||||
|
return tud_cdc_n_write_flush(0);
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -87,12 +87,6 @@ uint32_t tud_midi_n_available(uint8_t itf, uint8_t jack_id)
|
|||||||
return tu_fifo_count(&_midid_itf[itf].rx_ff);
|
return tu_fifo_count(&_midid_itf[itf].rx_ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
char tud_midi_n_read_char(uint8_t itf, uint8_t jack_id)
|
|
||||||
{
|
|
||||||
char ch;
|
|
||||||
return tu_fifo_read(&_midid_itf[itf].rx_ff, &ch) ? ch : (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t tud_midi_n_read(uint8_t itf, uint8_t jack_id, void* buffer, uint32_t bufsize)
|
uint32_t tud_midi_n_read(uint8_t itf, uint8_t jack_id, void* buffer, uint32_t bufsize)
|
||||||
{
|
{
|
||||||
return tu_fifo_read_n(&_midid_itf[itf].rx_ff, buffer, bufsize);
|
return tu_fifo_read_n(&_midid_itf[itf].rx_ff, buffer, bufsize);
|
||||||
@ -103,7 +97,6 @@ void tud_midi_n_read_flush (uint8_t itf, uint8_t jack_id)
|
|||||||
tu_fifo_clear(&_midid_itf[itf].rx_ff);
|
tu_fifo_clear(&_midid_itf[itf].rx_ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void midi_rx_done_cb(midid_interface_t* midi, uint8_t const* buffer, uint32_t bufsize) {
|
void midi_rx_done_cb(midid_interface_t* midi, uint8_t const* buffer, uint32_t bufsize) {
|
||||||
if (bufsize % 4 != 0) {
|
if (bufsize % 4 != 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -51,41 +51,64 @@
|
|||||||
* @{ */
|
* @{ */
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API (Multiple Interfaces)
|
// Application API (Multiple Interfaces)
|
||||||
// CFG_TUD_MIDI > 1
|
// CFG_TUD_MIDI > 1
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_midi_n_connected (uint8_t itf);
|
bool tud_midi_n_connected (uint8_t itf);
|
||||||
|
|
||||||
uint32_t tud_midi_n_available (uint8_t itf, uint8_t jack_id);
|
uint32_t tud_midi_n_available (uint8_t itf, uint8_t jack_id);
|
||||||
char tud_midi_n_read_char (uint8_t itf, uint8_t jack_id);
|
|
||||||
uint32_t tud_midi_n_read (uint8_t itf, uint8_t jack_id, void* buffer, uint32_t bufsize);
|
uint32_t tud_midi_n_read (uint8_t itf, uint8_t jack_id, void* buffer, uint32_t bufsize);
|
||||||
void tud_midi_n_read_flush (uint8_t itf, uint8_t jack_id);
|
void tud_midi_n_read_flush (uint8_t itf, uint8_t jack_id);
|
||||||
char tud_midi_n_peek (uint8_t itf, uint8_t jack_id, int pos);
|
|
||||||
|
|
||||||
uint32_t tud_midi_n_write_char (uint8_t itf, char ch);
|
|
||||||
uint32_t tud_midi_n_write (uint8_t itf, uint8_t jack_id, uint8_t const* buffer, uint32_t bufsize);
|
uint32_t tud_midi_n_write (uint8_t itf, uint8_t jack_id, uint8_t const* buffer, uint32_t bufsize);
|
||||||
bool tud_midi_n_write_flush (uint8_t itf);
|
bool tud_midi_n_write_flush (uint8_t itf);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API (Interface0)
|
// Application API (Interface0)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static inline bool tud_midi_connected (void) { return tud_midi_n_connected(0); }
|
static inline bool tud_midi_connected (void);
|
||||||
|
static inline uint32_t tud_midi_available (void);
|
||||||
static inline uint32_t tud_midi_available (void) { return tud_midi_n_available(0, 0); }
|
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize);
|
||||||
static inline char tud_midi_read_char (void) { return tud_midi_n_read_char(0, 0); }
|
static inline void tud_midi_read_flush (void);
|
||||||
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize) { return tud_midi_n_read(0, 0, buffer, bufsize); }
|
static inline uint32_t tud_midi_write (uint8_t jack_id, void const* buffer, uint32_t bufsize);
|
||||||
static inline void tud_midi_read_flush (void) { tud_midi_n_read_flush(0, 0); }
|
static inline bool tud_midi_write_flush (void);
|
||||||
static inline char tud_midi_peek (int pos) { return tud_midi_n_peek(0, 0, pos); }
|
|
||||||
|
|
||||||
static inline uint32_t tud_midi_write_char (char ch) { return tud_midi_n_write_char(0, ch); }
|
|
||||||
static inline uint32_t tud_midi_write (uint8_t jack_id, void const* buffer, uint32_t bufsize) { return tud_midi_n_write(0, jack_id, buffer, bufsize); }
|
|
||||||
static inline bool tud_midi_write_flush (void) { return tud_midi_n_write_flush(0); }
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION CALLBACK API (WEAK is optional)
|
// Application Callback API (weak is optional)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
TU_ATTR_WEAK void tud_midi_rx_cb(uint8_t itf);
|
TU_ATTR_WEAK void tud_midi_rx_cb(uint8_t itf);
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// Application API (Interface0) Implementation
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
static inline bool tud_midi_connected (void)
|
||||||
|
{
|
||||||
|
return tud_midi_n_connected(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_midi_available (void)
|
||||||
|
{
|
||||||
|
return tud_midi_n_available(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_midi_read (void* buffer, uint32_t bufsize)
|
||||||
|
{
|
||||||
|
return tud_midi_n_read(0, 0, buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void tud_midi_read_flush (void)
|
||||||
|
{
|
||||||
|
tud_midi_n_read_flush(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t tud_midi_write (uint8_t jack_id, void const* buffer, uint32_t bufsize)
|
||||||
|
{
|
||||||
|
return tud_midi_n_write(0, jack_id, buffer, bufsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool tud_midi_write_flush (void)
|
||||||
|
{
|
||||||
|
return tud_midi_n_write_flush(0);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Internal Class Driver API
|
// Internal Class Driver API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
Loading…
x
Reference in New Issue
Block a user