summaryrefslogtreecommitdiff
path: root/examples/device/dynamic_configuration/src
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2021-08-30 17:31:50 +0700
committerGitHub <[email protected]>2021-08-30 17:31:50 +0700
commit38f5aee9c31299874dcda1758cb98e4404c6ad9d (patch)
tree3d29d52b6305d32e4c7960ad358a3cfe289b5ec8 /examples/device/dynamic_configuration/src
parent36dc25a22d05cf9826944e363dd9ca4eb3416661 (diff)
parentfdf1ff545f41c23f63e86d6debaa852e731d7644 (diff)
Merge pull request #1058 from hathach/usbcv-compliant-test
nrf5x USB Compliance Verification Test suite
Diffstat (limited to 'examples/device/dynamic_configuration/src')
-rw-r--r--examples/device/dynamic_configuration/src/msc_disk.c8
-rw-r--r--examples/device/dynamic_configuration/src/usb_descriptors.c4
2 files changed, 9 insertions, 3 deletions
diff --git a/examples/device/dynamic_configuration/src/msc_disk.c b/examples/device/dynamic_configuration/src/msc_disk.c
index 5aa7befc9..b9205f0c2 100644
--- a/examples/device/dynamic_configuration/src/msc_disk.c
+++ b/examples/device/dynamic_configuration/src/msc_disk.c
@@ -178,6 +178,9 @@ int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buff
{
(void) lun;
+ // out of ramdisk
+ if ( lba >= DISK_BLOCK_NUM ) return -1;
+
uint8_t const* addr = msc_disk[lba] + offset;
memcpy(buffer, addr, bufsize);
@@ -190,6 +193,9 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
{
(void) lun;
+ // out of ramdisk
+ if ( lba >= DISK_BLOCK_NUM ) return -1;
+
#ifndef CFG_EXAMPLE_MSC_READONLY
uint8_t* addr = msc_disk[lba] + offset;
memcpy(addr, buffer, bufsize);
@@ -208,7 +214,7 @@ int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer,
// read10 & write10 has their own callback and MUST not be handled here
void const* response = NULL;
- uint16_t resplen = 0;
+ int32_t resplen = 0;
// most scsi handled is input
bool in_xfer = true;
diff --git a/examples/device/dynamic_configuration/src/usb_descriptors.c b/examples/device/dynamic_configuration/src/usb_descriptors.c
index 9ccb37654..3352972a5 100644
--- a/examples/device/dynamic_configuration/src/usb_descriptors.c
+++ b/examples/device/dynamic_configuration/src/usb_descriptors.c
@@ -160,7 +160,7 @@ enum
uint8_t const desc_configuration_0[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
- TUD_CONFIG_DESCRIPTOR(1, ITF_0_NUM_TOTAL, 0, CONFIG_0_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
+ TUD_CONFIG_DESCRIPTOR(1, ITF_0_NUM_TOTAL, 0, CONFIG_0_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP notification address and size, EP data address (out, in) and size.
TUD_CDC_DESCRIPTOR(ITF_0_NUM_CDC, 0, EPNUM_0_CDC_NOTIF, 8, EPNUM_0_CDC_OUT, EPNUM_0_CDC_IN, 64),
@@ -173,7 +173,7 @@ uint8_t const desc_configuration_0[] =
uint8_t const desc_configuraiton_1[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
- TUD_CONFIG_DESCRIPTOR(1, ITF_1_NUM_TOTAL, 0, CONFIG_1_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
+ TUD_CONFIG_DESCRIPTOR(1, ITF_1_NUM_TOTAL, 0, CONFIG_1_TOTAL_LEN, 0x00, 100),
// Interface number, string index, EP Out & EP In address, EP size
TUD_MSC_DESCRIPTOR(ITF_1_NUM_MSC, 0, EPNUM_1_MSC_OUT, EPNUM_1_MSC_IN, TUD_OPT_HIGH_SPEED ? 512 : 64),