diff options
| author | hathach <[email protected]> | 2013-07-02 17:20:25 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-07-02 17:20:25 +0700 |
| commit | e1ad7b62cf453735b3f8b9d97abe2b3e6579a099 (patch) | |
| tree | f90caee82c921b0b62c8ebaa19352eb28f72d245 /demos/host/src | |
| parent | 6ce90e2bd8d1599df22af8dc670d4187a1ec6dc5 (diff) | |
add way to calculate the actual byte transferred with ehci
add come callback for cdch
add code for cdc serial demo
Diffstat (limited to 'demos/host/src')
| -rw-r--r-- | demos/host/src/cdc_serial_app.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c index 2a20b01d0..46f77a39b 100644 --- a/demos/host/src/cdc_serial_app.c +++ b/demos/host/src/cdc_serial_app.c @@ -58,6 +58,32 @@ static uint8_t buffer_in[64] TUSB_CFG_ATTR_USBRAM; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ +void tusbh_cdc_isr(uint8_t dev_addr, tusb_event_t event) +{ + switch(event) + { + case TUSB_EVENT_INTERFACE_OPEN: // application set-up + osal_queue_flush(queue_hdl); + tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // first report + break; + + case TUSB_EVENT_INTERFACE_CLOSE: // application tear-down + + break; + + case TUSB_EVENT_XFER_COMPLETE: +// osal_queue_send(queue_hdl, &usb_keyboard_report); + tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); + break; + + case TUSB_EVENT_XFER_ERROR: + tusbh_cdc_receive(dev_addr, buffer_in, sizeof(buffer_in), true); // ignore & continue + break; + + default : + break; + } +} //--------------------------------------------------------------------+ // APPLICATION @@ -75,13 +101,14 @@ void cdc_serial_app_init(void) OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para) { tusb_error_t error; - uint8_t c; + uint8_t c = 0; OSAL_TASK_LOOP_BEGIN osal_queue_receive(queue_hdl, &c, OSAL_TIMEOUT_WAIT_FOREVER, &error); - printf("%c", c); + if (c) + printf("%c", c); OSAL_TASK_LOOP_END } |
