mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-23 13:20:54 +00:00
- put ATTR_UNUSED to hardfault handler variables to discard compiler warning
- change host_class_driver_t: open_subtask signature to accept tusb_descriptor_interface_t const * instead of uint8_t*
This commit is contained in:
parent
54acee1fc8
commit
03d045ecde
@ -90,20 +90,20 @@ void HardFault_HandlerAsm(void){
|
||||
* The function ends with a BKPT instruction to force control back into the debugger
|
||||
*/
|
||||
void HardFault_HandlerC(unsigned long *hardfault_args){
|
||||
volatile unsigned long stacked_r0 ;
|
||||
volatile unsigned long stacked_r1 ;
|
||||
volatile unsigned long stacked_r2 ;
|
||||
volatile unsigned long stacked_r3 ;
|
||||
volatile unsigned long stacked_r12 ;
|
||||
volatile unsigned long stacked_lr ;
|
||||
volatile unsigned long stacked_pc ;
|
||||
volatile unsigned long stacked_psr ;
|
||||
volatile unsigned long _CFSR ;
|
||||
volatile unsigned long _HFSR ;
|
||||
volatile unsigned long _DFSR ;
|
||||
volatile unsigned long _AFSR ;
|
||||
volatile unsigned long _BFAR ;
|
||||
volatile unsigned long _MMAR ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_r0 ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_r1 ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_r2 ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_r3 ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_r12 ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_lr ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_pc ;
|
||||
ATTR_UNUSED volatile unsigned long stacked_psr ;
|
||||
ATTR_UNUSED volatile unsigned long _CFSR ;
|
||||
ATTR_UNUSED volatile unsigned long _HFSR ;
|
||||
ATTR_UNUSED volatile unsigned long _DFSR ;
|
||||
ATTR_UNUSED volatile unsigned long _AFSR ;
|
||||
ATTR_UNUSED volatile unsigned long _BFAR ;
|
||||
ATTR_UNUSED volatile unsigned long _MMAR ;
|
||||
|
||||
stacked_r0 = ((unsigned long)hardfault_args[0]) ;
|
||||
stacked_r1 = ((unsigned long)hardfault_args[1]) ;
|
||||
|
@ -56,6 +56,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common/compiler/compiler.h"
|
||||
#include "common/binary.h" // This file is too good to not use
|
||||
|
||||
#define BOARD_AT86RF2XX 1
|
||||
|
@ -72,7 +72,7 @@ void test_hidh_open_ok(void)
|
||||
hcd_pipe_open_IgnoreAndReturn( pipe_hdl );
|
||||
|
||||
//------------- Code Under TEST -------------//
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hidh_open_subtask(dev_addr, (uint8_t*) p_kbd_interface_desc, &length) );
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hidh_open_subtask(dev_addr, p_kbd_interface_desc, &length) );
|
||||
|
||||
TEST_ASSERT_EQUAL(sizeof(tusb_descriptor_interface_t) + sizeof(tusb_hid_descriptor_hid_t) + sizeof(tusb_descriptor_endpoint_t),
|
||||
length);
|
||||
|
@ -118,7 +118,7 @@ void test_keyboard_open_ok(void)
|
||||
hcd_pipe_open_ExpectAndReturn(dev_addr, p_kdb_endpoint_desc, TUSB_CLASS_HID, pipe_hdl);
|
||||
|
||||
//------------- Code Under TEST -------------//
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hidh_open_subtask(dev_addr, (uint8_t*) p_kbd_interface_desc, &length));
|
||||
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, hidh_open_subtask(dev_addr, p_kbd_interface_desc, &length));
|
||||
|
||||
TEST_ASSERT_PIPE_HANDLE(pipe_hdl, p_hidh_kbd->pipe_hdl);
|
||||
TEST_ASSERT_EQUAL(8, p_hidh_kbd->report_size);
|
||||
|
@ -40,7 +40,6 @@
|
||||
#if (MODE_HOST_SUPPORTED && defined HOST_CLASS_HID)
|
||||
|
||||
#define _TINY_USB_SOURCE_FILE_
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INCLUDE
|
||||
//--------------------------------------------------------------------+
|
||||
@ -80,7 +79,6 @@ void hidh_init(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
tusb_error_t hidh_keyboard_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length)
|
||||
{
|
||||
hidh_keyboard_info_t *p_keyboard = get_kbd_data(dev_addr);
|
||||
@ -110,34 +108,33 @@ tusb_error_t hidh_keyboard_open_subtask(uint8_t dev_addr, uint8_t const *descrip
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length)
|
||||
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
|
||||
{
|
||||
tusb_descriptor_interface_t* p_interface = (tusb_descriptor_interface_t*) descriptor;
|
||||
if (p_interface->bInterfaceSubClass == HID_SUBCLASS_BOOT)
|
||||
uint8_t const *p_desc = (uint8_t const *) p_interface_desc;
|
||||
if (p_interface_desc->bInterfaceSubClass == HID_SUBCLASS_BOOT)
|
||||
{
|
||||
switch(p_interface->bInterfaceProtocol)
|
||||
switch(p_interface_desc->bInterfaceProtocol)
|
||||
{
|
||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||
case HID_PROTOCOL_KEYBOARD:
|
||||
|
||||
return hidh_keyboard_open_subtask(dev_addr, descriptor, p_length);
|
||||
return hidh_keyboard_open_subtask(dev_addr, p_desc, p_length);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
case HID_PROTOCOL_MOUSE:
|
||||
return hidh_keyboard_open_subtask(dev_addr, descriptor, p_length);
|
||||
return hidh_keyboard_open_subtask(dev_addr, p_desc, p_length);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default: // unknown protocol --> skip this interface
|
||||
*p_length = p_interface->bLength;
|
||||
*p_length = p_interface_desc->bLength;
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
}else
|
||||
{
|
||||
// open generic
|
||||
*p_length = p_interface->bLength;
|
||||
*p_length = p_interface_desc->bLength;
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ typedef struct {
|
||||
uint16_t report_size;
|
||||
}hidh_keyboard_info_t;
|
||||
|
||||
bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
bool tusbh_hid_keyboard_is_supported(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, uint8_t instance_num, tusb_keyboard_report_t * const report) ATTR_WARN_UNUSED_RESULT;
|
||||
pipe_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
@ -85,7 +85,7 @@ pipe_status_t tusbh_hid_keyboard_status(uint8_t dev_addr, uint8_t instance_num)
|
||||
#ifdef _TINY_USB_SOURCE_FILE_
|
||||
|
||||
void hidh_init(void);
|
||||
tusb_error_t hidh_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT;
|
||||
void hidh_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event);
|
||||
void hidh_close(uint8_t dev_addr);
|
||||
|
||||
|
@ -69,9 +69,9 @@
|
||||
#ifdef _TINY_USB_SOURCE_FILE_
|
||||
|
||||
void msch_init(void) ATTR_WEAK;
|
||||
tusb_error_t msch_open_subtask(uint8_t dev_addr, uint8_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT;
|
||||
void msch_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK;
|
||||
void msch_close(uint8_t dev_addr) ATTR_WEAK;
|
||||
tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *descriptor, uint16_t *p_length) ATTR_WEAK ATTR_WARN_UNUSED_RESULT;
|
||||
void msch_isr(pipe_handle_t pipe_hdl, tusb_bus_event_t event) ATTR_WEAK;
|
||||
void msch_close(uint8_t dev_addr) ATTR_WEAK;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -386,7 +386,7 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
|
||||
// parse each interfaces
|
||||
while( p_desc < enum_data_buffer + ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength )
|
||||
{
|
||||
TASK_ASSERT( TUSB_DESC_INTERFACE == ((tusb_descriptor_interface_t*) p_desc)->bDescriptorType ); // TODO should we skip this descriptor and advance
|
||||
TASK_ASSERT( TUSB_DESC_INTERFACE == p_desc[DESCRIPTOR_OFFSET_TYPE] ); // TODO should we skip this descriptor and advance
|
||||
|
||||
uint8_t class_code = ((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass;
|
||||
if (class_code == 0)
|
||||
@ -398,7 +398,8 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
|
||||
{
|
||||
uint16_t length=0;
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT ( // parameters in task/sub_task must be static storage (static or global)
|
||||
usbh_class_drivers[ ((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass ].open_subtask(new_addr, p_desc, &length) );
|
||||
usbh_class_drivers[ ((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass ].open_subtask(
|
||||
new_addr, (tusb_descriptor_interface_t*) p_desc, &length) );
|
||||
|
||||
// TODO check class_open_subtask status
|
||||
usbh_devices[new_addr].flag_supported_class |= BIT_(((tusb_descriptor_interface_t*) p_desc)->bInterfaceClass);
|
||||
|
@ -72,7 +72,7 @@ typedef enum pipe_status_{
|
||||
|
||||
typedef struct {
|
||||
void (* const init) (void);
|
||||
tusb_error_t (* const open_subtask)(uint8_t, uint8_t const *, uint16_t*);
|
||||
tusb_error_t (* const open_subtask)(uint8_t, tusb_descriptor_interface_t const *, uint16_t*);
|
||||
void (* const isr) (pipe_handle_t, tusb_bus_event_t);
|
||||
void (* const close) (uint8_t);
|
||||
} host_class_driver_t;
|
||||
|
Loading…
x
Reference in New Issue
Block a user