From 60d8cde6951fa9fe9c43064ee701598e9da566f7 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 22 Nov 2018 17:21:07 +0700 Subject: rename CFG_TUSB_MEM_SECTION to CFG_TUSB_MEM_SECTION --- src/class/cdc/cdc_device.c | 2 +- src/class/cdc/cdc_host.h | 8 ++-- src/class/cdc/cdc_rndis_host.c | 4 +- src/class/hid/hid_device.c | 2 +- src/class/hid/hid_device.h | 4 +- src/class/hid/hid_host.c | 2 +- src/class/hid/hid_host.h | 4 +- src/class/msc/msc_device.c | 4 +- src/class/msc/msc_host.c | 4 +- src/class/msc/msc_host.h | 6 +-- src/device/usbd_control.c | 2 +- src/host/ehci/ehci.c | 6 +-- src/host/hub.c | 4 +- src/host/ohci/ohci.c | 2 +- src/host/usbh.c | 4 +- .../nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c | 6 +-- src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c | 2 +- src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 47 ++++++++++++++-------- src/tusb_option.h | 5 ++- 19 files changed, 67 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index d8ade9c7f..a0abd42f6 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -87,7 +87,7 @@ typedef struct //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -CFG_TUSB_ATTR_USBRAM static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC]; +CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC]; //--------------------------------------------------------------------+ // APPLICATION API diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h index 77f1e5a78..b3e995470 100644 --- a/src/class/cdc/cdc_host.h +++ b/src/class/cdc/cdc_host.h @@ -77,27 +77,27 @@ bool tuh_cdc_is_busy(uint8_t dev_addr, cdc_pipeid_t pipeid) ATTR_PURE ATTR_WARN /** \brief Perform USB OUT transfer to device * \param[in] dev_addr device address - * \param[in] p_data Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in] p_data Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] length Number of bytes to be transferred via USB bus * \retval TUSB_ERROR_NONE on success * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request) * \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct * \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by the - * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_ATTR_USBRAM. + * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_MEM_SECTION. */ tusb_error_t tuh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify); /** \brief Perform USB IN transfer to get data from device * \param[in] dev_addr device address - * \param[in] p_buffer Buffer containing received data. Must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in] p_buffer Buffer containing received data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] length Number of bytes to be transferred via USB bus * \retval TUSB_ERROR_NONE on success * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request) * \retval TUSB_ERROR_INVALID_PARA if input parameters are not correct * \note This function is non-blocking and returns immediately. The result of USB transfer will be reported by the - * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_ATTR_USBRAM. + * interface's callback function. \a p_data must be declared with \ref CFG_TUSB_MEM_SECTION. */ tusb_error_t tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify); diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c index 9b7684f77..42722fd0d 100644 --- a/src/class/cdc/cdc_rndis_host.c +++ b/src/class/cdc/cdc_rndis_host.c @@ -54,8 +54,8 @@ //--------------------------------------------------------------------+ #define RNDIS_MSG_PAYLOAD_MAX (1024*4) -CFG_TUSB_ATTR_USBRAM static uint8_t msg_notification[CFG_TUSB_HOST_DEVICE_MAX][8]; -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX]; +CFG_TUSB_MEM_SECTION static uint8_t msg_notification[CFG_TUSB_HOST_DEVICE_MAX][8]; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX]; STATIC_VAR rndish_data_t rndish_data[CFG_TUSB_HOST_DEVICE_MAX]; diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index b5586a488..cece06ea0 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -91,7 +91,7 @@ typedef struct hidd_interface_t* itf; } hidd_report_t ; -CFG_TUSB_ATTR_USBRAM static hidd_interface_t _hidd_itf[ITF_COUNT]; +CFG_TUSB_MEM_SECTION static hidd_interface_t _hidd_itf[ITF_COUNT]; #if CFG_TUD_HID_KEYBOARD diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index 7f8cd0fa7..357c71082 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -110,7 +110,7 @@ extern const hid_ascii_to_keycode_entry_t HID_ASCII_TO_KEYCODE[128]; /** Callback invoked when USB host request \ref HID_REQ_CONTROL_GET_REPORT. * \param[in] report_type specify which report (INPUT, OUTPUT, FEATURE) that host requests - * \param[out] buffer data that application need to update, value must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[out] buffer data that application need to update, value must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] reqlen number of bytes that host requested * \retval non-zero Actual number of bytes in the response's buffer. * \retval zero indicates the current request is not supported. Tinyusb device stack will reject the request by @@ -173,7 +173,7 @@ static inline bool tud_hid_mouse_button_release(void) /** * Callback function that is invoked when USB host request \ref HID_REQ_CONTROL_GET_REPORT. * \param[in] report_type specify which report (INPUT, OUTPUT, FEATURE) that host requests - * \param[out] buffer buffer that application need to update, value must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[out] buffer buffer that application need to update, value must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] reqlen number of bytes that host requested * \retval non-zero Actual number of bytes in the response's buffer. * \retval zero indicates the current request is not supported. Tinyusb device stack will reject the request by diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index 518297eec..7129562c5 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -177,7 +177,7 @@ void hidh_init(void) } #if 0 -CFG_TUSB_ATTR_USBRAM uint8_t report_descriptor[256]; +CFG_TUSB_MEM_SECTION uint8_t report_descriptor[256]; #endif tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index b93bcdccb..3acc05bf7 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -80,7 +80,7 @@ bool tuh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNU /** \brief Perform a get report from Keyboard interface * \param[in] dev_addr device address - * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_MEM_SECTION) * \returns \ref tusb_error_t type to indicate success or error condition. * \retval TUSB_ERROR_NONE on success * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device @@ -145,7 +145,7 @@ bool tuh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED /** \brief Perform a get report from Mouse interface * \param[in] dev_addr device address - * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in,out] p_report address that is used to store data from device. Must be accessible by usb controller (see \ref CFG_TUSB_MEM_SECTION) * \returns \ref tusb_error_t type to indicate success or error condition. * \retval TUSB_ERROR_NONE on success * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index bfe708f42..78e6d0a6b 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -83,8 +83,8 @@ typedef struct { uint8_t add_sense_qualifier; }mscd_interface_t; -CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf; -CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN static uint8_t _mscd_buf[CFG_TUD_MSC_BUFSIZE]; +CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf; +CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static uint8_t _mscd_buf[CFG_TUD_MSC_BUFSIZE]; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index 9250b8df7..bd3e92de1 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -51,13 +51,13 @@ //--------------------------------------------------------------------+ // MACRO CONSTANT TYPEDEF //--------------------------------------------------------------------+ -CFG_TUSB_ATTR_USBRAM STATIC_VAR msch_interface_t msch_data[CFG_TUSB_HOST_DEVICE_MAX]; +CFG_TUSB_MEM_SECTION STATIC_VAR msch_interface_t msch_data[CFG_TUSB_HOST_DEVICE_MAX]; //------------- Initalization Data -------------// static osal_semaphore_t msch_sem_hdl; // buffer used to read scsi information when mounted, largest response data currently is inquiry -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4) STATIC_VAR uint8_t msch_buffer[sizeof(scsi_inquiry_data_t)]; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) STATIC_VAR uint8_t msch_buffer[sizeof(scsi_inquiry_data_t)]; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index dce275fc8..6d95cfe34 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -104,7 +104,7 @@ tusb_error_t tuh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32 /** \brief Perform SCSI READ 10 command to read data from MassStorage device * \param[in] dev_addr device address * \param[in] lun Targeted Logical Unit - * \param[out] p_buffer Buffer used to store data read from device. Must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[out] p_buffer Buffer used to store data read from device. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] lba Starting Logical Block Address to be read * \param[in] block_count Number of Block to be read * \retval TUSB_ERROR_NONE on success @@ -118,7 +118,7 @@ tusb_error_t tuh_msc_read10 (uint8_t dev_addr, uint8_t lun, void * p_buffer, uin /** \brief Perform SCSI WRITE 10 command to write data to MassStorage device * \param[in] dev_addr device address * \param[in] lun Targeted Logical Unit - * \param[in] p_buffer Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in] p_buffer Buffer containing data. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \param[in] lba Starting Logical Block Address to be written * \param[in] block_count Number of Block to be written * \retval TUSB_ERROR_NONE on success @@ -132,7 +132,7 @@ tusb_error_t tuh_msc_write10(uint8_t dev_addr, uint8_t lun, void const * p_buffe /** \brief Perform SCSI REQUEST SENSE command, used to retrieve sense data from MassStorage device * \param[in] dev_addr device address * \param[in] lun Targeted Logical Unit - * \param[in] p_data Buffer to store response's data from device. Must be accessible by USB controller (see \ref CFG_TUSB_ATTR_USBRAM) + * \param[in] p_data Buffer to store response's data from device. Must be accessible by USB controller (see \ref CFG_TUSB_MEM_SECTION) * \retval TUSB_ERROR_NONE on success * \retval TUSB_ERROR_INTERFACE_IS_BUSY if the interface is already transferring data with device * \retval TUSB_ERROR_DEVICE_NOT_READY if device is not yet configured (by SET CONFIGURED request) diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 8564d1ae9..33de6d064 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -64,7 +64,7 @@ typedef struct static usbd_control_xfer_t _control_state; -CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN uint8_t _usbd_ctrl_buf[CFG_TUD_ENDOINT0_SIZE]; +CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN uint8_t _usbd_ctrl_buf[CFG_TUD_ENDOINT0_SIZE]; void usbd_control_reset (uint8_t rhport) { diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index c7ff70d70..b3d897537 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -56,12 +56,12 @@ //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -CFG_TUSB_ATTR_USBRAM STATIC_VAR ehci_data_t ehci_data; +CFG_TUSB_MEM_SECTION STATIC_VAR ehci_data_t ehci_data; #if EHCI_PERIODIC_LIST #if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HOST) - CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE]; + CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE]; #ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma TU_VERIFY_STATIC( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation @@ -69,7 +69,7 @@ CFG_TUSB_ATTR_USBRAM STATIC_VAR ehci_data_t ehci_data; #endif #if (CFG_TUSB_RHPORT1_MODE & OPT_MODE_HOST) - CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE]; + CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE]; #ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma TU_VERIFY_STATIC( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation diff --git a/src/host/hub.c b/src/host/hub.c index 624e43563..e4c08c9d1 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -58,8 +58,8 @@ typedef struct { uint8_t status_change; // data from status change interrupt endpoint }usbh_hub_t; -CFG_TUSB_ATTR_USBRAM STATIC_VAR usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX]; -ATTR_ALIGNED(4) CFG_TUSB_ATTR_USBRAM STATIC_VAR uint8_t hub_enum_buffer[sizeof(descriptor_hub_desc_t)]; +CFG_TUSB_MEM_SECTION STATIC_VAR usbh_hub_t hub_data[CFG_TUSB_HOST_DEVICE_MAX]; +ATTR_ALIGNED(4) CFG_TUSB_MEM_SECTION 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/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index b9183a025..f058f8348 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -142,7 +142,7 @@ enum { //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(256) STATIC_VAR ohci_data_t ohci_data; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(256) STATIC_VAR ohci_data_t ohci_data; static ohci_ed_t * const p_ed_head[] = { diff --git a/src/host/usbh.c b/src/host/usbh.c index f996d7a70..196a45ee7 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -109,13 +109,13 @@ enum { USBH_CLASS_DRIVER_COUNT = sizeof(usbh_class_drivers) / sizeof(host_class_ //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -CFG_TUSB_ATTR_USBRAM usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; // including zero-address +CFG_TUSB_MEM_SECTION usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; // including zero-address //------------- Enumeration Task Data -------------/ enum { ENUM_QUEUE_DEPTH = 16 }; STATIC_VAR osal_queue_t enum_queue_hdl; -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(4) STATIC_VAR uint8_t enum_data_buffer[CFG_TUSB_HOST_ENUM_BUFFER_SIZE]; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(4) STATIC_VAR uint8_t enum_data_buffer[CFG_TUSB_HOST_ENUM_BUFFER_SIZE]; //------------- Reporter Task Data -------------// diff --git a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c index 5c64cbb6b..4e514d6e2 100644 --- a/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c +++ b/src/portable/nxp/lpc11xx_lpc13xx/dcd_lpc_11uxx_13uxx.c @@ -141,11 +141,11 @@ typedef struct { //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION //--------------------------------------------------------------------+ -// CFG_TUSB_ATTR_USBRAM must have ATTR_ALIGNED(64) for lpc11u & lpc13u +// CFG_TUSB_MEM_SECTION must have ATTR_ALIGNED(64) for lpc11u & lpc13u #ifdef __ICCARM__ -ATTR_ALIGNED(256) CFG_TUSB_ATTR_USBRAM // for IAR the first ATTR_ALIGNED takes effect +ATTR_ALIGNED(256) CFG_TUSB_MEM_SECTION // for IAR the first ATTR_ALIGNED takes effect #else -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(256) // GCC & Keil the last ATTR_ALIGNED takes effect +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(256) // GCC & Keil the last ATTR_ALIGNED takes effect #endif STATIC_VAR dcd_11u_13u_data_t dcd_data; diff --git a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c index 850e257c6..ce8362546 100644 --- a/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c +++ b/src/portable/nxp/lpc17xx/dcd_lpc175x_6x.c @@ -68,7 +68,7 @@ typedef struct { }dcd_data_t; -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(128) STATIC_VAR dcd_data_t dcd_data; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(128) STATIC_VAR dcd_data_t dcd_data; //--------------------------------------------------------------------+ // INTERNAL OBJECT & FUNCTION DECLARATION diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 8d53759e6..64a2c257a 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -66,19 +66,30 @@ typedef struct { dcd_qtd_t qtd[DCD_QTD_MAX] ATTR_ALIGNED(32); }dcd_data_t; -extern ATTR_WEAK dcd_data_t dcd_data0; -extern ATTR_WEAK dcd_data_t dcd_data1; - #if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(2048) STATIC_VAR dcd_data_t dcd_data0; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(2048) static dcd_data_t dcd_data0; #endif #if (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) -CFG_TUSB_ATTR_USBRAM ATTR_ALIGNED(2048) STATIC_VAR dcd_data_t dcd_data1; +CFG_TUSB_MEM_SECTION ATTR_ALIGNED(2048) static dcd_data_t dcd_data1; #endif static LPC_USB0_Type * const LPC_USB[2] = { LPC_USB0, ((LPC_USB0_Type*) LPC_USB1_BASE) }; -static dcd_data_t* const dcd_data_ptr[2] = { &dcd_data0, &dcd_data1 }; + +static dcd_data_t* const dcd_data_ptr[2] = +{ +#if (CFG_TUSB_RHPORT0_MODE & OPT_MODE_DEVICE) + &dcd_data0, +#else + NULL, +#endif + +#if (CFG_TUSB_RHPORT1_MODE & OPT_MODE_DEVICE) + &dcd_data1 +#else + NULL +#endif +}; //--------------------------------------------------------------------+ // CONTROLLER API @@ -104,12 +115,11 @@ static void bus_reset(uint8_t rhport) LPC_USB0_Type* const lpc_usb = LPC_USB[rhport]; // The reset value for all endpoint types is the control endpoint. If one endpoint - //direction is enabled and the paired endpoint of opposite direction is disabled, then the - //endpoint type of the unused direction must bechanged from the control type to any other - //type (e.g. bulk). Leaving an unconfigured endpoint control will cause undefined behavior - //for the data PID tracking on the active endpoint. - lpc_usb->ENDPTCTRL1 = lpc_usb->ENDPTCTRL2 = lpc_usb->ENDPTCTRL3 = - (TUSB_XFER_BULK << 2) | (TUSB_XFER_BULK << 18); + // direction is enabled and the paired endpoint of opposite direction is disabled, then the + // endpoint type of the unused direction must bechanged from the control type to any other + // type (e.g. bulk). Leaving an unconfigured endpoint control will cause undefined behavior + // for the data PID tracking on the active endpoint. + lpc_usb->ENDPTCTRL1 = lpc_usb->ENDPTCTRL2 = lpc_usb->ENDPTCTRL3 = (TUSB_XFER_BULK << 2) | (TUSB_XFER_BULK << 18); // USB1 only has 3 non-control endpoints if ( rhport == 0) @@ -282,6 +292,12 @@ void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) } } +// TOOD implement later +bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) +{ + return false; +} + void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { volatile uint32_t * reg_control = get_reg_control_addr(rhport, edpt_addr2phy(ep_addr)); @@ -375,7 +391,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } -//------------- Device Controller Driver's Interrupt Handler -------------// +//--------------------------------------------------------------------+ +// ISR +//--------------------------------------------------------------------+ void xfer_complete_isr(uint8_t rhport, uint32_t reg_complete) { for(uint8_t ep_idx = 2; ep_idx < DCD_QHD_MAX; ep_idx++) @@ -504,7 +522,4 @@ void hal_dcd_isr(uint8_t rhport) if (int_status & INT_MASK_ERROR) TU_ASSERT(false, ); } -//--------------------------------------------------------------------+ -// HELPER -//--------------------------------------------------------------------+ #endif diff --git a/src/tusb_option.h b/src/tusb_option.h index f19ff4076..18e1e245e 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -131,8 +131,9 @@ #warning CFG_TUSB_DEBUG is not defined, default value is 0 #endif -#ifndef CFG_TUSB_ATTR_USBRAM - #error CFG_TUSB_ATTR_USBRAM is not defined, please help me know how to place data in accessible RAM for usb controller +// place data in accessible RAM for usb controller +#ifndef CFG_TUSB_MEM_SECTION +#define CFG_TUSB_MEM_SECTION #endif #ifndef CFG_TUSB_OS -- cgit v1.3.1 From 569e85a0c0a80848e3076b64363ce0e589d3a604 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 22 Nov 2018 17:40:20 +0700 Subject: cdc work ok with lpc43xx --- .../cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject | 2 +- examples/device/cdc_msc_hid/src/tusb_config.h | 18 ++++-- src/common/compiler/tusb_compiler_gcc.h | 2 - src/common/compiler/tusb_compiler_iar.h | 2 - src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 71 +++++++++++----------- 5 files changed, 51 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject b/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject index 3b91cf865..363fae3e2 100644 --- a/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject +++ b/examples/device/cdc_msc_hid/ses/lpc43xx/lpc43xx.emProject @@ -19,7 +19,7 @@ arm_target_device_name="LPC4357_M4" arm_target_interface_type="SWD" build_treat_warnings_as_errors="Yes" - c_preprocessor_definitions="CORE_M4;__LPC4300_FAMILY;__LPC435x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4357;CFG_TUSB_MCU=OPT_MCU_LPC43XX" + c_preprocessor_definitions="CORE_M4;__LPC4300_FAMILY;__LPC435x_SUBFAMILY;ARM_MATH_CM4;FLASH_PLACEMENT=1;BOARD_EA4357;CFG_TUSB_MCU=OPT_MCU_LPC43XX;CFG_TUSB_MEM_SECTION= __attribute__((section(".bss2")))" c_user_include_directories="../../src;$(rootDir)/hw/cmsis/Include;$(rootDir)/hw;$(rootDir)/src;$(lpcDir)/CMSIS_LPC43xx_DriverLib/inc" debug_register_definition_file="LPC43xx_Registers.xml" debug_target_connection="J-Link" diff --git a/examples/device/cdc_msc_hid/src/tusb_config.h b/examples/device/cdc_msc_hid/src/tusb_config.h index 3af109188..9bc97ecff 100644 --- a/examples/device/cdc_msc_hid/src/tusb_config.h +++ b/examples/device/cdc_msc_hid/src/tusb_config.h @@ -58,16 +58,24 @@ #define CFG_TUSB_DEBUG 2 #define CFG_TUSB_OS OPT_OS_NONE -//-------------------------------------------------------------------- -// USB RAM PLACEMENT -//-------------------------------------------------------------------- -#define CFG_TUSB_ATTR_USBRAM +/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment. + * Tinyusb use follows macros to declare transferring memory so that they can be put + * into those specific section. + * e.g + * - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") )) + * - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4))) + */ +#ifndef CFG_TUSB_MEM_SECTION +#define CFG_TUSB_MEM_SECTION +#endif + +#ifndef CFG_TUSB_MEM_ALIGN #define CFG_TUSB_MEM_ALIGN ATTR_ALIGNED(4) +#endif //-------------------------------------------------------------------- // DEVICE CONFIGURATION //-------------------------------------------------------------------- - #define CFG_TUD_ENDOINT0_SIZE 64 /*------------- Descriptors -------------*/ diff --git a/src/common/compiler/tusb_compiler_gcc.h b/src/common/compiler/tusb_compiler_gcc.h index c9f716d48..e40ad9c41 100644 --- a/src/common/compiler/tusb_compiler_gcc.h +++ b/src/common/compiler/tusb_compiler_gcc.h @@ -66,10 +66,8 @@ /// The packed attribute specifies that a variable or structure field should have the smallest possible alignment—one byte for a variable, and one bit for a field, unless you specify a larger value with the aligned attribute #define ATTR_PACKED __attribute__ ((packed)) - #define ATTR_PREPACKED -#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed)) /** @} */ /** \defgroup Group_FuncAttr Function Attributes diff --git a/src/common/compiler/tusb_compiler_iar.h b/src/common/compiler/tusb_compiler_iar.h index 1703ea45f..1f8936859 100644 --- a/src/common/compiler/tusb_compiler_iar.h +++ b/src/common/compiler/tusb_compiler_iar.h @@ -53,8 +53,6 @@ #endif #define ALIGN_OF(x) __ALIGNOF__(x) - -#define ATTR_PACKED_STRUCT(x) __packed x #define ATTR_PREPACKED __packed #define ATTR_PACKED //#define ATTR_SECTION(section) _Pragma((#section)) diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 64a2c257a..07f6eef82 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -237,40 +237,7 @@ static inline uint8_t qtd_find_free(uint8_t rhport) } //--------------------------------------------------------------------+ -// CONTROL PIPE API -//--------------------------------------------------------------------+ - -// control transfer does not need to use qtd find function -// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism -bool dcd_control_xfer(uint8_t rhport, uint8_t dir, uint8_t * p_buffer, uint16_t length) -{ - LPC_USB0_Type* const lpc_usb = LPC_USB[rhport]; - dcd_data_t* const p_dcd = dcd_data_ptr[rhport]; - - uint8_t const ep_phy = (dir == TUSB_DIR_IN) ? 1 : 0; - - dcd_qhd_t* qhd = &p_dcd->qhd[ep_phy]; - - // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out - while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {} - - TU_VERIFY( !qhd->qtd_overlay.active ); - - dcd_qtd_t* qtd = &p_dcd->qtd[0]; - qtd_init(qtd, p_buffer, length); - - // skip xfer complete for Status - qtd->int_on_complete = (length > 0 ? 1 : 0); - - qhd->qtd_overlay.next = (uint32_t) qtd; - - lpc_usb->ENDPTPRIME = BIT_(edpt_phy2pos(ep_phy)); - - return true; -} - -//--------------------------------------------------------------------+ -// BULK/INTERRUPT/ISOCHRONOUS PIPE API +// DCD Endpoint Port //--------------------------------------------------------------------+ static inline volatile uint32_t * get_reg_control_addr(uint8_t rhport, uint8_t physical_endpoint) { @@ -345,6 +312,36 @@ bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr) // return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active; } +// control transfer does not need to use qtd find function +// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism +bool dcd_control_xfer(uint8_t rhport, uint8_t dir, uint8_t * p_buffer, uint16_t length) +{ + LPC_USB0_Type* const lpc_usb = LPC_USB[rhport]; + dcd_data_t* const p_dcd = dcd_data_ptr[rhport]; + + uint8_t const ep_phy = (dir == TUSB_DIR_IN) ? 1 : 0; + + dcd_qhd_t* qhd = &p_dcd->qhd[ep_phy]; + + // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out + while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {} + + TU_VERIFY( !qhd->qtd_overlay.active ); + + dcd_qtd_t* qtd = &p_dcd->qtd[0]; + qtd_init(qtd, p_buffer, length); + + // skip xfer complete for Status + qtd->int_on_complete = (length > 0 ? 1 : 0); + + qhd->qtd_overlay.next = (uint32_t) qtd; + + lpc_usb->ENDPTPRIME = BIT_(edpt_phy2pos(ep_phy)); + + return true; +} + + // add only, controller virtually cannot know // TODO remove and merge to dcd_edpt_xfer static bool pipe_add_xfer(uint8_t rhport, uint8_t ed_idx, void * buffer, uint16_t total_bytes, bool int_on_complete) @@ -377,6 +374,11 @@ static bool pipe_add_xfer(uint8_t rhport, uint8_t ed_idx, void * buffer, uint16_ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) { + if ( edpt_number(ep_addr) == 0 ) + { + return dcd_control_xfer(rhport, edpt_dir(ep_addr), buffer, total_bytes); + } + uint8_t ep_idx = edpt_addr2phy(ep_addr); TU_VERIFY ( pipe_add_xfer(rhport, ep_idx, buffer, total_bytes, true) ); @@ -391,6 +393,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t return true; } + //--------------------------------------------------------------------+ // ISR //--------------------------------------------------------------------+ -- cgit v1.3.1 From a1faf5c9cbe417ecd9cd7547f4fac58222697ae5 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 22 Nov 2018 21:37:23 +0700 Subject: clean up dcd lpc43xx --- src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 173 ++++++------------------- 1 file changed, 43 insertions(+), 130 deletions(-) (limited to 'src') diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 07f6eef82..4ec93fb35 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -239,7 +239,7 @@ static inline uint8_t qtd_find_free(uint8_t rhport) //--------------------------------------------------------------------+ // DCD Endpoint Port //--------------------------------------------------------------------+ -static inline volatile uint32_t * get_reg_control_addr(uint8_t rhport, uint8_t physical_endpoint) +static inline volatile uint32_t * get_endpt_ctrl_reg(uint8_t rhport, uint8_t physical_endpoint) { return &(LPC_USB[rhport]->ENDPTCTRL0) + edpt_phy2log(physical_endpoint); } @@ -247,7 +247,7 @@ static inline volatile uint32_t * get_reg_control_addr(uint8_t rhport, uint8_t p void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) { uint8_t ep_idx = edpt_addr2phy(ep_addr); - volatile uint32_t * reg_control = get_reg_control_addr(rhport, ep_idx); + volatile uint32_t * reg_control = get_endpt_ctrl_reg(rhport, ep_idx); if ( ep_addr == 0) { @@ -267,7 +267,7 @@ bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { - volatile uint32_t * reg_control = get_reg_control_addr(rhport, edpt_addr2phy(ep_addr)); + volatile uint32_t * reg_control = get_endpt_ctrl_reg(rhport, edpt_addr2phy(ep_addr)); // data toggle also need to be reset (*reg_control) |= ENDPTCTRL_MASK_TOGGLE_RESET << ((ep_addr & TUSB_DIR_IN_MASK) ? 16 : 0); @@ -280,12 +280,12 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) // TODO not support ISO yet TU_VERIFY ( p_endpoint_desc->bmAttributes.xfer != TUSB_XFER_ISOCHRONOUS); - tusb_dir_t dir = (p_endpoint_desc->bEndpointAddress & TUSB_DIR_IN_MASK) ? TUSB_DIR_IN : TUSB_DIR_OUT; + uint8_t const epnum = edpt_number(p_endpoint_desc->bEndpointAddress); + uint8_t const dir = edpt_dir(p_endpoint_desc->bEndpointAddress); + uint8_t const ep_idx = 2*epnum + dir; //------------- Prepare Queue Head -------------// - uint8_t ep_idx = edpt_addr2phy(p_endpoint_desc->bEndpointAddress); dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; - tu_memclr(p_qhd, sizeof(dcd_qhd_t)); p_qhd->zero_length_termination = 1; @@ -293,101 +293,52 @@ bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) p_qhd->qtd_overlay.next = QTD_NEXT_INVALID; //------------- Endpoint Control Register -------------// - volatile uint32_t * reg_control = get_reg_control_addr(rhport, ep_idx); + volatile uint32_t * endpt_ctrl = get_endpt_ctrl_reg(rhport, ep_idx); // endpoint must not be already enabled - TU_VERIFY( !( (*reg_control) & (ENDPTCTRL_MASK_ENABLE << (dir ? 16 : 0)) ) ); + TU_VERIFY( !( (*endpt_ctrl) & (ENDPTCTRL_MASK_ENABLE << (dir ? 16 : 0)) ) ); - (*reg_control) |= ((p_endpoint_desc->bmAttributes.xfer << 2) | ENDPTCTRL_MASK_ENABLE | ENDPTCTRL_MASK_TOGGLE_RESET) << (dir ? 16 : 0); + (*endpt_ctrl) |= ((p_endpoint_desc->bmAttributes.xfer << 2) | ENDPTCTRL_MASK_ENABLE | ENDPTCTRL_MASK_TOGGLE_RESET) << (dir ? 16 : 0); return true; } bool dcd_edpt_busy(uint8_t rhport, uint8_t ep_addr) { - uint8_t ep_idx = edpt_addr2phy(ep_addr); + uint8_t const epnum = edpt_number(ep_addr); + uint8_t const dir = edpt_dir(ep_addr); + uint8_t const ep_idx = 2*epnum + dir; + dcd_qhd_t const * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; + dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx]; - return p_qhd->list_qtd_idx[0] != 0; // qtd list is not empty + return p_qtd->active; // return !p_qhd->qtd_overlay.halted && p_qhd->qtd_overlay.active; } -// control transfer does not need to use qtd find function -// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism -bool dcd_control_xfer(uint8_t rhport, uint8_t dir, uint8_t * p_buffer, uint16_t length) -{ - LPC_USB0_Type* const lpc_usb = LPC_USB[rhport]; - dcd_data_t* const p_dcd = dcd_data_ptr[rhport]; - - uint8_t const ep_phy = (dir == TUSB_DIR_IN) ? 1 : 0; - - dcd_qhd_t* qhd = &p_dcd->qhd[ep_phy]; - - // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out - while(lpc_usb->ENDPTSETUPSTAT & BIT_(0)) {} - - TU_VERIFY( !qhd->qtd_overlay.active ); - - dcd_qtd_t* qtd = &p_dcd->qtd[0]; - qtd_init(qtd, p_buffer, length); - - // skip xfer complete for Status - qtd->int_on_complete = (length > 0 ? 1 : 0); - - qhd->qtd_overlay.next = (uint32_t) qtd; - - lpc_usb->ENDPTPRIME = BIT_(edpt_phy2pos(ep_phy)); - - return true; -} - - -// add only, controller virtually cannot know -// TODO remove and merge to dcd_edpt_xfer -static bool pipe_add_xfer(uint8_t rhport, uint8_t ed_idx, void * buffer, uint16_t total_bytes, bool int_on_complete) +bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) { - uint8_t qtd_idx = qtd_find_free(rhport); - TU_ASSERT(qtd_idx != 0); - - dcd_data_t* p_dcd = dcd_data_ptr[rhport]; - dcd_qhd_t * p_qhd = &p_dcd->qhd[ed_idx]; - dcd_qtd_t * p_qtd = &p_dcd->qtd[qtd_idx]; + uint8_t const epnum = edpt_number(ep_addr); + uint8_t const dir = edpt_dir(ep_addr); + uint8_t const ep_idx = 2*epnum + dir; - //------------- Find free slot in qhd's array list -------------// - uint8_t free_slot; - for(free_slot=0; free_slot < DCD_QTD_PER_QHD_MAX; free_slot++) + if ( epnum == 0 ) { - if ( p_qhd->list_qtd_idx[free_slot] == 0 ) break; // found free slot + // follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism + // wait until ENDPTSETUPSTAT before priming data/status in response TODO add time out + while(LPC_USB[rhport]->ENDPTSETUPSTAT & BIT_(0)) {} } - TU_ASSERT(free_slot < DCD_QTD_PER_QHD_MAX); - p_qhd->list_qtd_idx[free_slot] = qtd_idx; // add new qtd to qhd's array list + dcd_data_t* p_dcd = dcd_data_ptr[rhport]; + dcd_qhd_t * p_qhd = &p_dcd->qhd[ep_idx]; + dcd_qtd_t * p_qtd = &p_dcd->qtd[ep_idx]; //------------- Prepare qtd -------------// qtd_init(p_qtd, buffer, total_bytes); - p_qtd->int_on_complete = int_on_complete; - - if ( free_slot > 0 ) p_dcd->qtd[ p_qhd->list_qtd_idx[free_slot-1] ].next = (uint32_t) p_qtd; - - return true; -} - -bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes) -{ - if ( edpt_number(ep_addr) == 0 ) - { - return dcd_control_xfer(rhport, edpt_dir(ep_addr), buffer, total_bytes); - } - - uint8_t ep_idx = edpt_addr2phy(ep_addr); - - TU_VERIFY ( pipe_add_xfer(rhport, ep_idx, buffer, total_bytes, true) ); - - dcd_qhd_t* p_qhd = &dcd_data_ptr[rhport]->qhd[ ep_idx ]; - dcd_qtd_t* p_qtd = &dcd_data_ptr[rhport]->qtd[ p_qhd->list_qtd_idx[0] ]; - - p_qhd->qtd_overlay.next = (uint32_t) p_qtd; // attach head QTD to QHD start transferring + p_qtd->int_on_complete = true; + p_qhd->qtd_overlay.next = (uint32_t) p_qtd; // link qtd to qhd + // start transfer LPC_USB[rhport]->ENDPTPRIME = BIT_( edpt_phy2pos(ep_idx) ) ; return true; @@ -397,39 +348,6 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t //--------------------------------------------------------------------+ // ISR //--------------------------------------------------------------------+ -void xfer_complete_isr(uint8_t rhport, uint32_t reg_complete) -{ - for(uint8_t ep_idx = 2; ep_idx < DCD_QHD_MAX; ep_idx++) - { - if ( BIT_TEST_(reg_complete, edpt_phy2pos(ep_idx)) ) - { // 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set - dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; - - // retire all QTDs in array list, up to 1st still-active QTD - while( p_qhd->list_qtd_idx[0] != 0 ) - { - dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ p_qhd->list_qtd_idx[0] ]; - - if (p_qtd->active) break; // stop immediately if found still-active QTD and shift array list - - //------------- Free QTD and shift array list -------------// - p_qtd->used = 0; // free QTD - memmove( (void*) p_qhd->list_qtd_idx, (void*) (p_qhd->list_qtd_idx+1), DCD_QTD_PER_QHD_MAX-1); - p_qhd->list_qtd_idx[DCD_QTD_PER_QHD_MAX-1]=0; - - if (p_qtd->int_on_complete) - { - uint8_t result = p_qtd->halted ? DCD_XFER_STALLED : - ( p_qtd->xact_err ||p_qtd->buffer_err ) ? DCD_XFER_FAILED : DCD_XFER_SUCCESS; - - uint8_t ep_addr = edpt_phy2addr(ep_idx); - dcd_event_xfer_complete(rhport, ep_addr, p_qtd->expected_bytes - p_qtd->total_bytes, result, true); // only number of bytes in the IOC qtd - } - } - } - } -} - void hal_dcd_isr(uint8_t rhport) { LPC_USB0_Type* const lpc_usb = LPC_USB[rhport]; @@ -478,9 +396,9 @@ void hal_dcd_isr(uint8_t rhport) dcd_data_t* const p_dcd = dcd_data_ptr[rhport]; - //------------- Set up Received -------------// if (lpc_usb->ENDPTSETUPSTAT) { + //------------- Set up Received -------------// // 23.10.10.2 Operational model for setup transfers lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT;// acknowledge @@ -490,28 +408,23 @@ void hal_dcd_isr(uint8_t rhport) dcd_event_handler(&event, true); } - //------------- Control Request Completed -------------// - else if ( edpt_complete & ( BIT_(0) | BIT_(16)) ) + if ( edpt_complete ) { - // determine Control OUT or IN - uint8_t ep_idx = BIT_TEST_(edpt_complete, 0) ? 0 : 1; - - // TODO use the actual QTD instead of the qhd's overlay to get expected bytes for actual byte xferred - dcd_qtd_t* const p_qtd = (dcd_qtd_t*) p_dcd->qhd[ep_idx].qtd_addr; - - if ( p_qtd->int_on_complete ) + for(uint8_t ep_idx = 0; ep_idx < DCD_QHD_MAX; ep_idx++) { - uint8_t result = p_qtd->halted ? DCD_XFER_STALLED : - ( p_qtd->xact_err ||p_qtd->buffer_err ) ? DCD_XFER_FAILED : DCD_XFER_SUCCESS; + if ( BIT_TEST_(edpt_complete, edpt_phy2pos(ep_idx)) ) + { + // 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set + dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; + dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx]; - dcd_event_xfer_complete(rhport, 0, p_qtd->expected_bytes - p_qtd->total_bytes, result, true); - } - } + uint8_t result = p_qtd->halted ? DCD_XFER_STALLED : + ( p_qtd->xact_err ||p_qtd->buffer_err ) ? DCD_XFER_FAILED : DCD_XFER_SUCCESS; - //------------- Transfer Complete -------------// - if ( edpt_complete & ~(BIT_(0) | BIT_(16)) ) - { - xfer_complete_isr(rhport, edpt_complete); + uint8_t ep_addr = edpt_phy2addr(ep_idx); + dcd_event_xfer_complete(rhport, ep_addr, p_qtd->expected_bytes - p_qtd->total_bytes, result, true); // only number of bytes in the IOC qtd + } + } } } -- cgit v1.3.1 From 4e8400e6fba17b47a0834f0498f3fe3d9c8c1153 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 22 Nov 2018 21:58:06 +0700 Subject: more clean up --- src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 76 ++++++++------------------ src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.h | 9 +-- 2 files changed, 26 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 4ec93fb35..274ebc032 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -175,41 +175,18 @@ bool dcd_init(uint8_t rhport) } //--------------------------------------------------------------------+ -// PIPE HELPER +// HELPER //--------------------------------------------------------------------+ -#if 0 -static inline uint8_t edpt_pos2phy(uint8_t pos) -{ // 0-5 --> OUT, 16-21 IN - return (pos < DCD_QHD_MAX/2) ? (2*pos) : (2*(pos-16)+1); -} -#endif - -static inline uint8_t edpt_phy2pos(uint8_t physical_endpoint) -{ - return physical_endpoint/2 + ( (physical_endpoint%2) ? 16 : 0); -} - -static inline uint8_t edpt_addr2phy(uint8_t endpoint_addr) +// index to bit position in register +static inline uint8_t ep_idx2bit(uint8_t ep_idx) { - return 2*(endpoint_addr & 0x0F) + ((endpoint_addr & TUSB_DIR_IN_MASK) ? 1 : 0); -} - -static inline uint8_t edpt_phy2addr(uint8_t ep_idx) -{ - return (ep_idx/2) | ( ep_idx & 0x01 ? TUSB_DIR_IN_MASK : 0 ); -} - -static inline uint8_t edpt_phy2log(uint8_t physical_endpoint) -{ - return physical_endpoint/2; + return ep_idx/2 + ( (ep_idx%2) ? 16 : 0); } static void qtd_init(dcd_qtd_t* p_qtd, void * data_ptr, uint16_t total_bytes) { tu_memclr(p_qtd, sizeof(dcd_qtd_t)); - p_qtd->used = 1; - p_qtd->next = QTD_NEXT_INVALID; p_qtd->active = 1; p_qtd->total_bytes = p_qtd->expected_bytes = total_bytes; @@ -224,38 +201,29 @@ static void qtd_init(dcd_qtd_t* p_qtd, void * data_ptr, uint16_t total_bytes) } } -// retval 0: invalid -static inline uint8_t qtd_find_free(uint8_t rhport) +static inline volatile uint32_t * get_endpt_ctrl_reg(uint8_t rhport, uint8_t ep_idx) { - // QTD0 is reserved for control transfer - for(uint8_t i=1; iqtd[i].used == 0) return i; - } - - return 0; + return &(LPC_USB[rhport]->ENDPTCTRL0) + ep_idx/2; } //--------------------------------------------------------------------+ // DCD Endpoint Port //--------------------------------------------------------------------+ -static inline volatile uint32_t * get_endpt_ctrl_reg(uint8_t rhport, uint8_t physical_endpoint) -{ - return &(LPC_USB[rhport]->ENDPTCTRL0) + edpt_phy2log(physical_endpoint); -} - void dcd_edpt_stall(uint8_t rhport, uint8_t ep_addr) { - uint8_t ep_idx = edpt_addr2phy(ep_addr); - volatile uint32_t * reg_control = get_endpt_ctrl_reg(rhport, ep_idx); + uint8_t const epnum = edpt_number(ep_addr); + uint8_t const dir = edpt_dir(ep_addr); + uint8_t const ep_idx = 2*epnum + dir; - if ( ep_addr == 0) + volatile uint32_t * endpt_ctrl = get_endpt_ctrl_reg(rhport, ep_idx); + + if ( epnum == 0) { // Stall both Control IN and OUT - (*reg_control) |= ( (ENDPTCTRL_MASK_STALL << 16) || (ENDPTCTRL_MASK_STALL << 0) ); + (*endpt_ctrl) |= ( (ENDPTCTRL_MASK_STALL << 16) || (ENDPTCTRL_MASK_STALL << 0) ); }else { - (*reg_control) |= ENDPTCTRL_MASK_STALL << (ep_idx & 0x01 ? 16 : 0); + (*endpt_ctrl) |= ENDPTCTRL_MASK_STALL << (ep_idx & 0x01 ? 16 : 0); } } @@ -267,11 +235,15 @@ bool dcd_edpt_stalled (uint8_t rhport, uint8_t ep_addr) void dcd_edpt_clear_stall(uint8_t rhport, uint8_t ep_addr) { - volatile uint32_t * reg_control = get_endpt_ctrl_reg(rhport, edpt_addr2phy(ep_addr)); + uint8_t const epnum = edpt_number(ep_addr); + uint8_t const dir = edpt_dir(ep_addr); + uint8_t const ep_idx = 2*epnum + dir; + + volatile uint32_t * endpt_ctrl = get_endpt_ctrl_reg(rhport, ep_idx); // data toggle also need to be reset - (*reg_control) |= ENDPTCTRL_MASK_TOGGLE_RESET << ((ep_addr & TUSB_DIR_IN_MASK) ? 16 : 0); - (*reg_control) &= ~(ENDPTCTRL_MASK_STALL << ((ep_addr & TUSB_DIR_IN_MASK) ? 16 : 0)); + (*endpt_ctrl) |= ENDPTCTRL_MASK_TOGGLE_RESET << ((ep_addr & TUSB_DIR_IN_MASK) ? 16 : 0); + (*endpt_ctrl) &= ~(ENDPTCTRL_MASK_STALL << ((ep_addr & TUSB_DIR_IN_MASK) ? 16 : 0)); } bool dcd_edpt_open(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc) @@ -339,7 +311,7 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t p_qhd->qtd_overlay.next = (uint32_t) p_qtd; // link qtd to qhd // start transfer - LPC_USB[rhport]->ENDPTPRIME = BIT_( edpt_phy2pos(ep_idx) ) ; + LPC_USB[rhport]->ENDPTPRIME = BIT_( ep_idx2bit(ep_idx) ) ; return true; } @@ -412,7 +384,7 @@ void hal_dcd_isr(uint8_t rhport) { for(uint8_t ep_idx = 0; ep_idx < DCD_QHD_MAX; ep_idx++) { - if ( BIT_TEST_(edpt_complete, edpt_phy2pos(ep_idx)) ) + if ( BIT_TEST_(edpt_complete, ep_idx2bit(ep_idx)) ) { // 23.10.12.3 Failed QTD also get ENDPTCOMPLETE set dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; @@ -421,7 +393,7 @@ void hal_dcd_isr(uint8_t rhport) uint8_t result = p_qtd->halted ? DCD_XFER_STALLED : ( p_qtd->xact_err ||p_qtd->buffer_err ) ? DCD_XFER_FAILED : DCD_XFER_SUCCESS; - uint8_t ep_addr = edpt_phy2addr(ep_idx); + uint8_t ep_addr = (ep_idx/2) | ( (ep_idx & 0x01) ? TUSB_DIR_IN_MASK : 0 ); dcd_event_xfer_complete(rhport, ep_addr, p_qtd->expected_bytes - p_qtd->total_bytes, result, true); // only number of bytes in the IOC qtd } } diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.h b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.h index 1476c0d30..85334a34d 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.h +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.h @@ -54,7 +54,6 @@ //--------------------------------------------------------------------+ #define DCD_QHD_MAX 12 #define DCD_QTD_MAX 12 -#define DCD_QTD_PER_QHD_MAX 2 // maximum number of qtd that are linked into one queue head at a time #define QTD_NEXT_INVALID 0x01 @@ -91,7 +90,6 @@ enum { PORTSC_CURRENT_CONNECT_STATUS_MASK = BIT_(0), PORTSC_FORCE_PORT_RESUME_MASK = BIT_(6), PORTSC_SUSPEND_MASK = BIT_(7) - }; typedef struct @@ -118,8 +116,7 @@ typedef struct //------------- DCD Area -------------// uint16_t expected_bytes; - uint8_t used; - uint8_t reserved; + uint8_t reserved[2]; } dcd_qtd_t; TU_VERIFY_STATIC( sizeof(dcd_qtd_t) == 32, "size is not correct"); @@ -148,9 +145,7 @@ typedef struct /// Due to the fact QHD is 64 bytes aligned but occupies only 48 bytes /// thus there are 16 bytes padding free that we can make use of. //--------------------------------------------------------------------+ - volatile uint8_t list_qtd_idx[DCD_QTD_PER_QHD_MAX]; - - uint8_t reserved[16-DCD_QTD_PER_QHD_MAX]; + uint8_t reserved[16]; } dcd_qhd_t; TU_VERIFY_STATIC( sizeof(dcd_qhd_t) == 64, "size is not correct"); -- cgit v1.3.1 From e61e9d8b1b9f8e551b4560c61f707bbaeac1fc9a Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 23 Nov 2018 15:05:40 +0700 Subject: nrf5x add DCD_EVENT_UNPLUGGED event --- src/portable/nordic/nrf5x/hal_nrf5x.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c index 4ce512746..f40e904d7 100644 --- a/src/portable/nordic/nrf5x/hal_nrf5x.c +++ b/src/portable/nordic/nrf5x/hal_nrf5x.c @@ -61,6 +61,7 @@ enum { #endif #include "tusb_hal.h" +#include "device/dcd.h" /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM @@ -291,6 +292,8 @@ void tusb_hal_nrf_power_event (uint32_t event) nrf_usbd_disable(); hfclk_disable(); + + dcd_event_bus_signal(0, DCD_EVENT_UNPLUGGED, true); } break; -- cgit v1.3.1 From cb8782e5f28b4897e73520c91296d1ac7d71da81 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 23 Nov 2018 15:14:47 +0700 Subject: rename tusb_event_t to xfer_result_t --- examples/obsolete/device/src/keyboard_device_app.c | 2 +- examples/obsolete/device/src/mouse_device_app.c | 2 +- examples/obsolete/host/src/cdc_serial_host_app.c | 2 +- examples/obsolete/host/src/keyboard_host_app.c | 2 +- examples/obsolete/host/src/mouse_host_app.c | 2 +- examples/obsolete/host/src/msc_host_app.c | 2 +- src/class/cdc/cdc_device.c | 2 +- src/class/cdc/cdc_device.h | 2 +- src/class/cdc/cdc_host.c | 2 +- src/class/cdc/cdc_host.h | 6 +++--- src/class/cdc/cdc_rndis_host.c | 2 +- src/class/cdc/cdc_rndis_host.h | 2 +- src/class/custom/custom_device.c | 2 +- src/class/custom/custom_device.h | 2 +- src/class/custom/custom_host.c | 2 +- src/class/custom/custom_host.h | 2 +- src/class/hid/hid_device.c | 2 +- src/class/hid/hid_device.h | 2 +- src/class/hid/hid_host.c | 2 +- src/class/hid/hid_host.h | 12 ++++++------ src/class/msc/msc_device.c | 4 ++-- src/class/msc/msc_device.h | 2 +- src/class/msc/msc_host.c | 2 +- src/class/msc/msc_host.h | 6 +++--- src/common/tusb_types.h | 3 +-- src/device/usbd.c | 4 ++-- src/device/usbd_control.c | 2 +- src/host/ehci/ehci.c | 2 +- src/host/hub.c | 2 +- src/host/hub.h | 2 +- src/host/ohci/ohci.c | 2 +- src/host/usbh.c | 2 +- src/host/usbh.h | 2 +- src/host/usbh_hcd.h | 2 +- tests/lpc18xx_43xx/test/host/cdc/cdc_callback.h | 2 +- tests/lpc18xx_43xx/test/host/hid/hidh_callback.h | 4 ++-- tests/lpc18xx_43xx/test/host/msc/msch_callback.h | 2 +- 37 files changed, 49 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/examples/obsolete/device/src/keyboard_device_app.c b/examples/obsolete/device/src/keyboard_device_app.c index f6ef77c10..6c413464e 100644 --- a/examples/obsolete/device/src/keyboard_device_app.c +++ b/examples/obsolete/device/src/keyboard_device_app.c @@ -66,7 +66,7 @@ void keyboard_app_umount(uint8_t rhport) } -void tud_hid_keyboard_cb(uint8_t rhport, tusb_event_t event, uint32_t xferred_bytes) +void tud_hid_keyboard_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_bytes) { switch(event) { diff --git a/examples/obsolete/device/src/mouse_device_app.c b/examples/obsolete/device/src/mouse_device_app.c index db685daf6..4c4d322d7 100644 --- a/examples/obsolete/device/src/mouse_device_app.c +++ b/examples/obsolete/device/src/mouse_device_app.c @@ -66,7 +66,7 @@ void mouse_app_umount(uint8_t rhport) } -void tud_hid_mouse_cb(uint8_t rhport, tusb_event_t event, uint32_t xferred_bytes) +void tud_hid_mouse_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_bytes) { switch(event) { diff --git a/examples/obsolete/host/src/cdc_serial_host_app.c b/examples/obsolete/host/src/cdc_serial_host_app.c index d16a9b411..afb2b8937 100644 --- a/examples/obsolete/host/src/cdc_serial_host_app.c +++ b/examples/obsolete/host/src/cdc_serial_host_app.c @@ -75,7 +75,7 @@ void tuh_cdc_unmounted_cb(uint8_t dev_addr) } // invoked ISR context -void tuh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) +void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) { (void) dev_addr; // compiler warnings diff --git a/examples/obsolete/host/src/keyboard_host_app.c b/examples/obsolete/host/src/keyboard_host_app.c index 6d10e96e1..27d10b9e7 100644 --- a/examples/obsolete/host/src/keyboard_host_app.c +++ b/examples/obsolete/host/src/keyboard_host_app.c @@ -77,7 +77,7 @@ void tuh_hid_keyboard_unmounted_cb(uint8_t dev_addr) } // invoked ISR context -void tuh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event) +void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event) { switch(event) { diff --git a/examples/obsolete/host/src/mouse_host_app.c b/examples/obsolete/host/src/mouse_host_app.c index 563b911c2..05135693b 100644 --- a/examples/obsolete/host/src/mouse_host_app.c +++ b/examples/obsolete/host/src/mouse_host_app.c @@ -76,7 +76,7 @@ void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr) } // invoked ISR context -void tuh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event) +void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event) { switch(event) { diff --git a/examples/obsolete/host/src/msc_host_app.c b/examples/obsolete/host/src/msc_host_app.c index 3648cb94b..1cfe9ec60 100644 --- a/examples/obsolete/host/src/msc_host_app.c +++ b/examples/obsolete/host/src/msc_host_app.c @@ -129,7 +129,7 @@ void tuh_msc_unmounted_cb(uint8_t dev_addr) } // invoked ISR context -void tuh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes) +void tuh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes) { (void) dev_addr; (void) event; diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index a0abd42f6..b68a6a7ff 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -358,7 +358,7 @@ bool cdcd_control_request(uint8_t rhport, tusb_control_request_t const * request return true; } -tusb_error_t cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, uint32_t xferred_bytes) +tusb_error_t cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes) { // TODO Support multiple interfaces uint8_t const itf = 0; diff --git a/src/class/cdc/cdc_device.h b/src/class/cdc/cdc_device.h index 749351a54..ad1100e9c 100644 --- a/src/class/cdc/cdc_device.h +++ b/src/class/cdc/cdc_device.h @@ -116,7 +116,7 @@ void cdcd_init (void); tusb_error_t cdcd_open (uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool cdcd_control_request (uint8_t rhport, tusb_control_request_t const * p_request); bool cdcd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); -tusb_error_t cdcd_xfer_cb (uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes); +tusb_error_t cdcd_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes); void cdcd_reset (uint8_t rhport); #endif diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index af2e2c444..0a3661878 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -221,7 +221,7 @@ tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_ OSAL_SUBTASK_END } -void cdch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) +void cdch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes) { tuh_cdc_xfer_isr( pipe_hdl.dev_addr, event, get_app_pipeid(pipe_hdl), xferred_bytes ); } diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h index b3e995470..8cfe6e5b7 100644 --- a/src/class/cdc/cdc_host.h +++ b/src/class/cdc/cdc_host.h @@ -118,7 +118,7 @@ void tuh_cdc_unmounted_cb(uint8_t dev_addr); /** \brief Callback function that is invoked when an transferring event occurred * \param[in] dev_addr Address of device - * \param[in] event an value from \ref tusb_event_t + * \param[in] event an value from \ref xfer_result_t * \param[in] pipe_id value from \ref cdc_pipeid_t indicate the pipe * \param[in] xferred_bytes Number of bytes transferred via USB bus * \note event can be one of following @@ -127,7 +127,7 @@ void tuh_cdc_unmounted_cb(uint8_t dev_addr); * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * \note */ -void tuh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes); +void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes); /// @} // group CDC_Serial_Host /// @} @@ -151,7 +151,7 @@ extern cdch_data_t cdch_data[CFG_TUSB_HOST_DEVICE_MAX]; // TODO consider to move void cdch_init(void); tusb_error_t cdch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void cdch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); +void cdch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void cdch_close(uint8_t dev_addr); #endif diff --git a/src/class/cdc/cdc_rndis_host.c b/src/class/cdc/cdc_rndis_host.c index 42722fd0d..89ea3b32f 100644 --- a/src/class/cdc/cdc_rndis_host.c +++ b/src/class/cdc/cdc_rndis_host.c @@ -224,7 +224,7 @@ tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc) OSAL_SUBTASK_END } -void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) +void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes) { if ( pipehandle_is_equal(pipe_hdl, p_cdc->pipe_notification) ) { diff --git a/src/class/cdc/cdc_rndis_host.h b/src/class/cdc/cdc_rndis_host.h index c4597daa8..3b92d3f23 100644 --- a/src/class/cdc/cdc_rndis_host.h +++ b/src/class/cdc/cdc_rndis_host.h @@ -65,7 +65,7 @@ typedef struct { void rndish_init(void); tusb_error_t rndish_open_subtask(uint8_t dev_addr, cdch_data_t *p_cdc) ATTR_WARN_UNUSED_RESULT; -void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); +void rndish_xfer_isr(cdch_data_t *p_cdc, pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void rndish_close(uint8_t dev_addr); #endif diff --git a/src/class/custom/custom_device.c b/src/class/custom/custom_device.c index cc440fc7e..194963c17 100644 --- a/src/class/custom/custom_device.c +++ b/src/class/custom/custom_device.c @@ -94,7 +94,7 @@ bool cusd_control_request(uint8_t rhport, tusb_control_request_t const * p_reque return false; } -tusb_error_t cusd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes) +tusb_error_t cusd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes) { return TUSB_ERROR_NONE; } diff --git a/src/class/custom/custom_device.h b/src/class/custom/custom_device.h index 704c4127b..0a8f05e7d 100644 --- a/src/class/custom/custom_device.h +++ b/src/class/custom/custom_device.h @@ -66,7 +66,7 @@ void cusd_init(void); tusb_error_t cusd_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool cusd_control_request_st(uint8_t rhport, tusb_control_request_t const * p_request); bool cusd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); -tusb_error_t cusd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes); +tusb_error_t cusd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes); void cusd_reset(uint8_t rhport); #endif diff --git a/src/class/custom/custom_host.c b/src/class/custom/custom_host.c index 329012fda..9f0b70afb 100644 --- a/src/class/custom/custom_host.c +++ b/src/class/custom/custom_host.c @@ -131,7 +131,7 @@ tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_ return TUSB_ERROR_NONE; } -void cush_isr(pipe_handle_t pipe_hdl, tusb_event_t event) +void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event) { } diff --git a/src/class/custom/custom_host.h b/src/class/custom/custom_host.h index 2bf3a8d3c..5f9c25dda 100644 --- a/src/class/custom/custom_host.h +++ b/src/class/custom/custom_host.h @@ -73,7 +73,7 @@ tusb_error_t tusbh_custom_write(uint8_t dev_addr, uint16_t vendor_id, uint16_t p void cush_init(void); tusb_error_t cush_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void cush_isr(pipe_handle_t pipe_hdl, tusb_event_t event); +void cush_isr(pipe_handle_t pipe_hdl, xfer_result_t event); void cush_close(uint8_t dev_addr); #endif diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index cece06ea0..f1ecec3c7 100644 --- a/src/class/hid/hid_device.c +++ b/src/class/hid/hid_device.c @@ -510,7 +510,7 @@ bool hidd_control_request_complete(uint8_t rhport, tusb_control_request_t const return true; } -tusb_error_t hidd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes) +tusb_error_t hidd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes) { // nothing to do return TUSB_ERROR_NONE; diff --git a/src/class/hid/hid_device.h b/src/class/hid/hid_device.h index 357c71082..7aff7f34d 100644 --- a/src/class/hid/hid_device.h +++ b/src/class/hid/hid_device.h @@ -380,7 +380,7 @@ void hidd_init(void); tusb_error_t hidd_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool hidd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); bool hidd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); -tusb_error_t hidd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes); +tusb_error_t hidd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes); void hidd_reset(uint8_t rhport); #endif diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index 7129562c5..6aa0748df 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -251,7 +251,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_ OSAL_SUBTASK_END } -void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) +void hidh_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes) { (void) xferred_bytes; // TODO may need to use this para later diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index 3acc05bf7..fb10a614f 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -93,14 +93,14 @@ tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void * p_report) /*A //------------- Application Callback -------------// /** \brief Callback function that is invoked when an transferring event occurred * \param[in] dev_addr Address of device - * \param[in] event an value from \ref tusb_event_t + * \param[in] event an value from \ref xfer_result_t * \note event can be one of following * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * \note Application should schedule the next report by calling \ref tuh_hid_keyboard_get_report within this callback */ -void tuh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event); +void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event); /** \brief Callback function that will be invoked when a device with Keyboard interface is mounted * \param[in] dev_addr Address of newly mounted device @@ -158,14 +158,14 @@ tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void* p_report) /*ATTR_ //------------- Application Callback -------------// /** \brief Callback function that is invoked when an transferring event occurred * \param[in] dev_addr Address of device - * \param[in] event an value from \ref tusb_event_t + * \param[in] event an value from \ref xfer_result_t * \note event can be one of following * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * \note Application should schedule the next report by calling \ref tuh_hid_mouse_get_report within this callback */ -void tuh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event); +void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event); /** \brief Callback function that will be invoked when a device with Mouse interface is mounted * \param[in] dev_addr Address of newly mounted device @@ -199,7 +199,7 @@ tusb_interface_status_t tuh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_U tusb_interface_status_t tuh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; //------------- Application Callback -------------// -void tuh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event); +void tuh_hid_generic_isr(uint8_t dev_addr, xfer_result_t event); /** @} */ // Generic_Host /** @} */ // ClassDriver_HID_Generic @@ -217,7 +217,7 @@ typedef struct { void hidh_init(void); tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); +void hidh_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void hidh_close(uint8_t dev_addr); #endif diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 78e6d0a6b..1f4252f22 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -324,7 +324,7 @@ int32_t proc_builtin_scsi(msc_cbw_t const * p_cbw, uint8_t* buffer, uint32_t buf return ret; } -tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, uint32_t xferred_bytes) +tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes) { mscd_interface_t* p_msc = &_mscd_itf; msc_cbw_t const * p_cbw = &p_msc->cbw; @@ -337,7 +337,7 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, tusb_event_t event, u // Complete IN while waiting for CMD is usually Status of previous SCSI op, ignore it if(ep_addr != p_msc->ep_out) return TUSB_ERROR_NONE; - TU_ASSERT( event == DCD_XFER_SUCCESS && + TU_ASSERT( ((uint8_t) event) == DCD_XFER_SUCCESS && xferred_bytes == sizeof(msc_cbw_t) && p_cbw->signature == MSC_CBW_SIGNATURE, TUSB_ERROR_INVALID_PARA ); p_csw->signature = MSC_CSW_SIGNATURE; diff --git a/src/class/msc/msc_device.h b/src/class/msc/msc_device.h index c1c51255a..c4476f56f 100644 --- a/src/class/msc/msc_device.h +++ b/src/class/msc/msc_device.h @@ -180,7 +180,7 @@ void mscd_init(void); tusb_error_t mscd_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length); bool mscd_control_request(uint8_t rhport, tusb_control_request_t const * p_request); bool mscd_control_request_complete (uint8_t rhport, tusb_control_request_t const * p_request); -tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, tusb_event_t event, uint32_t xferred_bytes); +tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t edpt_addr, xfer_result_t event, uint32_t xferred_bytes); void mscd_reset(uint8_t rhport); #endif diff --git a/src/class/msc/msc_host.c b/src/class/msc/msc_host.c index bd3e92de1..baef7ff44 100644 --- a/src/class/msc/msc_host.c +++ b/src/class/msc/msc_host.c @@ -397,7 +397,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_ OSAL_SUBTASK_END } -void msch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) +void msch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes) { if ( pipehandle_is_equal(pipe_hdl, msch_data[pipe_hdl.dev_addr-1].bulk_in) ) { diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index 6d95cfe34..0afe5c515 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -171,7 +171,7 @@ void tuh_msc_unmounted_cb(uint8_t dev_addr); /** \brief Callback function that is invoked when an transferring event occurred * \param[in] dev_addr Address of device - * \param[in] event an value from \ref tusb_event_t + * \param[in] event an value from \ref xfer_result_t * \param[in] xferred_bytes Number of bytes transferred via USB bus * \note event can be one of following * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. @@ -179,7 +179,7 @@ void tuh_msc_unmounted_cb(uint8_t dev_addr); * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. * \note */ -void tuh_msc_isr(uint8_t dev_addr, tusb_event_t event, uint32_t xferred_bytes); +void tuh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes); //--------------------------------------------------------------------+ @@ -205,7 +205,7 @@ typedef struct { void msch_init(void); tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void msch_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); +void msch_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void msch_close(uint8_t dev_addr); #endif diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 32632cd90..7b5268d4f 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -197,11 +197,10 @@ typedef enum typedef enum { - TUSB_EVENT_NONE = 0, TUSB_EVENT_XFER_COMPLETE, TUSB_EVENT_XFER_ERROR, TUSB_EVENT_XFER_STALLED, -}tusb_event_t; +}xfer_result_t; enum { diff --git a/src/device/usbd.c b/src/device/usbd.c index f39605987..710eba553 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -92,7 +92,7 @@ typedef struct { tusb_error_t (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length); bool (* control_request ) (uint8_t rhport, tusb_control_request_t const * request); bool (* control_request_complete ) (uint8_t rhport, tusb_control_request_t const * request); - tusb_error_t (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, tusb_event_t, uint32_t); + tusb_error_t (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t, uint32_t); void (* sof ) (uint8_t rhport); void (* reset ) (uint8_t); } usbd_class_driver_t; @@ -174,7 +174,7 @@ static bool process_set_config(uint8_t rhport, uint8_t config_number); static void const* get_descriptor(tusb_control_request_t const * p_request, uint16_t* desc_len); void usbd_control_reset (uint8_t rhport); -bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, tusb_event_t event, uint32_t xferred_bytes); +bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes); void usbd_control_set_complete_callback( bool (*fp) (uint8_t, tusb_control_request_t const * ) ); //--------------------------------------------------------------------+ diff --git a/src/device/usbd_control.c b/src/device/usbd_control.c index 33de6d064..31d74edf0 100644 --- a/src/device/usbd_control.c +++ b/src/device/usbd_control.c @@ -126,7 +126,7 @@ bool usbd_control_xfer(uint8_t rhport, tusb_control_request_t const * request, v } // callback when a transaction complete on DATA stage of control endpoint -bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, tusb_event_t event, uint32_t xferred_bytes) +bool usbd_control_xfer_cb (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes) { if ( _control_state.request.bmRequestType_bit.direction == TUSB_DIR_OUT ) { diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index b3d897537..2fc99ffcd 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -638,7 +638,7 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd) qhd_has_xact_error(p_qhd) ) { // current qhd has error in transaction tusb_xfer_type_t const xfer_type = qhd_get_xfer_type(p_qhd); - tusb_event_t error_event; + xfer_result_t error_event; // no error bits are set, endpoint is halted due to STALL error_event = qhd_has_xact_error(p_qhd) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_STALLED; diff --git a/src/host/hub.c b/src/host/hub.c index e4c08c9d1..9635bcc0b 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -209,7 +209,7 @@ tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_i } // is the response of interrupt endpoint polling -void hub_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes) +void hub_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes) { (void) xferred_bytes; // TODO can be more than 1 for hub with lots of ports diff --git a/src/host/hub.h b/src/host/hub.h index 67c02f2e3..9376a2698 100644 --- a/src/host/hub.h +++ b/src/host/hub.h @@ -196,7 +196,7 @@ tusb_error_t hub_status_pipe_queue(uint8_t dev_addr); void hub_init(void); tusb_error_t hub_open_subtask(uint8_t dev_addr, tusb_desc_interface_t const *p_interface_desc, uint16_t *p_length) ATTR_WARN_UNUSED_RESULT; -void hub_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes); +void hub_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes); void hub_close(uint8_t dev_addr); #endif diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index f058f8348..58738a236 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -617,7 +617,7 @@ static void done_queue_isr(uint8_t hostid) // TODO check if td_head is iso td //------------- Non ISO transfer -------------// ohci_gtd_t * const p_qtd = (ohci_gtd_t *) td_head; - tusb_event_t const event = (p_qtd->condition_code == OHCI_CCODE_NO_ERROR) ? TUSB_EVENT_XFER_COMPLETE : + xfer_result_t const event = (p_qtd->condition_code == OHCI_CCODE_NO_ERROR) ? TUSB_EVENT_XFER_COMPLETE : (p_qtd->condition_code == OHCI_CCODE_STALL) ? TUSB_EVENT_XFER_STALLED : TUSB_EVENT_XFER_ERROR; p_qtd->used = 0; // free TD diff --git a/src/host/usbh.c b/src/host/usbh.c index 196a45ee7..ed21bf3da 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -256,7 +256,7 @@ static inline uint8_t std_class_code_to_index(uint8_t std_class_code) // USBH-HCD ISR/Callback API //--------------------------------------------------------------------+ // interrupt caused by a TD (with IOC=1) in pipe of class class_code -void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event, uint32_t xferred_bytes) +void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, xfer_result_t event, uint32_t xferred_bytes) { uint8_t class_index = std_class_code_to_index(class_code); if (TUSB_XFER_CONTROL == pipe_hdl.xfer_type) diff --git a/src/host/usbh.h b/src/host/usbh.h index 5aaeb4186..22fdef162 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -66,7 +66,7 @@ typedef enum tusb_interface_status_{ typedef struct { void (* const init) (void); tusb_error_t (* const open_subtask)(uint8_t, tusb_desc_interface_t const *, uint16_t*); - void (* const isr) (pipe_handle_t, tusb_event_t, uint32_t); + void (* const isr) (pipe_handle_t, xfer_result_t, uint32_t); void (* const close) (uint8_t); } host_class_driver_t; //--------------------------------------------------------------------+ diff --git a/src/host/usbh_hcd.h b/src/host/usbh_hcd.h index 1c2c4ad0b..f6b72273a 100644 --- a/src/host/usbh_hcd.h +++ b/src/host/usbh_hcd.h @@ -101,7 +101,7 @@ extern usbh_device_info_t usbh_devices[CFG_TUSB_HOST_DEVICE_MAX+1]; // including //--------------------------------------------------------------------+ // callback from HCD ISR //--------------------------------------------------------------------+ -void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event, uint32_t xferred_bytes); +void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, xfer_result_t event, uint32_t xferred_bytes); void usbh_hcd_rhport_plugged_isr(uint8_t hostid); void usbh_hcd_rhport_unplugged_isr(uint8_t hostid); diff --git a/tests/lpc18xx_43xx/test/host/cdc/cdc_callback.h b/tests/lpc18xx_43xx/test/host/cdc/cdc_callback.h index b1aea64b0..1eb608b91 100644 --- a/tests/lpc18xx_43xx/test/host/cdc/cdc_callback.h +++ b/tests/lpc18xx_43xx/test/host/cdc/cdc_callback.h @@ -55,7 +55,7 @@ void tusbh_cdc_mounted_cb(uint8_t dev_addr); void tusbh_cdc_unmounted_cb(uint8_t 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 tusbh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes); void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr); void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr); diff --git a/tests/lpc18xx_43xx/test/host/hid/hidh_callback.h b/tests/lpc18xx_43xx/test/host/hid/hidh_callback.h index 4b76bd3cd..b0945c1d1 100644 --- a/tests/lpc18xx_43xx/test/host/hid/hidh_callback.h +++ b/tests/lpc18xx_43xx/test/host/hid/hidh_callback.h @@ -59,11 +59,11 @@ #include "common/common.h" //------------- hidh -------------// -void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event); +void tusbh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event); void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr); void tusbh_hid_keyboard_unmounted_cb(uint8_t dev_addr); -void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event); +void tusbh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event); void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr); void tusbh_hid_mouse_unmounted_cb(uint8_t dev_addr); diff --git a/tests/lpc18xx_43xx/test/host/msc/msch_callback.h b/tests/lpc18xx_43xx/test/host/msc/msch_callback.h index 26b301a00..275245bec 100644 --- a/tests/lpc18xx_43xx/test/host/msc/msch_callback.h +++ b/tests/lpc18xx_43xx/test/host/msc/msch_callback.h @@ -54,7 +54,7 @@ void tusbh_msc_mounted_cb(uint8_t dev_addr); 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 tusbh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes); #ifdef __cplusplus -- cgit v1.3.1 From a619ff88a36e4b841cb5901135b1811b06c3c843 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 23 Nov 2018 15:17:43 +0700 Subject: rename xfer complete enum --- examples/obsolete/device/src/keyboard_device_app.c | 6 +++--- examples/obsolete/device/src/mouse_device_app.c | 6 +++--- examples/obsolete/host/src/cdc_serial_host_app.c | 6 +++--- examples/obsolete/host/src/keyboard_host_app.c | 4 ++-- examples/obsolete/host/src/mouse_host_app.c | 4 ++-- src/class/cdc/cdc_host.h | 6 +++--- src/class/hid/hid_host.h | 12 ++++++------ src/class/msc/msc_host.h | 6 +++--- src/common/tusb_types.h | 6 +++--- src/host/ehci/ehci.c | 6 +++--- src/host/hub.c | 2 +- src/host/ohci/ohci.c | 10 +++++----- src/host/usbh.c | 8 ++++---- src/osal/osal_none.h | 6 ++++-- tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c | 12 ++++++------ tests/lpc18xx_43xx/test/host/cdc/test_cdc_rndis_host.c | 2 +- tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c | 2 +- tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c | 6 +++--- tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c | 6 +++--- tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c | 4 ++-- tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c | 8 ++++---- tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c | 2 +- 22 files changed, 66 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/examples/obsolete/device/src/keyboard_device_app.c b/examples/obsolete/device/src/keyboard_device_app.c index 6c413464e..5e14c56c9 100644 --- a/examples/obsolete/device/src/keyboard_device_app.c +++ b/examples/obsolete/device/src/keyboard_device_app.c @@ -70,9 +70,9 @@ void tud_hid_keyboard_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_b { switch(event) { - case TUSB_EVENT_XFER_COMPLETE: - case TUSB_EVENT_XFER_ERROR: - case TUSB_EVENT_XFER_STALLED: + case XFER_RESULT_SUCCESS: + case XFER_RESULT_FAILED: + case XFER_RESULT_STALLED: default: break; } } diff --git a/examples/obsolete/device/src/mouse_device_app.c b/examples/obsolete/device/src/mouse_device_app.c index 4c4d322d7..6869f1a05 100644 --- a/examples/obsolete/device/src/mouse_device_app.c +++ b/examples/obsolete/device/src/mouse_device_app.c @@ -70,9 +70,9 @@ void tud_hid_mouse_cb(uint8_t rhport, xfer_result_t event, uint32_t xferred_byte { switch(event) { - case TUSB_EVENT_XFER_COMPLETE: - case TUSB_EVENT_XFER_ERROR: - case TUSB_EVENT_XFER_STALLED: + case XFER_RESULT_SUCCESS: + case XFER_RESULT_FAILED: + case XFER_RESULT_STALLED: default: break; } } diff --git a/examples/obsolete/host/src/cdc_serial_host_app.c b/examples/obsolete/host/src/cdc_serial_host_app.c index afb2b8937..85604dcdf 100644 --- a/examples/obsolete/host/src/cdc_serial_host_app.c +++ b/examples/obsolete/host/src/cdc_serial_host_app.c @@ -84,17 +84,17 @@ void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_i case CDC_PIPE_DATA_IN: switch(event) { - case TUSB_EVENT_XFER_COMPLETE: + case XFER_RESULT_SUCCESS: received_bytes = xferred_bytes; osal_semaphore_post(sem_hdl); // notify main task break; - case TUSB_EVENT_XFER_ERROR: + case XFER_RESULT_FAILED: received_bytes = 0; // ignore tuh_cdc_receive(dev_addr, serial_in_buffer, SERIAL_BUFFER_SIZE, true); // waiting for next data break; - case TUSB_EVENT_XFER_STALLED: + case XFER_RESULT_STALLED: default : break; } diff --git a/examples/obsolete/host/src/keyboard_host_app.c b/examples/obsolete/host/src/keyboard_host_app.c index 27d10b9e7..fd51548c3 100644 --- a/examples/obsolete/host/src/keyboard_host_app.c +++ b/examples/obsolete/host/src/keyboard_host_app.c @@ -81,12 +81,12 @@ void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event) { switch(event) { - case TUSB_EVENT_XFER_COMPLETE: + case XFER_RESULT_SUCCESS: osal_queue_send(queue_kbd_hdl, &usb_keyboard_report); tuh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); break; - case TUSB_EVENT_XFER_ERROR: + case XFER_RESULT_FAILED: tuh_hid_keyboard_get_report(dev_addr, (uint8_t*) &usb_keyboard_report); // ignore & continue break; diff --git a/examples/obsolete/host/src/mouse_host_app.c b/examples/obsolete/host/src/mouse_host_app.c index 05135693b..819c2b290 100644 --- a/examples/obsolete/host/src/mouse_host_app.c +++ b/examples/obsolete/host/src/mouse_host_app.c @@ -80,12 +80,12 @@ void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event) { switch(event) { - case TUSB_EVENT_XFER_COMPLETE: + case XFER_RESULT_SUCCESS: osal_queue_send(queue_mouse_hdl, &usb_mouse_report); (void) tuh_hid_mouse_get_report(dev_addr, (uint8_t*) &usb_mouse_report); break; - case TUSB_EVENT_XFER_ERROR: + case XFER_RESULT_FAILED: (void) tuh_hid_mouse_get_report(dev_addr, (uint8_t*) &usb_mouse_report); // ignore & continue break; diff --git a/src/class/cdc/cdc_host.h b/src/class/cdc/cdc_host.h index 8cfe6e5b7..0b863bb61 100644 --- a/src/class/cdc/cdc_host.h +++ b/src/class/cdc/cdc_host.h @@ -122,9 +122,9 @@ void tuh_cdc_unmounted_cb(uint8_t dev_addr); * \param[in] pipe_id value from \ref cdc_pipeid_t indicate the pipe * \param[in] xferred_bytes Number of bytes transferred via USB bus * \note event can be one of following - * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. - * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. - * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. + * - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully. + * - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error. + * - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device. * \note */ void tuh_cdc_xfer_isr(uint8_t dev_addr, xfer_result_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes); diff --git a/src/class/hid/hid_host.h b/src/class/hid/hid_host.h index fb10a614f..cb0230e8a 100644 --- a/src/class/hid/hid_host.h +++ b/src/class/hid/hid_host.h @@ -95,9 +95,9 @@ tusb_error_t tuh_hid_keyboard_get_report(uint8_t dev_addr, void * p_report) /*A * \param[in] dev_addr Address of device * \param[in] event an value from \ref xfer_result_t * \note event can be one of following - * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. - * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. - * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. + * - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully. + * - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error. + * - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device. * \note Application should schedule the next report by calling \ref tuh_hid_keyboard_get_report within this callback */ void tuh_hid_keyboard_isr(uint8_t dev_addr, xfer_result_t event); @@ -160,9 +160,9 @@ tusb_error_t tuh_hid_mouse_get_report(uint8_t dev_addr, void* p_report) /*ATTR_ * \param[in] dev_addr Address of device * \param[in] event an value from \ref xfer_result_t * \note event can be one of following - * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. - * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. - * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. + * - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully. + * - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error. + * - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device. * \note Application should schedule the next report by calling \ref tuh_hid_mouse_get_report within this callback */ void tuh_hid_mouse_isr(uint8_t dev_addr, xfer_result_t event); diff --git a/src/class/msc/msc_host.h b/src/class/msc/msc_host.h index 0afe5c515..a408bbeaf 100644 --- a/src/class/msc/msc_host.h +++ b/src/class/msc/msc_host.h @@ -174,9 +174,9 @@ void tuh_msc_unmounted_cb(uint8_t dev_addr); * \param[in] event an value from \ref xfer_result_t * \param[in] xferred_bytes Number of bytes transferred via USB bus * \note event can be one of following - * - TUSB_EVENT_XFER_COMPLETE : previously scheduled transfer completes successfully. - * - TUSB_EVENT_XFER_ERROR : previously scheduled transfer encountered a transaction error. - * - TUSB_EVENT_XFER_STALLED : previously scheduled transfer is stalled by device. + * - XFER_RESULT_SUCCESS : previously scheduled transfer completes successfully. + * - XFER_RESULT_FAILED : previously scheduled transfer encountered a transaction error. + * - XFER_RESULT_STALLED : previously scheduled transfer is stalled by device. * \note */ void tuh_msc_isr(uint8_t dev_addr, xfer_result_t event, uint32_t xferred_bytes); diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 7b5268d4f..9c3c21b88 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -197,9 +197,9 @@ typedef enum typedef enum { - TUSB_EVENT_XFER_COMPLETE, - TUSB_EVENT_XFER_ERROR, - TUSB_EVENT_XFER_STALLED, + XFER_RESULT_SUCCESS, + XFER_RESULT_FAILED, + XFER_RESULT_STALLED, }xfer_result_t; enum diff --git a/src/host/ehci/ehci.c b/src/host/ehci/ehci.c index 2fc99ffcd..27808d59b 100644 --- a/src/host/ehci/ehci.c +++ b/src/host/ehci/ehci.c @@ -570,7 +570,7 @@ static void qhd_xfer_complete_isr(ehci_qhd_t * p_qhd) if (is_ioc) // end of request { // call USBH callback usbh_xfer_isr( qhd_create_pipe_handle(p_qhd, xfer_type), - p_qhd->class_code, TUSB_EVENT_XFER_COMPLETE, + p_qhd->class_code, XFER_RESULT_SUCCESS, p_qhd->total_xferred_bytes - (xfer_type == TUSB_XFER_CONTROL ? 8 : 0) ); // subtract setup packet size if control, p_qhd->total_xferred_bytes = 0; } @@ -641,12 +641,12 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd) xfer_result_t error_event; // no error bits are set, endpoint is halted due to STALL - error_event = qhd_has_xact_error(p_qhd) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_STALLED; + error_event = qhd_has_xact_error(p_qhd) ? XFER_RESULT_FAILED : XFER_RESULT_STALLED; p_qhd->total_xferred_bytes += p_qhd->p_qtd_list_head->expected_bytes - p_qhd->p_qtd_list_head->total_bytes; -// if ( TUSB_EVENT_XFER_ERROR == error_event ) TU_BREAKPOINT(); // TODO skip unplugged device +// if ( XFER_RESULT_FAILED == error_event ) TU_BREAKPOINT(); // TODO skip unplugged device p_qhd->p_qtd_list_head->used = 0; // free QTD qtd_remove_1st_from_qhd(p_qhd); diff --git a/src/host/hub.c b/src/host/hub.c index 9635bcc0b..55c8597ad 100644 --- a/src/host/hub.c +++ b/src/host/hub.c @@ -215,7 +215,7 @@ void hub_isr(pipe_handle_t pipe_hdl, xfer_result_t event, uint32_t xferred_bytes usbh_hub_t * p_hub = &hub_data[pipe_hdl.dev_addr-1]; - if ( event == TUSB_EVENT_XFER_COMPLETE ) + if ( event == XFER_RESULT_SUCCESS ) { for (uint8_t port=1; port <= p_hub->port_number; port++) { // TODO HUB ignore bit0 hub_status_change diff --git a/src/host/ohci/ohci.c b/src/host/ohci/ohci.c index 58738a236..91d9b6243 100644 --- a/src/host/ohci/ohci.c +++ b/src/host/ohci/ohci.c @@ -617,11 +617,11 @@ static void done_queue_isr(uint8_t hostid) // TODO check if td_head is iso td //------------- Non ISO transfer -------------// ohci_gtd_t * const p_qtd = (ohci_gtd_t *) td_head; - xfer_result_t const event = (p_qtd->condition_code == OHCI_CCODE_NO_ERROR) ? TUSB_EVENT_XFER_COMPLETE : - (p_qtd->condition_code == OHCI_CCODE_STALL) ? TUSB_EVENT_XFER_STALLED : TUSB_EVENT_XFER_ERROR; + xfer_result_t const event = (p_qtd->condition_code == OHCI_CCODE_NO_ERROR) ? XFER_RESULT_SUCCESS : + (p_qtd->condition_code == OHCI_CCODE_STALL) ? XFER_RESULT_STALLED : XFER_RESULT_FAILED; p_qtd->used = 0; // free TD - if ( (p_qtd->delay_interrupt == OHCI_INT_ON_COMPLETE_YES) || (event != TUSB_EVENT_XFER_COMPLETE) ) + if ( (p_qtd->delay_interrupt == OHCI_INT_ON_COMPLETE_YES) || (event != XFER_RESULT_SUCCESS) ) { ohci_ed_t * const p_ed = gtd_get_ed(p_qtd); @@ -634,11 +634,11 @@ static void done_queue_isr(uint8_t hostid) // --> HC will not process Control list (due to service ratio when Bulk list not empty) // To walk-around this, the halted ED will have TailP = HeadP (empty list condition), when clearing halt // the TailP must be set back to NULL for processing remaining TDs - if ((event != TUSB_EVENT_XFER_COMPLETE)) + if ((event != XFER_RESULT_SUCCESS)) { p_ed->td_tail.address &= 0x0Ful; p_ed->td_tail.address |= tu_align16(p_ed->td_head.address); // mark halted EP as empty queue - if ( event == TUSB_EVENT_XFER_STALLED ) p_ed->is_stalled = 1; + if ( event == XFER_RESULT_STALLED ) p_ed->is_stalled = 1; } pipe_handle_t pipe_hdl = diff --git a/src/host/usbh.c b/src/host/usbh.c index ed21bf3da..a0aab3b96 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -199,7 +199,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, #ifndef _TEST_ usbh_devices[dev_addr].control.pipe_status = 0; #else - usbh_devices[dev_addr].control.pipe_status = TUSB_EVENT_XFER_COMPLETE; // in Test project, mark as complete immediately + usbh_devices[dev_addr].control.pipe_status = XFER_RESULT_SUCCESS; // in Test project, mark as complete immediately #endif error = hcd_pipe_control_xfer(dev_addr, &usbh_devices[dev_addr].control.request, data); @@ -207,11 +207,11 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, uint8_t bmRequestType, osal_mutex_release(usbh_devices[dev_addr].control.mutex_hdl); STASK_ASSERT_ERR(error); - if (TUSB_EVENT_XFER_STALLED == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED); - if (TUSB_EVENT_XFER_ERROR == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED); + if (XFER_RESULT_STALLED == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_STALLED); + if (XFER_RESULT_FAILED == usbh_devices[dev_addr].control.pipe_status) STASK_RETURN(TUSB_ERROR_USBH_XFER_FAILED); // STASK_ASSERT_HDLR(TUSB_ERROR_NONE == error && -// TUSB_EVENT_XFER_COMPLETE == usbh_devices[dev_addr].control.pipe_status, +// XFER_RESULT_SUCCESS == usbh_devices[dev_addr].control.pipe_status, // tuh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) ); OSAL_SUBTASK_END diff --git a/src/osal/osal_none.h b/src/osal/osal_none.h index 46930aeda..b21c3332a 100644 --- a/src/osal/osal_none.h +++ b/src/osal/osal_none.h @@ -156,10 +156,12 @@ static inline void osal_queue_reset(osal_queue_t const queue_hdl) static inline bool osal_queue_receive(osal_queue_t const queue_hdl, void* data) { // osal none return immediately without blocking + // extern void tusb_hal_int_disable(uint8_t rhport); + // extern void tusb_hal_int_enable(uint8_t rhport); - // tusb_hal_int_disable_all(); +// tusb_hal_int_disable(0); bool rc = tu_fifo_read(queue_hdl, data); - // tusb_hal_int_enable_all(); +// tusb_hal_int_enable(0); return rc; } diff --git a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c index 5077eea93..12dce0528 100644 --- a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c +++ b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_host.c @@ -251,10 +251,10 @@ void test_cdc_xfer_notification_pipe(void) cdch_data[dev_addr-1].pipe_out = pipe_out; cdch_data[dev_addr-1].pipe_in = pipe_in; - tusbh_cdc_xfer_isr_Expect(dev_addr, TUSB_EVENT_XFER_COMPLETE, CDC_PIPE_NOTIFICATION, 10); + tusbh_cdc_xfer_isr_Expect(dev_addr, XFER_RESULT_SUCCESS, CDC_PIPE_NOTIFICATION, 10); //------------- CUT -------------// - cdch_isr(pipe_notification, TUSB_EVENT_XFER_COMPLETE, 10); + cdch_isr(pipe_notification, XFER_RESULT_SUCCESS, 10); } void test_cdc_xfer_pipe_out(void) @@ -267,10 +267,10 @@ void test_cdc_xfer_pipe_out(void) cdch_data[dev_addr-1].pipe_out = pipe_out; cdch_data[dev_addr-1].pipe_in = pipe_in; - tusbh_cdc_xfer_isr_Expect(dev_addr, TUSB_EVENT_XFER_ERROR, CDC_PIPE_DATA_OUT, 20); + tusbh_cdc_xfer_isr_Expect(dev_addr, XFER_RESULT_FAILED, CDC_PIPE_DATA_OUT, 20); //------------- CUT -------------// - cdch_isr(pipe_out, TUSB_EVENT_XFER_ERROR, 20); + cdch_isr(pipe_out, XFER_RESULT_FAILED, 20); } void test_cdc_xfer_pipe_in(void) @@ -283,8 +283,8 @@ void test_cdc_xfer_pipe_in(void) cdch_data[dev_addr-1].pipe_out = pipe_out; cdch_data[dev_addr-1].pipe_in = pipe_in; - tusbh_cdc_xfer_isr_Expect(dev_addr, TUSB_EVENT_XFER_STALLED, CDC_PIPE_DATA_IN, 0); + tusbh_cdc_xfer_isr_Expect(dev_addr, XFER_RESULT_STALLED, CDC_PIPE_DATA_IN, 0); //------------- CUT -------------// - cdch_isr(pipe_in, TUSB_EVENT_XFER_STALLED, 0); + cdch_isr(pipe_in, XFER_RESULT_STALLED, 0); } diff --git a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_rndis_host.c b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_rndis_host.c index a493c3b79..86d6c2890 100644 --- a/tests/lpc18xx_43xx/test/host/cdc/test_cdc_rndis_host.c +++ b/tests/lpc18xx_43xx/test/host/cdc/test_cdc_rndis_host.c @@ -188,7 +188,7 @@ static tusb_error_t stub_pipe_notification_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[0] = 1; // response available - cdch_isr(pipe_hdl, TUSB_EVENT_XFER_COMPLETE, 8); + cdch_isr(pipe_hdl, XFER_RESULT_SUCCESS, 8); return TUSB_ERROR_NONE; } diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c index 2e9e29fdc..c4037c596 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_bulk_xfer.c @@ -208,7 +208,7 @@ void test_bulk_xfer_complete_isr(void) ehci_qtd_t* p_head = p_qhd_bulk->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_bulk->p_qtd_list_tail; - usbh_xfer_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, TUSB_EVENT_XFER_COMPLETE, sizeof(data2)+sizeof(xfer_data)); + usbh_xfer_isr_Expect(pipe_hdl_bulk, TUSB_CLASS_MSC, XFER_RESULT_SUCCESS, sizeof(data2)+sizeof(xfer_data)); //------------- Code Under Test -------------// ehci_controller_run(hostid); diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c index ffd7ffb67..4f8cdb4c8 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_control_xfer.c @@ -228,7 +228,7 @@ void test_control_xfer_complete_isr(void) { TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); - usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_COMPLETE, 18); + usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, XFER_RESULT_SUCCESS, 18); //------------- Code Under TEST -------------// ehci_controller_run(hostid); @@ -247,7 +247,7 @@ void test_control_xfer_error_isr(void) { TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); - usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_ERROR, 0); + usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, XFER_RESULT_FAILED, 0); //------------- Code Under TEST -------------// ehci_controller_run_error(hostid); @@ -266,7 +266,7 @@ void test_control_xfer_error_stall(void) { TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr, &request_get_dev_desc, xfer_data) ); - usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, TUSB_EVENT_XFER_STALLED, 0); + usbh_xfer_isr_Expect(((pipe_handle_t){.dev_addr = dev_addr}), 0, XFER_RESULT_STALLED, 0); //------------- Code Under TEST -------------// ehci_controller_run_stall(hostid); diff --git a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c index 827db2897..bf7ad352a 100644 --- a/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c +++ b/tests/lpc18xx_43xx/test/host/ehci/test_pipe_interrupt_xfer.c @@ -201,7 +201,7 @@ void test_interrupt_xfer_complete_isr_interval_less_than_1ms(void) TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, data2, sizeof(data2), true) ); - usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_COMPLETE, sizeof(xfer_data)+sizeof(data2)); + usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, XFER_RESULT_SUCCESS, sizeof(xfer_data)+sizeof(data2)); ehci_qtd_t* p_head = p_qhd_interrupt->p_qtd_list_head; ehci_qtd_t* p_tail = p_qhd_interrupt->p_qtd_list_tail; @@ -242,7 +242,7 @@ void test_interrupt_xfer_error_isr(void) { TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), true) ); - usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_ERROR, 0); + usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, XFER_RESULT_FAILED, 0); //------------- Code Under TEST -------------// ehci_controller_run_error(hostid); @@ -254,7 +254,7 @@ void test_interrupt_xfer_error_stall(void) { TEST_ASSERT_STATUS( hcd_pipe_xfer(pipe_hdl_interrupt, xfer_data, sizeof(xfer_data), true) ); - usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, TUSB_EVENT_XFER_STALLED, 0); + usbh_xfer_isr_Expect(pipe_hdl_interrupt, TUSB_CLASS_HID, XFER_RESULT_STALLED, 0); //------------- Code Under TEST -------------// ehci_controller_run_stall(hostid); diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c b/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c index b3b49c172..de3581423 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hidh_keyboard.c @@ -216,10 +216,10 @@ void test_keyboard_get_ok() void test_keyboard_isr_event_complete(void) { - tusbh_hid_keyboard_isr_Expect(dev_addr, TUSB_EVENT_XFER_COMPLETE); + tusbh_hid_keyboard_isr_Expect(dev_addr, XFER_RESULT_SUCCESS); //------------- Code Under TEST -------------// - hidh_isr(p_hidh_kbd->pipe_hdl, TUSB_EVENT_XFER_COMPLETE, 8); + hidh_isr(p_hidh_kbd->pipe_hdl, XFER_RESULT_SUCCESS, 8); // tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); // TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_keyboard_status(dev_addr)); diff --git a/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c b/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c index b1a3558e6..541c2caef 100644 --- a/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c +++ b/tests/lpc18xx_43xx/test/host/hid/test_hidh_mouse.c @@ -189,10 +189,10 @@ void test_mouse_get_ok() void test_mouse_isr_event_xfer_complete(void) { - tusbh_hid_mouse_isr_Expect(dev_addr, TUSB_EVENT_XFER_COMPLETE); + tusbh_hid_mouse_isr_Expect(dev_addr, XFER_RESULT_SUCCESS); //------------- Code Under TEST -------------// - hidh_isr(p_hidh_mouse->pipe_hdl, TUSB_EVENT_XFER_COMPLETE, 8); + hidh_isr(p_hidh_mouse->pipe_hdl, XFER_RESULT_SUCCESS, 8); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); // TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_mouse_status(dev_addr)); @@ -200,10 +200,10 @@ void test_mouse_isr_event_xfer_complete(void) void test_mouse_isr_event_xfer_error(void) { - tusbh_hid_mouse_isr_Expect(dev_addr, TUSB_EVENT_XFER_ERROR); + tusbh_hid_mouse_isr_Expect(dev_addr, XFER_RESULT_FAILED); //------------- Code Under TEST -------------// - hidh_isr(p_hidh_mouse->pipe_hdl, TUSB_EVENT_XFER_ERROR, 0); + hidh_isr(p_hidh_mouse->pipe_hdl, XFER_RESULT_FAILED, 0); tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED); // TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_ERROR, tusbh_hid_mouse_status(dev_addr)); diff --git a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c b/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c index a85c3c48a..eba3fbcc3 100644 --- a/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c +++ b/tests/lpc18xx_43xx/test/host/usbh/test_enum_task.c @@ -181,7 +181,7 @@ tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * usbh_xfer_isr( (pipe_handle_t) { .dev_addr = (num_call > 1 ? 1 : 0), .xfer_type = TUSB_XFER_CONTROL }, - 0, TUSB_EVENT_XFER_COMPLETE, 0); + 0, XFER_RESULT_SUCCESS, 0); return TUSB_ERROR_NONE; } -- cgit v1.3.1 From f196b24dce1531eae8e049bbe35df79996fe4155 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 23 Nov 2018 15:22:46 +0700 Subject: rename DCD_XFER_SUCCESS to XFER_RESULT_SUCCESS --- src/class/msc/msc_device.c | 8 ++++---- src/device/dcd.h | 7 ------- src/device/usbd.c | 2 +- src/portable/microchip/samd21/dcd_samd21.c | 4 ++-- src/portable/microchip/samd51/dcd_samd51.c | 2 +- src/portable/nordic/nrf5x/dcd_nrf5x.c | 6 +++--- src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c | 8 ++++---- 7 files changed, 15 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 1f4252f22..88f8da6db 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -337,7 +337,7 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, // Complete IN while waiting for CMD is usually Status of previous SCSI op, ignore it if(ep_addr != p_msc->ep_out) return TUSB_ERROR_NONE; - TU_ASSERT( ((uint8_t) event) == DCD_XFER_SUCCESS && + TU_ASSERT( event == XFER_RESULT_SUCCESS && xferred_bytes == sizeof(msc_cbw_t) && p_cbw->signature == MSC_CBW_SIGNATURE, TUSB_ERROR_INVALID_PARA ); p_csw->signature = MSC_CSW_SIGNATURE; @@ -467,7 +467,7 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, } // simulate an transfer complete with adjusted parameters --> this driver callback will fired again - dcd_event_xfer_complete(rhport, p_msc->ep_out, xferred_bytes-nbytes, DCD_XFER_SUCCESS, false); + dcd_event_xfer_complete(rhport, p_msc->ep_out, xferred_bytes-nbytes, XFER_RESULT_SUCCESS, false); return TUSB_ERROR_NONE; // skip the rest } @@ -516,7 +516,7 @@ tusb_error_t mscd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t event, if ( dcd_edpt_stalled(rhport, p_msc->ep_in) || dcd_edpt_stalled(rhport, p_msc->ep_out) ) { // simulate an transfer complete with adjusted parameters --> this driver callback will fired again - dcd_event_xfer_complete(rhport, p_msc->ep_out, 0, DCD_XFER_SUCCESS, false); + dcd_event_xfer_complete(rhport, p_msc->ep_out, 0, XFER_RESULT_SUCCESS, false); } else { @@ -578,7 +578,7 @@ static void proc_read10_cmd(uint8_t rhport, mscd_interface_t* p_msc) else if ( nbytes == 0 ) { // zero means not ready -> simulate an transfer complete so that this driver callback will fired again - dcd_event_xfer_complete(rhport, p_msc->ep_in, 0, DCD_XFER_SUCCESS, false); + dcd_event_xfer_complete(rhport, p_msc->ep_in, 0, XFER_RESULT_SUCCESS, false); } else { diff --git a/src/device/dcd.h b/src/device/dcd.h index f07bda2d3..db84df839 100644 --- a/src/device/dcd.h +++ b/src/device/dcd.h @@ -49,13 +49,6 @@ extern "C" { #endif -enum -{ - DCD_XFER_SUCCESS = 0, - DCD_XFER_FAILED, - DCD_XFER_STALLED -}; - typedef enum { DCD_EVENT_BUS_RESET = 1, diff --git a/src/device/usbd.c b/src/device/usbd.c index 710eba553..8c7e588e0 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -581,7 +581,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr) if ( 0 == edpt_number(event->xfer_complete.ep_addr) && event->xfer_complete.len == 0) break; osal_queue_send(_usbd_q, event, in_isr); - TU_ASSERT(event->xfer_complete.result == DCD_XFER_SUCCESS,); + TU_ASSERT(event->xfer_complete.result == XFER_RESULT_SUCCESS,); break; default: break; diff --git a/src/portable/microchip/samd21/dcd_samd21.c b/src/portable/microchip/samd21/dcd_samd21.c index b31db547d..c6101f312 100644 --- a/src/portable/microchip/samd21/dcd_samd21.c +++ b/src/portable/microchip/samd21/dcd_samd21.c @@ -275,7 +275,7 @@ void maybe_transfer_complete(void) { total_transfer_size = bank->PCKSIZE.bit.BYTE_COUNT; uint8_t ep_addr = epnum | TUSB_DIR_IN_MASK; - dcd_event_xfer_complete(0, ep_addr, total_transfer_size, DCD_XFER_SUCCESS, true); + dcd_event_xfer_complete(0, ep_addr, total_transfer_size, XFER_RESULT_SUCCESS, true); } // Handle OUT completions @@ -286,7 +286,7 @@ void maybe_transfer_complete(void) { total_transfer_size = bank->PCKSIZE.bit.BYTE_COUNT; uint8_t ep_addr = epnum; - dcd_event_xfer_complete(0, ep_addr, total_transfer_size, DCD_XFER_SUCCESS, true); + dcd_event_xfer_complete(0, ep_addr, total_transfer_size, XFER_RESULT_SUCCESS, true); } // just finished status stage (total size = 0), prepare for next setup packet diff --git a/src/portable/microchip/samd51/dcd_samd51.c b/src/portable/microchip/samd51/dcd_samd51.c index 6fff12ba7..6e8053e59 100644 --- a/src/portable/microchip/samd51/dcd_samd51.c +++ b/src/portable/microchip/samd51/dcd_samd51.c @@ -304,7 +304,7 @@ void transfer_complete(uint8_t direction) { if (direction == TUSB_DIR_IN) { ep_addr |= TUSB_DIR_IN_MASK; } - dcd_event_xfer_complete(0, ep_addr, total_transfer_size, DCD_XFER_SUCCESS, true); + dcd_event_xfer_complete(0, ep_addr, total_transfer_size, XFER_RESULT_SUCCESS, true); // just finished status stage (total size = 0), prepare for next setup packet if (epnum == 0 && total_transfer_size == 0) { diff --git a/src/portable/nordic/nrf5x/dcd_nrf5x.c b/src/portable/nordic/nrf5x/dcd_nrf5x.c index 816ff62ae..4fb88689c 100644 --- a/src/portable/nordic/nrf5x/dcd_nrf5x.c +++ b/src/portable/nordic/nrf5x/dcd_nrf5x.c @@ -261,7 +261,7 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t edpt_dma_end(); // The nRF doesn't interrupt on status transmit so we queue up a success response. - dcd_event_xfer_complete(0, ep_addr, 0, DCD_XFER_SUCCESS, false); + dcd_event_xfer_complete(0, ep_addr, 0, XFER_RESULT_SUCCESS, false); } else if ( dir == TUSB_DIR_OUT ) { @@ -459,7 +459,7 @@ void USBD_IRQHandler(void) xfer->total_len = xfer->actual_len; // BULK/INT OUT complete - dcd_event_xfer_complete(0, epnum, xfer->actual_len, DCD_XFER_SUCCESS, true); + dcd_event_xfer_complete(0, epnum, xfer->actual_len, XFER_RESULT_SUCCESS, true); } } @@ -494,7 +494,7 @@ void USBD_IRQHandler(void) } else { // Bulk/Int IN complete - dcd_event_xfer_complete(0, epnum | TUSB_DIR_IN_MASK, xfer->actual_len, DCD_XFER_SUCCESS, true); + dcd_event_xfer_complete(0, epnum | TUSB_DIR_IN_MASK, xfer->actual_len, XFER_RESULT_SUCCESS, true); } } } diff --git a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c index 274ebc032..2f83f4203 100644 --- a/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c +++ b/src/portable/nxp/lpc43xx_lpc18xx/dcd_lpc43xx.c @@ -311,9 +311,9 @@ bool dcd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t p_qhd->qtd_overlay.next = (uint32_t) p_qtd; // link qtd to qhd // start transfer - LPC_USB[rhport]->ENDPTPRIME = BIT_( ep_idx2bit(ep_idx) ) ; + LPC_USB[rhport]->ENDPTPRIME = BIT_( ep_idx2bit(ep_idx) ) ; - return true; + return true; } @@ -390,8 +390,8 @@ void hal_dcd_isr(uint8_t rhport) dcd_qhd_t * p_qhd = &dcd_data_ptr[rhport]->qhd[ep_idx]; dcd_qtd_t * p_qtd = &dcd_data_ptr[rhport]->qtd[ep_idx]; - uint8_t result = p_qtd->halted ? DCD_XFER_STALLED : - ( p_qtd->xact_err ||p_qtd->buffer_err ) ? DCD_XFER_FAILED : DCD_XFER_SUCCESS; + uint8_t result = p_qtd->halted ? XFER_RESULT_STALLED : + ( p_qtd->xact_err ||p_qtd->buffer_err ) ? XFER_RESULT_FAILED : XFER_RESULT_SUCCESS; uint8_t ep_addr = (ep_idx/2) | ( (ep_idx & 0x01) ? TUSB_DIR_IN_MASK : 0 ); dcd_event_xfer_complete(rhport, ep_addr, p_qtd->expected_bytes - p_qtd->total_bytes, result, true); // only number of bytes in the IOC qtd -- cgit v1.3.1 From 394a22ecf7760cce630a8186260f1c79901af934 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 23 Nov 2018 15:25:25 +0700 Subject: remove pragma GCC diagnostic --- src/class/cdc/cdc.h | 6 ------ src/class/hid/hid.h | 6 ------ src/class/msc/msc.h | 8 +------- src/common/tusb_types.h | 6 ------ 4 files changed, 1 insertion(+), 25 deletions(-) (limited to 'src') diff --git a/src/class/cdc/cdc.h b/src/class/cdc/cdc.h index afac8379d..d07c62429 100644 --- a/src/class/cdc/cdc.h +++ b/src/class/cdc/cdc.h @@ -50,10 +50,6 @@ extern "C" { #endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpacked" -#pragma GCC diagnostic ignored "-Wattributes" - /** \defgroup ClassDriver_CDC_Common Common Definitions * @{ */ @@ -406,8 +402,6 @@ typedef struct ATTR_PACKED TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct"); -#pragma GCC diagnostic pop - /** @} */ #ifdef __cplusplus diff --git a/src/class/hid/hid.h b/src/class/hid/hid.h index 0008e47fb..8bfede2da 100644 --- a/src/class/hid/hid.h +++ b/src/class/hid/hid.h @@ -49,10 +49,6 @@ extern "C" { #endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpacked" -#pragma GCC diagnostic ignored "-Wattributes" - //--------------------------------------------------------------------+ // Common Definitions //--------------------------------------------------------------------+ @@ -613,8 +609,6 @@ enum HID_USAGE_CONSUMER_AC_PAN = 0x0238, }; -#pragma GCC diagnostic pop - #ifdef __cplusplus } #endif diff --git a/src/class/msc/msc.h b/src/class/msc/msc.h index e7c32b303..10a73bb1c 100644 --- a/src/class/msc/msc.h +++ b/src/class/msc/msc.h @@ -46,16 +46,12 @@ #ifndef _TUSB_MSC_H_ #define _TUSB_MSC_H_ -#include +#include "common/tusb_common.h" #ifdef __cplusplus extern "C" { #endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpacked" -#pragma GCC diagnostic ignored "-Wattributes" - //--------------------------------------------------------------------+ // Mass Storage Class Constant //--------------------------------------------------------------------+ @@ -396,8 +392,6 @@ typedef struct ATTR_PACKED TU_VERIFY_STATIC(sizeof(scsi_read10_t) == 10, "size is not correct"); TU_VERIFY_STATIC(sizeof(scsi_write10_t) == 10, "size is not correct"); -#pragma GCC diagnostic pop - #ifdef __cplusplus } #endif diff --git a/src/common/tusb_types.h b/src/common/tusb_types.h index 9c3c21b88..b11481b18 100644 --- a/src/common/tusb_types.h +++ b/src/common/tusb_types.h @@ -51,10 +51,6 @@ extern "C" { #endif -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpacked" -#pragma GCC diagnostic ignored "-Wattributes" - /*------------------------------------------------------------------*/ /* CONSTANTS *------------------------------------------------------------------*/ @@ -427,8 +423,6 @@ static inline uint8_t descriptor_len(uint8_t const p_desc[]) // Convert comma-separated string to descriptor unicode format #define TUD_DESC_STRCONV( ... ) (const uint16_t[]) { TUD_DESC_STR_HEADER(VA_ARGS_NUM_(__VA_ARGS__)), __VA_ARGS__ } -#pragma GCC diagnostic pop - #ifdef __cplusplus } #endif -- cgit v1.3.1