diff options
| author | Ha Thach <[email protected]> | 2020-11-23 23:25:55 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-23 23:25:55 +0700 |
| commit | 308028e17cb4ba5e93413431a51bbe94d2afcc53 (patch) | |
| tree | 79ac511381d953b0ef35e70924da375b4bb0320b /examples/device | |
| parent | 339b1a772350321d0f9d4f84e93c5360247e3f17 (diff) | |
| parent | b870d932e5e1c6ece4227a5d49cc71e53a744149 (diff) | |
Merge branch 'master' into cdc_without_dtr
Diffstat (limited to 'examples/device')
| -rw-r--r-- | examples/device/cdc_msc/ses/samd21/samd21.emProject | 12 | ||||
| -rw-r--r-- | examples/device/cdc_msc/ses/samd51/samd51.emProject | 14 | ||||
| -rw-r--r-- | examples/device/cdc_msc/src/msc_disk.c | 12 | ||||
| -rw-r--r-- | examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject | 12 | ||||
| -rw-r--r-- | examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject | 14 | ||||
| -rw-r--r-- | examples/device/webusb_serial/src/main.c | 19 |
6 files changed, 44 insertions, 39 deletions
diff --git a/examples/device/cdc_msc/ses/samd21/samd21.emProject b/examples/device/cdc_msc/ses/samd21/samd21.emProject index 1536af9ab..6740241a9 100644 --- a/examples/device/cdc_msc/ses/samd21/samd21.emProject +++ b/examples/device/cdc_msc/ses/samd21/samd21.emProject @@ -28,7 +28,7 @@ linker_memory_map_file="$(ProjectDir)/ATSAMD21G18A_MemoryMap.xml" linker_section_placement_file="flash_placement.xml" linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000" - macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd21" + macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/asf4/samd21" project_directory="" project_type="Executable" target_reset_script="Reset();" @@ -54,22 +54,22 @@ <folder Name="asf4"> <folder Name="samd21"> <folder Name="gcc"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/gcc/system_samd21.c" /> </folder> <folder Name="hpl"> <folder Name="gclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/gclk/hpl_gclk.c" /> </folder> <folder Name="pm"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/pm/hpl_pm.c" /> </folder> <folder Name="sysctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" /> </folder> </folder> <folder Name="hal"> <folder Name="src"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hal/src/hal_atomic.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hal/src/hal_atomic.c" /> </folder> </folder> </folder> diff --git a/examples/device/cdc_msc/ses/samd51/samd51.emProject b/examples/device/cdc_msc/ses/samd51/samd51.emProject index ecb1e031b..d4049e834 100644 --- a/examples/device/cdc_msc/ses/samd51/samd51.emProject +++ b/examples/device/cdc_msc/ses/samd51/samd51.emProject @@ -29,7 +29,7 @@ linker_memory_map_file="ATSAMD51J19A_MemoryMap.xml" linker_section_placement_file="flash_placement.xml" linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000" - macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd51" + macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/asf4/samd51" project_directory="" project_type="Executable" target_reset_script="Reset();" @@ -55,25 +55,25 @@ <folder Name="asf4"> <folder Name="samd51"> <folder Name="gcc"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/gcc/system_samd51.c" /> </folder> <folder Name="hpl"> <folder Name="osc32kctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" /> </folder> <folder Name="oscctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" /> </folder> <folder Name="mclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/mclk/hpl_mclk.c" /> </folder> <folder Name="gclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/gclk/hpl_gclk.c" /> </folder> </folder> <folder Name="hal"> <folder Name="src"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hal/src/hal_atomic.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hal/src/hal_atomic.c" /> </folder> </folder> </folder> diff --git a/examples/device/cdc_msc/src/msc_disk.c b/examples/device/cdc_msc/src/msc_disk.c index 5aa7befc9..503baace9 100644 --- a/examples/device/cdc_msc/src/msc_disk.c +++ b/examples/device/cdc_msc/src/msc_disk.c @@ -28,6 +28,9 @@ #if CFG_TUD_MSC +// whether host does safe-eject +static bool ejected = false; + // Some MCU doesn't have enough 8KB SRAM to store the whole disk // We will use Flash as read-only disk with board that has // CFG_EXAMPLE_MSC_READONLY defined @@ -137,7 +140,13 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) { (void) lun; - return true; // RAM disk is always ready + // RAM disk is ready until ejected + if (ejected) { + tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3a, 0x00); + return false; + } + + return true; } // Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size @@ -166,6 +175,7 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo }else { // unload disk storage + ejected = true; } } diff --git a/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject b/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject index 18291fbfd..b8b099b68 100644 --- a/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject +++ b/examples/device/cdc_msc_freertos/ses/samd21/samd21.emProject @@ -27,7 +27,7 @@ linker_memory_map_file="$(ProjectDir)/ATSAMD21G18A_MemoryMap.xml" linker_section_placement_file="flash_placement.xml" linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000" - macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd21;freertosDir=../../../../../lib/FreeRTOS" + macros="DeviceFamily=SAMD21;Target=ATSAMD21G18A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/asf4/samd21;freertosDir=../../../../../lib/FreeRTOS" project_directory="" project_type="Executable" target_reset_script="Reset();" @@ -52,20 +52,20 @@ <folder Name="asf4"> <folder Name="samd21"> <folder Name="gcc"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/gcc/system_samd21.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/gcc/system_samd21.c" /> </folder> <folder Name="hpl"> <folder Name="core"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/core/hpl_init.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/core/hpl_init.c" /> </folder> <folder Name="gclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/gclk/hpl_gclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/gclk/hpl_gclk.c" /> </folder> <folder Name="pm"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/pm/hpl_pm.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/pm/hpl_pm.c" /> </folder> <folder Name="sysctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd21/hpl/sysctrl/hpl_sysctrl.c" /> </folder> </folder> </folder> diff --git a/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject b/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject index c18aad2eb..d84d070c0 100644 --- a/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject +++ b/examples/device/cdc_msc_freertos/ses/samd51/samd51.emProject @@ -28,7 +28,7 @@ linker_memory_map_file="ATSAMD51J19A_MemoryMap.xml" linker_section_placement_file="flash_placement.xml" linker_section_placements_segments="FLASH RX 0x00000000 0x00080000;RAM RWX 0x20000000 0x00030000" - macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/samd/asf4/samd51;freertosDir=../../../../../lib/FreeRTOS" + macros="DeviceFamily=SAMD51;Target=ATSAMD51J19A;Placement=Flash;rootDir=../../../../..;asf4Dir=../../../../../hw/mcu/microchip/asf4/samd51;freertosDir=../../../../../lib/FreeRTOS" project_directory="" project_type="Executable" target_reset_script="Reset();" @@ -53,23 +53,23 @@ <folder Name="asf4"> <folder Name="samd51"> <folder Name="gcc"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/gcc/system_samd51.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/gcc/system_samd51.c" /> </folder> <folder Name="hpl"> <folder Name="core"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/core/hpl_init.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/core/hpl_init.c" /> </folder> <folder Name="osc32kctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/osc32kctrl/hpl_osc32kctrl.c" /> </folder> <folder Name="oscctrl"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/oscctrl/hpl_oscctrl.c" /> </folder> <folder Name="mclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/mclk/hpl_mclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/mclk/hpl_mclk.c" /> </folder> <folder Name="gclk"> - <file file_name="../../../../../hw/mcu/microchip/samd/asf4/samd51/hpl/gclk/hpl_gclk.c" /> + <file file_name="../../../../../hw/mcu/microchip/asf4/samd51/hpl/gclk/hpl_gclk.c" /> </folder> </folder> </folder> diff --git a/examples/device/webusb_serial/src/main.c b/examples/device/webusb_serial/src/main.c index e1a098048..9309bbf6e 100644 --- a/examples/device/webusb_serial/src/main.c +++ b/examples/device/webusb_serial/src/main.c @@ -143,9 +143,14 @@ void tud_resume_cb(void) // WebUSB use vendor class //--------------------------------------------------------------------+ -// Invoked when received VENDOR control request -bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const * request) +// Invoked when a control transfer occurred on an interface of this class +// Driver response accordingly to the request and the transfer stage (setup/data/ack) +// return false to stall control endpoint (e.g unsupported request) +bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) { + // nothing to with DATA & ACK stage + if (stage != CONTROL_STAGE_SETUP ) return true; + switch (request->bRequest) { case VENDOR_REQUEST_WEBUSB: @@ -194,16 +199,6 @@ bool tud_vendor_control_request_cb(uint8_t rhport, tusb_control_request_t const return true; } -// Invoked when DATA Stage of VENDOR's request is complete -bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_request_t const * request) -{ - (void) rhport; - (void) request; - - // nothing to do - return true; -} - void webserial_task(void) { if ( web_serial_connected ) |
