From 4cdebe2e769e52f04ad72992dd9d265372453a18 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 14 Mar 2014 17:18:05 +0700 Subject: [PATCH] fix warning for device os none --- demos/device/device_os_none/.cproject | 12 ++++----- demos/device/src/main.c | 6 ++--- tinyusb/device/dcd.h | 2 +- tinyusb/device/dcd_lpc43xx.h | 2 +- tinyusb/device/usbd.c | 39 ++++++++++++++++----------- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/demos/device/device_os_none/.cproject b/demos/device/device_os_none/.cproject index c6c2ef84..17ecc051 100644 --- a/demos/device/device_os_none/.cproject +++ b/demos/device/device_os_none/.cproject @@ -8,7 +8,7 @@ - + @@ -99,7 +99,7 @@ - + @@ -190,7 +190,7 @@ - + @@ -285,7 +285,7 @@ - + @@ -376,7 +376,7 @@ - + @@ -471,7 +471,7 @@ - + diff --git a/demos/device/src/main.c b/demos/device/src/main.c index 9e9be2a7..c15d92e4 100644 --- a/demos/device/src/main.c +++ b/demos/device/src/main.c @@ -108,8 +108,6 @@ int main(void) #error need to start RTOS schduler #endif - while(1) { } // should not reach here - return 0; } @@ -133,7 +131,9 @@ OSAL_TASK_FUNCTION( led_blinking_task ) (void* p_task_para) board_leds(led_on_mask, 1 - led_on_mask); led_on_mask = 1 - led_on_mask; // toggle - uint32_t btn_mask = board_buttons(); + uint32_t btn_mask; + btn_mask = board_buttons(); + for(uint8_t i=0; i<32; i++) { if ( BIT_TEST_(btn_mask, i) ) printf("button %d is pressed\n", i); diff --git a/tinyusb/device/dcd.h b/tinyusb/device/dcd.h index 3df43e30..6baac8c6 100644 --- a/tinyusb/device/dcd.h +++ b/tinyusb/device/dcd.h @@ -87,7 +87,7 @@ void dcd_pipe_control_stall(uint8_t coreid); endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT; tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes) ATTR_WARN_UNUSED_RESULT; // only queue, not transferring yet tusb_error_t dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes, bool int_on_complete) ATTR_WARN_UNUSED_RESULT; -tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT; +tusb_error_t dcd_pipe_stall(endpoint_handle_t edpt_hdl); bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl) ATTR_WARN_UNUSED_RESULT ; // TODO coreid + endpoint address are part of endpoint handle, not endpoint handle, data toggle also need to be reset diff --git a/tinyusb/device/dcd_lpc43xx.h b/tinyusb/device/dcd_lpc43xx.h index b8f5b178..ba8fcc68 100644 --- a/tinyusb/device/dcd_lpc43xx.h +++ b/tinyusb/device/dcd_lpc43xx.h @@ -57,4 +57,4 @@ #endif /* _TUSB_DCD_LPC43XX_H_ */ -/** @} */ \ No newline at end of file +/** @} */ diff --git a/tinyusb/device/usbd.c b/tinyusb/device/usbd.c index b91cf699..1bd8b7d7 100644 --- a/tinyusb/device/usbd.c +++ b/tinyusb/device/usbd.c @@ -55,9 +55,9 @@ usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER]; // TODO fix/compress number of class driver -static usbd_class_driver_t const usbd_class_drivers[TUSB_CLASS_MAPPED_INDEX_START] = +static usbd_class_driver_t const usbd_class_drivers[] = { -#if DEVICE_CLASS_HID + #if DEVICE_CLASS_HID [TUSB_CLASS_HID] = { .init = hidd_init, @@ -66,9 +66,9 @@ static usbd_class_driver_t const usbd_class_drivers[TUSB_CLASS_MAPPED_INDEX_STAR .xfer_cb = hidd_xfer_cb, .close = hidd_close }, -#endif + #endif -#if TUSB_CFG_DEVICE_MSC + #if TUSB_CFG_DEVICE_MSC [TUSB_CLASS_MSC] = { .init = mscd_init, @@ -77,9 +77,9 @@ static usbd_class_driver_t const usbd_class_drivers[TUSB_CLASS_MAPPED_INDEX_STAR .xfer_cb = mscd_xfer_cb, .close = mscd_close }, -#endif + #endif -#if TUSB_CFG_DEVICE_CDC + #if TUSB_CFG_DEVICE_CDC [TUSB_CLASS_CDC] = { .init = cdcd_init, @@ -88,10 +88,14 @@ static usbd_class_driver_t const usbd_class_drivers[TUSB_CLASS_MAPPED_INDEX_STAR .xfer_cb = cdcd_xfer_cb, .close = cdcd_close }, -#endif + #endif }; +enum { + USBD_CLASS_DRIVER_COUNT = sizeof(usbd_class_drivers) / sizeof(usbd_class_driver_t) +}; + //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ @@ -135,7 +139,7 @@ typedef struct ATTR_ALIGNED(4) uint32_t xferred_byte; }xfer_done; }; -}usbd_task_event_t; +} usbd_task_event_t; STATIC_ASSERT(sizeof(usbd_task_event_t) <= 12, "size is not correct"); @@ -150,7 +154,8 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t { OSAL_SUBTASK_BEGIN - tusb_error_t error = TUSB_ERROR_NONE; + tusb_error_t error; + error = TUSB_ERROR_NONE; //------------- Standard Control such as those in enumeration -------------// if( TUSB_REQUEST_RECIPIENT_DEVICE == p_request->bmRequestType_bit.recipient && @@ -165,7 +170,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t if ( TUSB_ERROR_NONE == error ) { - dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, p_buffer, length, false); + dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, p_buffer, length, false); } } else if ( TUSB_REQUEST_SET_ADDRESS == p_request->bRequest ) @@ -185,11 +190,12 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t //------------- Class/Interface Specific Request -------------// else if ( TUSB_REQUEST_RECIPIENT_INTERFACE == p_request->bmRequestType_bit.recipient) { - OSAL_VAR tusb_std_class_code_t class_code; + OSAL_VAR uint8_t class_code; class_code = usbd_devices[coreid].interface2class[ u16_low_u8(p_request->wIndex) ]; - if ( (TUSB_CLASS_AUDIO <= class_code) && (class_code <= TUSB_CLASS_AUDIO_VIDEO) && + // TODO [Custom] TUSB_CLASS_DIAGNOSTIC, vendor etc ... + if ( (class_code > 0) && (class_code < USBD_CLASS_DRIVER_COUNT) && usbd_class_drivers[class_code].control_request_subtask ) { OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_class_drivers[class_code].control_request_subtask(coreid, p_request), error ); @@ -216,7 +222,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t // ASSERT(error == TUSB_ERROR_NONE, VOID_RETURN); }else if (p_request->wLength == 0) { - dcd_pipe_control_xfer(coreid, p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data + dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data } OSAL_SUBTASK_END @@ -230,7 +236,8 @@ OSAL_TASK_FUNCTION(usbd_task) (void* p_task_para) OSAL_TASK_LOOP_BEGIN OSAL_VAR usbd_task_event_t event; - tusb_error_t error = TUSB_ERROR_NONE; + tusb_error_t error; + error = TUSB_ERROR_NONE; osal_queue_receive(usbd_queue_hdl, &event, OSAL_TIMEOUT_WAIT_FOREVER, &error); SUBTASK_ASSERT_STATUS(error); @@ -245,7 +252,7 @@ OSAL_TASK_FUNCTION(usbd_task) (void* p_task_para) if (usbd_class_drivers[class_index].xfer_cb) { - usbd_class_drivers[class_index].xfer_cb( event.xfer_done.edpt_hdl, event.sub_event_id, event.xfer_done.xferred_byte); + usbd_class_drivers[class_index].xfer_cb( event.xfer_done.edpt_hdl, (tusb_event_t) event.sub_event_id, event.xfer_done.xferred_byte); }else { hal_debugger_breakpoint(); // something wrong, no one claims the isr's source @@ -326,7 +333,7 @@ static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_n static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const * const p_request, uint8_t ** pp_buffer, uint16_t * p_length) { - tusb_std_descriptor_type_t const desc_type = u16_high_u8(p_request->wValue); + tusb_std_descriptor_type_t const desc_type = (tusb_std_descriptor_type_t) u16_high_u8(p_request->wValue); uint8_t const desc_index = u16_low_u8( p_request->wValue ); if ( TUSB_DESC_TYPE_DEVICE == desc_type )