diff options
| author | Ha Thach <[email protected]> | 2021-07-29 16:13:13 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-07-29 16:13:13 +0700 |
| commit | fa00377d9338e3bead32e8b670283879e1959bfb (patch) | |
| tree | af81779f8a78a56de967b216600571408f6a374d /src/device | |
| parent | aca24ed481907a036e85a00de7707e599730a3ba (diff) | |
| parent | 15112fdbba8cf4e9ad0d99fafd8b40f07f29fb6d (diff) | |
Merge pull request #859 from Wini-Buh/CCRX_Port
Adaptations for Renesas CCRX toolchain and Rx72N controller performed
Diffstat (limited to 'src/device')
| -rw-r--r-- | src/device/dcd_attr.h | 4 | ||||
| -rw-r--r-- | src/device/usbd.c | 26 | ||||
| -rw-r--r-- | src/device/usbd.h | 8 | ||||
| -rw-r--r-- | src/device/usbd_pvt.h | 1 |
4 files changed, 19 insertions, 20 deletions
diff --git a/src/device/dcd_attr.h b/src/device/dcd_attr.h index 306335642..18f369332 100644 --- a/src/device/dcd_attr.h +++ b/src/device/dcd_attr.h @@ -141,11 +141,11 @@ #define DCD_ATTR_ENDPOINT_MAX 7 //------------- Renesas -------------// -#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) +#elif TU_CHECK_MCU(RX63X) || TU_CHECK_MCU(RX65X) || TU_CHECK_MCU(RX72N) #define DCD_ATTR_ENDPOINT_MAX 10 //#elif TU_CHECK_MCU(MM32F327X) -// #define DCD_ATTR_ENDPOINT_MAX not knwon yet +// #define DCD_ATTR_ENDPOINT_MAX not known yet #else #warning "DCD_ATTR_ENDPOINT_MAX is not defined for this MCU, default to 8" diff --git a/src/device/usbd.c b/src/device/usbd.c index 0e24bf40e..a30eab217 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -831,7 +831,7 @@ static bool process_set_config(uint8_t rhport, uint8_t cfg_num) // Parse interface descriptor uint8_t const * p_desc = ((uint8_t const*) desc_cfg) + sizeof(tusb_desc_configuration_t); - uint8_t const * desc_end = ((uint8_t const*) desc_cfg) + desc_cfg->wTotalLength; + uint8_t const * desc_end = ((uint8_t const*) desc_cfg) + tu_le16toh(desc_cfg->wTotalLength); while( p_desc < desc_end ) { @@ -953,9 +953,8 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const tusb_desc_bos_t const* desc_bos = (tusb_desc_bos_t const*) tud_descriptor_bos_cb(); - uint16_t total_len; // Use offsetof to avoid pointer to the odd/misaligned address - memcpy(&total_len, (uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength), 2); + uint16_t const total_len = tu_le16toh( tu_unaligned_read16((uint8_t*) desc_bos + offsetof(tusb_desc_bos_t, wTotalLength)) ); return tud_control_xfer(rhport, p_request, (void*) desc_bos, total_len); } @@ -968,9 +967,8 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const tusb_desc_configuration_t const* desc_config = (tusb_desc_configuration_t const*) tud_descriptor_configuration_cb(desc_index); TU_ASSERT(desc_config); - uint16_t total_len; // Use offsetof to avoid pointer to the odd/misaligned address - memcpy(&total_len, (uint8_t*) desc_config + offsetof(tusb_desc_configuration_t, wTotalLength), 2); + uint16_t const total_len = tu_le16toh( tu_unaligned_read16((uint8_t*) desc_config + offsetof(tusb_desc_configuration_t, wTotalLength)) ); return tud_control_xfer(rhport, p_request, (void*) desc_config, total_len); } @@ -1150,15 +1148,17 @@ void usbd_defer_func(osal_task_func_t func, void* param, bool in_isr) bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep) { - TU_LOG2(" Open EP %02X with Size = %u\r\n", desc_ep->bEndpointAddress, desc_ep->wMaxPacketSize.size); - TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < DCD_ATTR_ENDPOINT_MAX); + uint16_t const max_packet_size = tu_le16toh(desc_ep->wMaxPacketSize.size); + + TU_LOG2(" Open EP %02X with Size = %u\r\n", desc_ep->bEndpointAddress, max_packet_size); + TU_ASSERT(tu_edpt_number(desc_ep->bEndpointAddress) < CFG_TUD_ENDPPOINT_MAX); switch (desc_ep->bmAttributes.xfer) { case TUSB_XFER_ISOCHRONOUS: { - uint16_t const max_epsize = (_usbd_dev.speed == TUSB_SPEED_HIGH ? 1024 : 1023); - TU_ASSERT(desc_ep->wMaxPacketSize.size <= max_epsize); + uint16_t const spec_size = (_usbd_dev.speed == TUSB_SPEED_HIGH ? 1024 : 1023); + TU_ASSERT(max_packet_size <= spec_size); } break; @@ -1166,18 +1166,18 @@ bool usbd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep) if (_usbd_dev.speed == TUSB_SPEED_HIGH) { // Bulk highspeed must be EXACTLY 512 - TU_ASSERT(desc_ep->wMaxPacketSize.size == 512); + TU_ASSERT(max_packet_size == 512); }else { // TODO Bulk fullspeed can only be 8, 16, 32, 64 - TU_ASSERT(desc_ep->wMaxPacketSize.size <= 64); + TU_ASSERT(max_packet_size <= 64); } break; case TUSB_XFER_INTERRUPT: { - uint16_t const max_epsize = (_usbd_dev.speed == TUSB_SPEED_HIGH ? 1024 : 64); - TU_ASSERT(desc_ep->wMaxPacketSize.size <= max_epsize); + uint16_t const spec_size = (_usbd_dev.speed == TUSB_SPEED_HIGH ? 1024 : 64); + TU_ASSERT(max_packet_size <= spec_size); } break; diff --git a/src/device/usbd.h b/src/device/usbd.h index 1405f6917..c85616c95 100644 --- a/src/device/usbd.h +++ b/src/device/usbd.h @@ -100,10 +100,6 @@ bool tud_control_status(uint8_t rhport, tusb_control_request_t const * request); // Application return pointer to descriptor uint8_t const * tud_descriptor_device_cb(void); -// Invoked when received GET BOS DESCRIPTOR request -// Application return pointer to descriptor -TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void); - // Invoked when received GET CONFIGURATION DESCRIPTOR request // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete uint8_t const * tud_descriptor_configuration_cb(uint8_t index); @@ -112,6 +108,10 @@ uint8_t const * tud_descriptor_configuration_cb(uint8_t index); // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid); +// Invoked when received GET BOS DESCRIPTOR request +// Application return pointer to descriptor +TU_ATTR_WEAK uint8_t const * tud_descriptor_bos_cb(void); + // Invoked when received GET DEVICE QUALIFIER DESCRIPTOR request // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete TU_ATTR_WEAK uint8_t const* tud_descriptor_device_qualifier_cb(void); diff --git a/src/device/usbd_pvt.h b/src/device/usbd_pvt.h index b8d34d7b6..6a4b30956 100644 --- a/src/device/usbd_pvt.h +++ b/src/device/usbd_pvt.h @@ -56,7 +56,6 @@ typedef struct // Note: The drivers array must be accessible at all time when stack is active usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) TU_ATTR_WEAK; - typedef bool (*usbd_control_xfer_cb_t)(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request); //--------------------------------------------------------------------+ |
