diff options
| author | hathach <[email protected]> | 2013-09-27 22:38:23 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2013-09-27 22:38:23 +0700 |
| commit | eb1a101667f183db6781d5f7f73f360a508b13bc (patch) | |
| tree | 953c6b09a13eb3b32101662bb7391c00e1092a7a /tinyusb | |
| parent | 26f75d6cac91f0525627ca2086175007614632f8 (diff) | |
house keeping
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/class/hid.h | 2 | ||||
| -rw-r--r-- | tinyusb/class/msc_host.c | 30 | ||||
| -rw-r--r-- | tinyusb/class/msc_host.h | 6 | ||||
| -rw-r--r-- | tinyusb/core/std_descriptors.h | 18 | ||||
| -rw-r--r-- | tinyusb/host/ehci/ehci.c | 16 | ||||
| -rw-r--r-- | tinyusb/host/ehci/ehci.h | 10 |
6 files changed, 46 insertions, 36 deletions
diff --git a/tinyusb/class/hid.h b/tinyusb/class/hid.h index 3c550cd3e..7d8d1b047 100644 --- a/tinyusb/class/hid.h +++ b/tinyusb/class/hid.h @@ -84,7 +84,7 @@ enum { HID_REQUEST_CONTROL_SET_PROTOCOL = 0x0b }; -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */ uint8_t bDescriptorType; /**< Constant name specifying type of HID descriptor. */ diff --git a/tinyusb/class/msc_host.c b/tinyusb/class/msc_host.c index 25518a757..26beeae13 100644 --- a/tinyusb/class/msc_host.c +++ b/tinyusb/class/msc_host.c @@ -74,19 +74,33 @@ bool tusbh_msc_is_mounted(uint8_t dev_addr) msch_data[dev_addr-1].is_initialized; } +bool tusbh_msc_is_busy(uint8_t dev_addr) +{ + return msch_data[dev_addr-1].is_initialized && + hcd_pipe_is_busy(msch_data[dev_addr-1].bulk_in); +} + +bool tusbh_msc_is_failed(uint8_t dev_addr) +{ + return msch_data[dev_addr-1].is_initialized && + hcd_pipe_is_error(msch_data[dev_addr-1].bulk_in); +} + +// TODO tusbh_msc_is_stalled + uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr) { - return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].vendor_id : NULL; + return msch_data[dev_addr-1].is_initialized ? msch_data[dev_addr-1].vendor_id : NULL; } uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr) { - return tusbh_msc_is_mounted(dev_addr) ? msch_data[dev_addr-1].product_id : NULL; + return msch_data[dev_addr-1].is_initialized ? msch_data[dev_addr-1].product_id : NULL; } tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size) { - if ( !tusbh_msc_is_mounted(dev_addr) ) return TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED; + if ( !msch_data[dev_addr-1].is_initialized ) return TUSB_ERROR_MSCH_DEVICE_NOT_MOUNTED; ASSERT(p_last_lba != NULL && p_block_size != NULL, TUSB_ERROR_INVALID_PARA); (*p_last_lba) = msch_data[dev_addr-1].last_lba; @@ -95,16 +109,6 @@ tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint return TUSB_ERROR_NONE; } -tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr) -{ - if ( !tusbh_msc_is_mounted(dev_addr) ) return TUSB_INTERFACE_STATUS_INVALID_PARA; - - if ( hcd_pipe_is_busy(msch_data[dev_addr-1].bulk_in) ) return TUSB_INTERFACE_STATUS_BUSY; - if ( hcd_pipe_is_stalled(msch_data[dev_addr-1].bulk_in) ) return TUSB_INTERFACE_STATUS_ERROR; - - return TUSB_INTERFACE_STATUS_READY; -} - static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun) ATTR_ALWAYS_INLINE; static inline void msc_cbw_add_signature(msc_cmd_block_wrapper_t *p_cbw, uint8_t lun) { diff --git a/tinyusb/class/msc_host.h b/tinyusb/class/msc_host.h index b51b9f515..83409f859 100644 --- a/tinyusb/class/msc_host.h +++ b/tinyusb/class/msc_host.h @@ -59,7 +59,9 @@ // MASS STORAGE Application API //--------------------------------------------------------------------+ bool tusbh_msc_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; -tusb_interface_status_t tusbh_msc_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT; +bool tusbh_msc_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; +bool tusbh_msc_is_failed(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT; + uint8_t const* tusbh_msc_get_vendor_name(uint8_t dev_addr); uint8_t const* tusbh_msc_get_product_name(uint8_t dev_addr); tusb_error_t tusbh_msc_get_capacity(uint8_t dev_addr, uint32_t* p_last_lba, uint32_t* p_block_size); @@ -95,7 +97,7 @@ typedef struct { uint16_t block_size; uint32_t last_lba; // last logical block address - bool is_initialized; + volatile bool is_initialized; uint8_t vendor_id[8]; uint8_t product_id[16]; diff --git a/tinyusb/core/std_descriptors.h b/tinyusb/core/std_descriptors.h index 249d31491..0d0d3ef27 100644 --- a/tinyusb/core/std_descriptors.h +++ b/tinyusb/core/std_descriptors.h @@ -61,7 +61,7 @@ // STANDARD DESCRIPTORS //--------------------------------------------------------------------+ /// USB Standard Device Descriptor (section 9.6.1, table 9-8) -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of this descriptor in bytes. uint8_t bDescriptorType ; ///< DEVICE Descriptor Type. uint16_t bcdUSB ; ///< BUSB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). This field identifies the release of the USB Specification with which the device and its descriptors are compliant. @@ -82,7 +82,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_device_t; /// USB Standard Configuration Descriptor (section 9.6.1 table 9-10) */ -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< CONFIGURATION Descriptor Type uint16_t wTotalLength ; ///< Total length of data returned for this configuration. Includes the combined length of all descriptors (configuration, interface, endpoint, and class- or vendor-specific) returned for this configuration. @@ -95,7 +95,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_configuration_t; /// USB Standard Interface Descriptor (section 9.6.1 table 9-12) -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< INTERFACE Descriptor Type @@ -109,13 +109,13 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_interface_t; /// USB Standard Endpoint Descriptor (section 9.6.1 table 9-13) -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< ENDPOINT Descriptor Type uint8_t bEndpointAddress ; ///< The address of the endpoint on the USB device described by this descriptor. The address is encoded as follows: \n Bit 3...0: The endpoint number \n Bit 6...4: Reserved, reset to zero \n Bit 7: Direction, ignored for control endpoints 0 = OUT endpoint 1 = IN endpoint. - ATTR_PREPACKED struct ATTR_PACKED { + ATTR_PACKED_STRUCT(struct) { uint8_t xfer : 2; uint8_t sync : 2; uint8_t usage : 2; @@ -132,7 +132,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_endpoint_t; /// USB Other Speed Configuration Descriptor (section 9.6.1 table 9-11) -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type uint16_t wTotalLength ; ///< Total length of data returned @@ -145,7 +145,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_other_speed_t; /// USB Device Qualifier Descriptor (section 9.6.1 table 9-9) -typedef ATTR_PREPACKED struct ATTR_PACKED { +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Device Qualifier Type uint16_t bcdUSB ; ///< USB specification version number (e.g., 0200H for V2.00) @@ -159,7 +159,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED { } tusb_descriptor_device_qualifier_t; /// USB Interface Association Descriptor (IAD ECN) -typedef ATTR_PREPACKED struct ATTR_PACKED +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of descriptor uint8_t bDescriptorType ; ///< Other_speed_Configuration Type @@ -175,7 +175,7 @@ typedef ATTR_PREPACKED struct ATTR_PACKED } tusb_descriptor_interface_association_t; /// USB Header Descriptor -typedef ATTR_PREPACKED struct ATTR_PACKED +typedef ATTR_PACKED_STRUCT(struct) { uint8_t bLength ; ///< Size of this descriptor in bytes uint8_t bDescriptorType ; ///< Descriptor Type diff --git a/tinyusb/host/ehci/ehci.c b/tinyusb/host/ehci/ehci.c index 684051917..f3fe6614c 100644 --- a/tinyusb/host/ehci/ehci.c +++ b/tinyusb/host/ehci/ehci.c @@ -430,7 +430,7 @@ tusb_error_t hcd_pipe_queue_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t total_bytes, bool int_on_complete) { - hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes); + ASSERT_STATUS ( hcd_pipe_queue_xfer(pipe_hdl, buffer, total_bytes) ); ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle(pipe_hdl); @@ -481,9 +481,15 @@ bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl) return !p_qhd->qtd_overlay.halted && (p_qhd->p_qtd_list_head != NULL); } -bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl) +bool hcd_pipe_is_error(pipe_handle_t pipe_hdl) { ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl ); + return p_qhd->qtd_overlay.halted; +} + +bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl) +{ // TODO to be remove + ehci_qhd_t *p_qhd = qhd_get_from_pipe_handle( pipe_hdl ); return (p_qhd->p_qtd_list_head == NULL); } @@ -679,13 +685,11 @@ static void qhd_xfer_error_isr(ehci_qhd_t * p_qhd) p_qhd->qtd_overlay.alternate.terminate = 1; p_qhd->qtd_overlay.halted = 0; - #if 0 // no need to mark control qtds as not used - ehci_qtd_t *p_setup = get_control_qtds(dev_addr); + ehci_qtd_t *p_setup = get_control_qtds(p_qhd->device_address); ehci_qtd_t *p_data = p_setup + 1; ehci_qtd_t *p_status = p_setup + 2; - p_setup->used = p_data->used = p_status = 0; - #endif + p_setup->used = p_data->used = p_status->used = 0; } // call USBH callback diff --git a/tinyusb/host/ehci/ehci.h b/tinyusb/host/ehci/ehci.h index ec4b40302..ea1d6bdf6 100644 --- a/tinyusb/host/ehci/ehci.h +++ b/tinyusb/host/ehci/ehci.h @@ -126,9 +126,9 @@ typedef struct { union{ ehci_link_t alternate; struct { - uint32_t : 5; - uint32_t used : 1; - uint32_t : 10; + uint32_t : 5; + uint32_t used : 1; + uint32_t : 10; uint32_t expected_bytes : 16; }; }; @@ -203,8 +203,8 @@ typedef struct { uint8_t interval_ms; // polling interval in frames (or milisecond) uint8_t reserved; - ehci_qtd_t *p_qtd_list_head; // head of the scheduled TD list - ehci_qtd_t *p_qtd_list_tail; // tail of the scheduled TD list + ehci_qtd_t * volatile p_qtd_list_head; // head of the scheduled TD list + ehci_qtd_t * volatile p_qtd_list_tail; // tail of the scheduled TD list }ATTR_ALIGNED(32) ehci_qhd_t; /// Highspeed Isochronous Transfer Descriptor (section 3.3) |
