cdc device app rename CDCD_APP_BUFFER_SIZE to SERIAL_BUFFER_SIZE
cdc host app add SERIAL_BUFFER_SIZE for buffer constant, add cdc data receive if cb with TUSB_EVENT_XFER_ERROR minor change to keyboard & mouse host app add ASSERT_FAILED & ASSERT_FAILED_MSG add cast to fix IAR build error with dcd_lpc43xx.c FreeRTOS - merge FreeRTOSConfig for m0, m3, m4 - re-implement application hook - support portmacro.h for m0
This commit is contained in:
@@ -51,8 +51,9 @@ OSAL_SEM_DEF(serial_semaphore);
|
||||
|
||||
static osal_semaphore_handle_t sem_hdl;
|
||||
|
||||
TUSB_CFG_ATTR_USBRAM static uint8_t serial_in_buffer[32];
|
||||
TUSB_CFG_ATTR_USBRAM static uint8_t serial_out_buffer[32];
|
||||
enum { SERIAL_BUFFER_SIZE = 64 };
|
||||
TUSB_CFG_ATTR_USBRAM static uint8_t serial_in_buffer[SERIAL_BUFFER_SIZE];
|
||||
TUSB_CFG_ATTR_USBRAM static uint8_t serial_out_buffer[SERIAL_BUFFER_SIZE];
|
||||
|
||||
static uint8_t received_bytes; // set by transfer complete callback
|
||||
|
||||
@@ -68,7 +69,7 @@ void tusbh_cdc_mounted_cb(uint8_t dev_addr)
|
||||
received_bytes = 0;
|
||||
|
||||
osal_semaphore_reset(sem_hdl);
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true); // schedule first transfer
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, SERIAL_BUFFER_SIZE, true); // schedule first transfer
|
||||
}
|
||||
|
||||
void tusbh_cdc_unmounted_cb(uint8_t dev_addr)
|
||||
@@ -93,6 +94,7 @@ void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_
|
||||
|
||||
case TUSB_EVENT_XFER_ERROR:
|
||||
received_bytes = 0; // ignore
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, SERIAL_BUFFER_SIZE, true); // waiting for next data
|
||||
break;
|
||||
|
||||
case TUSB_EVENT_XFER_STALLED:
|
||||
@@ -133,12 +135,12 @@ OSAL_TASK_FUNCTION( cdc_serial_host_app_task, p_task_para)
|
||||
{
|
||||
int ch_tx = getchar();
|
||||
if ( ch_tx > 0 )
|
||||
{ // USB is much faster than serial, here we assume usb is always complete. There could be some characters missing
|
||||
{ // USB is much faster than serial, here we assume usb is always complete. There could be some characters missing though
|
||||
serial_out_buffer[0] = (uint8_t) ch_tx;
|
||||
|
||||
if ( !tusbh_cdc_is_busy(dev_addr, CDC_PIPE_DATA_OUT) )
|
||||
{
|
||||
tusbh_cdc_send(dev_addr, serial_out_buffer, 1, false); // no need for interrupt on serial out pipe
|
||||
tusbh_cdc_send(dev_addr, serial_out_buffer, 1, false); // no need for callback on serial out pipe
|
||||
}
|
||||
}
|
||||
break; // demo app only communicate with the first CDC-capable device
|
||||
@@ -157,7 +159,7 @@ OSAL_TASK_FUNCTION( cdc_serial_host_app_task, p_task_para)
|
||||
{
|
||||
if ( tusbh_cdc_serial_is_mounted(dev_addr) )
|
||||
{
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, sizeof(serial_in_buffer), true);
|
||||
tusbh_cdc_receive(dev_addr, serial_in_buffer, SERIAL_BUFFER_SIZE, true);
|
||||
|
||||
break; // demo app only communicate with the first CDC-capable device
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ OSAL_TASK_FUNCTION( keyboard_host_app_task, p_task_para)
|
||||
{
|
||||
(void) p_task_para;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
hid_keyboard_report_t kbd_report;
|
||||
tusb_error_t error;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
osal_queue_receive(queue_kbd_hdl, &kbd_report, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
(void) error; // suppress compiler warning
|
||||
|
||||
|
||||
@@ -118,13 +118,13 @@ OSAL_TASK_FUNCTION( mouse_host_app_task, p_task_para)
|
||||
{
|
||||
(void) p_task_para;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
tusb_error_t error;
|
||||
hid_mouse_report_t mouse_report;
|
||||
|
||||
OSAL_TASK_LOOP_BEGIN
|
||||
|
||||
osal_queue_receive(queue_mouse_hdl, &mouse_report, OSAL_TIMEOUT_WAIT_FOREVER, &error);
|
||||
(void) error; // supporess compiler's warninig
|
||||
(void) error; // suppress compiler's warnings
|
||||
|
||||
process_mouse_report(&mouse_report);
|
||||
|
||||
@@ -138,29 +138,29 @@ void cursor_movement(int8_t x, int8_t y, int8_t wheel)
|
||||
{
|
||||
//------------- X -------------//
|
||||
if ( x < 0)
|
||||
{ // move left
|
||||
printf(ANSI_CURSOR_BACKWARD(%d), (-x));
|
||||
{
|
||||
printf(ANSI_CURSOR_BACKWARD(%d), (-x)); // move left
|
||||
}else if ( x > 0)
|
||||
{ // move right
|
||||
printf(ANSI_CURSOR_FORWARD(%d), x);
|
||||
{
|
||||
printf(ANSI_CURSOR_FORWARD(%d), x); // move right
|
||||
}else { }
|
||||
|
||||
//------------- Y -------------//
|
||||
if ( y < 0)
|
||||
{ // move up
|
||||
printf(ANSI_CURSOR_UP(%d), (-y));
|
||||
{
|
||||
printf(ANSI_CURSOR_UP(%d), (-y)); // move up
|
||||
}else if ( y > 0)
|
||||
{ // move down
|
||||
printf(ANSI_CURSOR_DOWN(%d), y);
|
||||
{
|
||||
printf(ANSI_CURSOR_DOWN(%d), y); // move down
|
||||
}else { }
|
||||
|
||||
//------------- wheel -------------//
|
||||
if (wheel < 0)
|
||||
{ // scroll up
|
||||
printf(ANSI_SCROLL_UP(%d), (-wheel));
|
||||
{
|
||||
printf(ANSI_SCROLL_UP(%d), (-wheel)); // scroll up
|
||||
}else if (wheel > 0)
|
||||
{ // scroll down
|
||||
printf(ANSI_SCROLL_DOWN(%d), wheel);
|
||||
{
|
||||
printf(ANSI_SCROLL_DOWN(%d), wheel); // scroll down
|
||||
}else { }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user