diff --git a/demos/host/host_os_none/.cproject b/demos/host/host_os_none/.cproject index 7a890670..1d510fa1 100644 --- a/demos/host/host_os_none/.cproject +++ b/demos/host/host_os_none/.cproject @@ -1567,8 +1567,8 @@ - - + + @@ -9369,8 +9369,8 @@ <?xml version="1.0" encoding="UTF-8"?> <TargetConfig> -<Properties property_0="" property_3="NXP" property_4="LPC4330" property_count="5" version="1"/> -<infoList vendor="NXP"><info chip="LPC4330" match_id="0x0" name="LPC4330" resetscript="LPC18LPC43ExternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4330</name> +<Properties property_0="" property_2="LPC18x7_43x7_2x512_BootA.cfx" property_3="NXP" property_4="LPC4357" property_count="5" version="1"/> +<infoList vendor="NXP"><info chip="LPC4357" flash_driver="LPC18x7_43x7_2x512_BootA.cfx" match_id="0x0" name="LPC4357" resetscript="LPC18LPC43InternalFLASHBootResetscript.scp" stub="crt_emu_lpc18_43_nxp"><chip><name>LPC4357</name> <family>LPC43xx</family> <vendor>NXP (formerly Philips)</vendor> <reset board="None" core="Real" sys="Real"/> @@ -9378,11 +9378,17 @@ <memory can_program="true" id="Flash" is_ro="true" type="Flash"/> <memory id="RAM" type="RAM"/> <memory id="Periph" is_volatile="true" type="Peripheral"/> -<memoryInstance derived_from="RAM" id="RamLoc128" location="0x10000000" size="0x20000"/> -<memoryInstance derived_from="RAM" id="RamLoc72" location="0x10080000" size="0x12000"/> +<memoryInstance derived_from="Flash" id="MFlashA512" location="0x1a000000" size="0x80000"/> +<memoryInstance derived_from="Flash" id="MFlashB512" location="0x1b000000" size="0x80000"/> +<memoryInstance derived_from="RAM" id="RamLoc32" location="0x10000000" size="0x8000"/> +<memoryInstance derived_from="RAM" id="RamLoc40" location="0x10080000" size="0xa000"/> <memoryInstance derived_from="RAM" id="RamAHB32" location="0x20000000" size="0x8000"/> <memoryInstance derived_from="RAM" id="RamAHB16" location="0x20008000" size="0x4000"/> <memoryInstance derived_from="RAM" id="RamAHB_ETB16" location="0x2000c000" size="0x4000"/> +<prog_flash blocksz="0x2000" location="0x1a000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x10000" location="0x1a010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> +<prog_flash blocksz="0x2000" location="0x1b000000" maxprgbuff="0x400" progwithcode="TRUE" size="0x10000"/> +<prog_flash blocksz="0x10000" location="0x1b010000" maxprgbuff="0x400" progwithcode="TRUE" size="0x70000"/> <peripheralInstance derived_from="V7M_MPU" id="MPU" location="0xe000ed90"/> <peripheralInstance derived_from="V7M_NVIC" id="NVIC" location="0xe000e000"/> <peripheralInstance derived_from="V7M_DCR" id="DCR" location="0xe000edf0"/> @@ -9394,6 +9400,7 @@ <peripheralInstance derived_from="EMC" id="EMC" location="0x40005000"/> <peripheralInstance derived_from="USB0" id="USB0" location="0x40006000"/> <peripheralInstance derived_from="USB1" id="USB1" location="0x40007000"/> +<peripheralInstance derived_from="LCD" id="LCD" location="0x40008000"/> <peripheralInstance derived_from="EEPROM" id="EEPROM" location="0x4000e000"/> <peripheralInstance derived_from="ETHERNET" id="ETHERNET" location="0x40010000"/> <peripheralInstance derived_from="ATIMER" id="ATIMER" location="0x40040000"/> diff --git a/demos/host/src/cdc_serial_app.c b/demos/host/src/cdc_serial_app.c index 6c9e2359..6226d44b 100644 --- a/demos/host/src/cdc_serial_app.c +++ b/demos/host/src/cdc_serial_app.c @@ -61,7 +61,7 @@ static uint8_t received_bytes; // set by transfer complete callback //--------------------------------------------------------------------+ void tusbh_cdc_mounted_cb(uint8_t dev_addr) { // application set-up - printf("\na CDC device is mounted\n"); + printf("\na CDC device (address %d) is mounted\n", dev_addr); memclr_(serial_in_buffer, sizeof(serial_in_buffer)); memclr_(serial_out_buffer, sizeof(serial_out_buffer)); @@ -73,11 +73,13 @@ void tusbh_cdc_mounted_cb(uint8_t dev_addr) void tusbh_cdc_unmounted_cb(uint8_t dev_addr) { // application tear-down - printf("\na CDC device is unmounted\n"); + printf("\na CDC device (address %d) is unmounted \n", dev_addr); } void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) { + (void) dev_addr; // compiler warnings + switch ( pipe_id ) { case CDC_PIPE_DATA_IN: @@ -119,6 +121,8 @@ void cdc_serial_app_init(void) //------------- main task -------------// OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para) { + (void) p_task_para; + OSAL_TASK_LOOP_BEGIN //------------- send characters got from uart terminal to the first CDC device -------------// diff --git a/demos/host/src/cli.c b/demos/host/src/cli.c index 1dd2aadd..da3f2efb 100644 --- a/demos/host/src/cli.c +++ b/demos/host/src/cli.c @@ -206,11 +206,11 @@ void cli_poll(char ch) //------------- Separate Command & Parameter -------------// putchar('\n'); char* p_space = strchr(cli_buffer, ' '); - uint32_t command_len = (p_space == NULL) ? strlen(cli_buffer) : (p_space - cli_buffer); + uint32_t command_len = (p_space == NULL) ? strlen(cli_buffer) : (uint32_t) (p_space - cli_buffer); char* p_para = (p_space == NULL) ? (cli_buffer+command_len) : (p_space+1); // point to NULL-character or after space //------------- Find entered command in lookup table & execute it -------------// - uint32_t cmd_id; + uint8_t cmd_id; for(cmd_id = CLI_CMDTYPE_COUNT - 1; cmd_id > CLI_CMDTYPE_unknown; cmd_id--) { if( 0 == strncmp(cli_buffer, cli_string_tbl[cmd_id], command_len) ) break; @@ -230,8 +230,9 @@ void cli_poll(char ch) //--------------------------------------------------------------------+ // UNKNOWN Command //--------------------------------------------------------------------+ -cli_error_t cli_cmd_unknown(char * para) +cli_error_t cli_cmd_unknown(char * p_para) { + (void) p_para; puts("unknown command, please type \"help\" for list of supported commands"); return CLI_ERROR_NONE; } @@ -239,10 +240,12 @@ cli_error_t cli_cmd_unknown(char * para) //--------------------------------------------------------------------+ // HELP command //--------------------------------------------------------------------+ -cli_error_t cli_cmd_help(char * para) +cli_error_t cli_cmd_help(char * p_para) { + (void) p_para; + puts("current supported commands are:"); - for(uint32_t cmd_id = CLI_CMDTYPE_help+1; cmd_id < CLI_CMDTYPE_COUNT; cmd_id++) + for(uint8_t cmd_id = CLI_CMDTYPE_help+1; cmd_id < CLI_CMDTYPE_COUNT; cmd_id++) { printf("%s\t%s\n", cli_string_tbl[cmd_id], cli_description_tbl[cmd_id]); } @@ -255,6 +258,7 @@ cli_error_t cli_cmd_help(char * para) //--------------------------------------------------------------------+ cli_error_t cli_cmd_clear(char* p_para) { + (void) p_para; printf(ANSI_ERASE_SCREEN(2) ANSI_CURSOR_POSITION(1,1) ); return CLI_ERROR_NONE; } diff --git a/demos/host/src/keyboard_app.c b/demos/host/src/keyboard_app.c index a6631a76..6a770a06 100644 --- a/demos/host/src/keyboard_app.c +++ b/demos/host/src/keyboard_app.c @@ -67,8 +67,7 @@ static inline void process_kbd_report(hid_keyboard_report_t const * report); void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr) { // application set-up - - puts("\na Keyboard device is mounted"); + printf("\na Keyboard device (address %d) is mounted\n", dev_addr); osal_queue_flush(queue_kbd_hdl); tusbh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // first report @@ -77,7 +76,7 @@ void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr) void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr) { // application tear-down - puts("\na Keyboard device is unmounted"); + printf("\na Keyboard device (address %d) is unmounted\n", dev_addr); } void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event) @@ -115,6 +114,8 @@ void keyboard_app_init(void) //------------- main task -------------// OSAL_TASK_FUNCTION( keyboard_app_task ) (void* p_task_para) { + (void) p_task_para; + hid_keyboard_report_t kbd_report; tusb_error_t error; diff --git a/demos/host/src/mouse_app.c b/demos/host/src/mouse_app.c index 6fdba459..0f1323a2 100644 --- a/demos/host/src/mouse_app.c +++ b/demos/host/src/mouse_app.c @@ -66,8 +66,7 @@ static inline void process_mouse_report(hid_mouse_report_t const * p_report); void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr) { // application set-up - - puts("\na Mouse device is mounted"); + printf("\na Mouse device (address %d) is mounted\n", dev_addr); osal_queue_flush(queue_mouse_hdl); (void) tusbh_hid_mouse_get_report(dev_addr, (uint8_t*) &usb_mouse_report); // first report @@ -76,7 +75,7 @@ void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr) void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr) { // application tear-down - puts("\na Mouse device is unmounted\n"); + printf("\na Mouse device (address %d) is unmounted\n", dev_addr); } void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event) @@ -116,6 +115,8 @@ void mouse_app_init(void) //------------- main task -------------// OSAL_TASK_FUNCTION( mouse_app_task ) (void* p_task_para) { + (void) p_task_para; + tusb_error_t error; hid_mouse_report_t mouse_report; diff --git a/demos/host/src/msc_app.c b/demos/host/src/msc_app.c index ddda6d3a..fa1f0696 100644 --- a/demos/host/src/msc_app.c +++ b/demos/host/src/msc_app.c @@ -132,7 +132,9 @@ void tusbh_msc_unmounted_cb(uint8_t dev_addr) void tusbh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes) { - + (void) dev_addr; + (void) event; + (void) xferred_bytes; } //--------------------------------------------------------------------+ @@ -147,6 +149,8 @@ void msc_app_init(void) //------------- main task -------------// OSAL_TASK_FUNCTION( msc_app_task ) (void* p_task_para) { + (void) p_task_para; + OSAL_TASK_LOOP_BEGIN bool is_any_disk_mounted; diff --git a/tinyusb/class/custom_class.h b/tinyusb/class/custom_class.h index 9bc4046f..6fe219e3 100644 --- a/tinyusb/class/custom_class.h +++ b/tinyusb/class/custom_class.h @@ -66,7 +66,8 @@ STATIC_ INLINE_ bool tusbh_custom_is_mounted(uint8_t dev_addr, uint16_t vendor_i { (void) vendor_id; // TODO check this later (void) product_id; - return (tusbh_device_get_mounted_class_flag(dev_addr) & BIT_(TUSB_CLASS_MAPPED_INDEX_END-1) ) != 0; +// return (tusbh_device_get_mounted_class_flag(dev_addr) & BIT_(TUSB_CLASS_MAPPED_INDEX_END-1) ) != 0; + return false; } tusb_error_t tusbh_custom_read(uint8_t dev_addr, uint16_t vendor_id, uint16_t product_id, void * p_buffer, uint16_t length); diff --git a/tinyusb/class/hid_host.c b/tinyusb/class/hid_host.c index 450695b1..28a8a202 100644 --- a/tinyusb/class/hid_host.c +++ b/tinyusb/class/hid_host.c @@ -66,8 +66,8 @@ static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interfa return TUSB_ERROR_NONE; } -static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE; -static inline void hidh_interface_close(uint8_t dev_addr, hidh_interface_info_t *p_hid) +static inline void hidh_interface_close(hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE; +static inline void hidh_interface_close(hidh_interface_info_t *p_hid) { (void) hcd_pipe_close(p_hid->pipe_hdl); memclr_(p_hid, sizeof(hidh_interface_info_t)); @@ -256,6 +256,8 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) { + (void) xferred_bytes; // TODO may need to use this para later + #if TUSB_CFG_HOST_HID_KEYBOARD if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) ) { @@ -282,7 +284,7 @@ void hidh_close(uint8_t dev_addr) #if TUSB_CFG_HOST_HID_KEYBOARD if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) ) { - hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]); + hidh_interface_close(&keyboardh_data[dev_addr-1]); tusbh_hid_keyboard_unmounted_cb(dev_addr); } #endif @@ -290,7 +292,7 @@ void hidh_close(uint8_t dev_addr) #if TUSB_CFG_HOST_HID_MOUSE if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) ) { - hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]); + hidh_interface_close(&mouseh_data[dev_addr-1]); tusbh_hid_mouse_unmounted_cb( dev_addr ); } #endif diff --git a/tinyusb/common/tusb_types.h b/tinyusb/common/tusb_types.h index c950a7b6..72563e57 100644 --- a/tinyusb/common/tusb_types.h +++ b/tinyusb/common/tusb_types.h @@ -135,8 +135,7 @@ typedef enum { TUSB_CLASS_PERSONAL_HEALTHCARE = 15 , ///< 15 TUSB_CLASS_AUDIO_VIDEO = 16 , ///< 16 - TUSB_CLASS_MAPPED_INDEX_START = 17 , // TODO compact & minimize this number - TUSB_CLASS_MAPPED_INDEX_END = TUSB_CLASS_MAPPED_INDEX_START + 5, + TUSB_CLASS_MAPPED_INDEX_START = 17 , // TODO Map DIAGNOSTIC, WIRELESS_CONTROLLER, MISC, VENDOR_SPECIFIC to this to minimize the array TUSB_CLASS_DIAGNOSTIC = 0xDC , TUSB_CLASS_WIRELESS_CONTROLLER = 0xE0 , @@ -153,7 +152,7 @@ typedef enum { MISC_PROTOCOL_IAD = 1 }misc_protocol_type_t; -typedef enum tusb_std_class_flag_{ +typedef enum { TUSB_CLASS_FLAG_AUDIO = BIT_(TUSB_CLASS_AUDIO) , ///< 1 TUSB_CLASS_FLAG_CDC = BIT_(TUSB_CLASS_CDC) , ///< 2 TUSB_CLASS_FLAG_HID = BIT_(TUSB_CLASS_HID) , ///< 3 @@ -219,7 +218,7 @@ enum { static inline uint8_t std_class_code_to_index(uint8_t std_class_code) ATTR_CONST ATTR_ALWAYS_INLINE; static inline uint8_t std_class_code_to_index(uint8_t std_class_code) { - return (std_class_code <= TUSB_CLASS_AUDIO_VIDEO ) ? std_class_code : + return (std_class_code <= TUSB_CLASS_AUDIO_VIDEO ) ? std_class_code : (std_class_code == TUSB_CLASS_DIAGNOSTIC ) ? TUSB_CLASS_MAPPED_INDEX_START : (std_class_code == TUSB_CLASS_WIRELESS_CONTROLLER ) ? TUSB_CLASS_MAPPED_INDEX_START + 1 : (std_class_code == TUSB_CLASS_MISC ) ? TUSB_CLASS_MAPPED_INDEX_START + 2 : diff --git a/tinyusb/host/hub.c b/tinyusb/host/hub.c index 05164701..5e6744c2 100644 --- a/tinyusb/host/hub.c +++ b/tinyusb/host/hub.c @@ -59,7 +59,7 @@ typedef struct { }usbh_hub_t; TUSB_CFG_ATTR_USBRAM usbh_hub_t hub_data[TUSB_CFG_HOST_DEVICE_MAX]; -TUSB_CFG_ATTR_USBRAM uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)]; +ATTR_ALIGNED(4) TUSB_CFG_ATTR_USBRAM STATIC_VAR uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)]; //OSAL_SEM_DEF(hub_enum_semaphore); //static osal_semaphore_handle_t hub_enum_sem_hdl; diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c index be7c3f42..e6db37d4 100644 --- a/tinyusb/host/usbh.c +++ b/tinyusb/host/usbh.c @@ -55,52 +55,56 @@ #define ENUM_QUEUE_DEPTH 5 // TODO fix/compress number of class driver -static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAPPED_INDEX_END] = +static host_class_driver_t const usbh_class_drivers[] = { -#if HOST_CLASS_HID + #if HOST_CLASS_HID [TUSB_CLASS_HID] = { .init = hidh_init, .open_subtask = hidh_open_subtask, .isr = hidh_isr, .close = hidh_close }, -#endif + #endif -#if TUSB_CFG_HOST_CDC + #if TUSB_CFG_HOST_CDC [TUSB_CLASS_CDC] = { .init = cdch_init, .open_subtask = cdch_open_subtask, .isr = cdch_isr, .close = cdch_close }, -#endif + #endif -#if TUSB_CFG_HOST_MSC + #if TUSB_CFG_HOST_MSC [TUSB_CLASS_MSC] = { .init = msch_init, .open_subtask = msch_open_subtask, .isr = msch_isr, .close = msch_close }, -#endif + #endif -#if TUSB_CFG_HOST_HUB + #if TUSB_CFG_HOST_HUB [TUSB_CLASS_HUB] = { .init = hub_init, .open_subtask = hub_open_subtask, .isr = hub_isr, .close = hub_close }, -#endif + #endif -#if TUSB_CFG_HOST_CUSTOM_CLASS + #if TUSB_CFG_HOST_CUSTOM_CLASS [TUSB_CLASS_MAPPED_INDEX_END-1] = { .init = cush_init, .open_subtask = cush_open_subtask, .isr = cush_isr, .close = cush_close } -#endif + #endif +}; + +enum { + USBH_CLASS_DRIVER_COUNT = sizeof(usbh_class_drivers) / sizeof(host_class_driver_t) }; //--------------------------------------------------------------------+ @@ -162,7 +166,7 @@ tusb_error_t usbh_init(void) } //------------- class init -------------// - for (uint8_t class_index = 1; class_index < TUSB_CLASS_MAPPED_INDEX_END; class_index++) + for (uint8_t class_index = 1; class_index < USBH_CLASS_DRIVER_COUNT; class_index++) { if (usbh_class_drivers[class_index].init) { @@ -296,7 +300,7 @@ static void usbh_device_unplugged(uint8_t hostid, uint8_t hub_addr, uint8_t hub_ usbh_devices[dev_addr].state != TUSB_DEVICE_STATE_UNPLUG) { // TODO Hub multiple level - for (uint8_t class_index = 1; class_index < TUSB_CLASS_MAPPED_INDEX_END; class_index++) + for (uint8_t class_index = 1; class_index < USBH_CLASS_DRIVER_COUNT; class_index++) { if ((usbh_devices[dev_addr].flag_supported_class & BIT_(class_index)) && usbh_class_drivers[class_index].close) @@ -412,9 +416,12 @@ tusb_error_t enumeration_body_subtask(void) // Acknowledge Port Connection Change OSAL_SUBTASK_INVOKED_AND_WAIT( hub_port_clear_feature_subtask(usbh_devices[0].hub_addr, usbh_devices[0].hub_port, HUB_FEATURE_PORT_CONNECTION_CHANGE), error ); - if ( ! ((hub_port_status_response_t *) enum_data_buffer)->status_change.connect_status ) SUBTASK_EXIT(TUSB_ERROR_NONE); // only handle connection change + hub_port_status_response_t * p_port_status; + p_port_status = ((hub_port_status_response_t *) enum_data_buffer); - if ( ! ((hub_port_status_response_t *) enum_data_buffer)->status_current.connect_status ) + if ( ! p_port_status->status_change.connect_status ) SUBTASK_EXIT(TUSB_ERROR_NONE); // only handle connection change + + if ( ! p_port_status->status_current.connect_status ) { // Disconnection event usbh_device_unplugged(usbh_devices[0].core_id, usbh_devices[0].hub_addr, usbh_devices[0].hub_port); diff --git a/vendor/fatfs/diskio.c b/vendor/fatfs/diskio.c index ffcbbdfd..83d20f1b 100644 --- a/vendor/fatfs/diskio.c +++ b/vendor/fatfs/diskio.c @@ -126,8 +126,9 @@ DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, BYTE count) /* [I/O] Parameter and data buffer */ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff) { - if (cmd != CTRL_SYNC) return RES_ERROR; + (void) buff; (void) pdrv; // compiler warnings + if (cmd != CTRL_SYNC) return RES_ERROR; return RES_OK; }