mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
simple cdc host demo work
This commit is contained in:
parent
13d08cd636
commit
e6e3679136
@ -82,11 +82,14 @@ int main(void)
|
||||
// USB CDC
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_TUH_CDC
|
||||
CFG_TUSB_MEM_SECTION static char serial_in_buffer[64] = { 0 };
|
||||
|
||||
void tuh_cdc_mounted_cb(uint8_t dev_addr)
|
||||
{
|
||||
// application set-up
|
||||
printf("\na CDC device (address %d) is mounted\n", dev_addr);
|
||||
|
||||
tuh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true); // schedule first transfer
|
||||
}
|
||||
|
||||
void tuh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||
@ -98,7 +101,10 @@ void tuh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||
// invoked ISR context
|
||||
void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes)
|
||||
{
|
||||
printf(serial_in_buffer);
|
||||
tu_memclr(serial_in_buffer, sizeof(serial_in_buffer));
|
||||
|
||||
tuh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true); // waiting for next data
|
||||
}
|
||||
|
||||
void virtual_com_task(void)
|
||||
|
@ -82,10 +82,10 @@
|
||||
|
||||
#define CFG_TUH_HUB 1 // not tested
|
||||
#define CFG_TUH_CDC 1
|
||||
#define CFG_TUH_HID_KEYBOARD 1
|
||||
#define CFG_TUH_HID_MOUSE 1
|
||||
#define CFG_TUH_HID_KEYBOARD 0
|
||||
#define CFG_TUH_HID_MOUSE 0
|
||||
#define CFG_TUSB_HOST_HID_GENERIC 0 // (not yet supported)
|
||||
#define CFG_TUH_MSC 1
|
||||
#define CFG_TUH_MSC 0
|
||||
|
||||
#define CFG_TUSB_HOST_DEVICE_MAX (CFG_TUH_HUB ? 5 : 1) // normal hub has 4 ports
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
* \retval true if device supports
|
||||
* \retval false if device does not support or is not mounted
|
||||
*/
|
||||
bool tuh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
bool tuh_cdc_serial_is_mounted(uint8_t dev_addr);
|
||||
|
||||
/** \brief Check if the interface is currently busy or not
|
||||
* \param[in] dev_addr device address
|
||||
@ -73,7 +73,7 @@ bool tuh_cdc_serial_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESU
|
||||
* can be scheduled. User needs to make sure the corresponding interface is mounted
|
||||
* (by \ref tuh_cdc_serial_is_mounted) before calling this function.
|
||||
*/
|
||||
bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid);
|
||||
|
||||
/** \brief Perform USB OUT transfer to device
|
||||
* \param[in] dev_addr device address
|
||||
|
Loading…
x
Reference in New Issue
Block a user