diff options
| author | hathach <[email protected]> | 2014-03-23 17:33:58 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2014-03-23 17:33:58 +0700 |
| commit | a8d32d81b37274642179b6ebafcf501eb57fe75c (patch) | |
| tree | 44485a94686a7073634a4078854648769f22a739 /tinyusb | |
| parent | 5d5aa9b2137f23ab01597cc279fb7995aad8bc4c (diff) | |
tested with IAR & keil for device ea4357, fix some warnings
Diffstat (limited to 'tinyusb')
| -rw-r--r-- | tinyusb/device/dcd_lpc43xx.c | 105 | ||||
| -rw-r--r-- | tinyusb/device/dcd_lpc_11uxx_13uxx.c | 3 |
2 files changed, 56 insertions, 52 deletions
diff --git a/tinyusb/device/dcd_lpc43xx.c b/tinyusb/device/dcd_lpc43xx.c index 036c65a64..e33b7fe09 100644 --- a/tinyusb/device/dcd_lpc43xx.c +++ b/tinyusb/device/dcd_lpc43xx.c @@ -286,11 +286,13 @@ tusb_error_t dcd_init(void) //--------------------------------------------------------------------+
// PIPE HELPER
//--------------------------------------------------------------------+
+#if 0
static inline uint8_t edpt_pos2phy(uint8_t pos) ATTR_CONST ATTR_ALWAYS_INLINE;
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) ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint8_t edpt_phy2pos(uint8_t physical_endpoint)
@@ -546,29 +548,30 @@ void dcd_isr(uint8_t coreid) {
LPC_USB0_Type* const lpc_usb = LPC_USB[coreid];
- uint32_t const int_status = lpc_usb->USBSTS_D & lpc_usb->USBINTR_D;
- lpc_usb->USBSTS_D = int_status; // Acknowledge handled interrupt
+ uint32_t const int_enable = lpc_usb->USBINTR_D;
+ uint32_t const int_status = lpc_usb->USBSTS_D & int_enable;
+ lpc_usb->USBSTS_D = int_status; // Acknowledge handled interrupt
- if (int_status == 0) return; // disabled interrupt sources
+ if (int_status == 0) return;// disabled interrupt sources
- if (int_status & INT_MASK_RESET)
- {
- bus_reset(coreid);
- usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESET);
- }
+ if (int_status & INT_MASK_RESET)
+ {
+ bus_reset(coreid);
+ usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESET);
+ }
- if (int_status & INT_MASK_SUSPEND)
- {
- if (lpc_usb->PORTSC1_D & PORTSC_SUSPEND_MASK)
- { // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
- if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
- {
- usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_SUSPENDED);
- }
- }
- }
+ if (int_status & INT_MASK_SUSPEND)
+ {
+ if (lpc_usb->PORTSC1_D & PORTSC_SUSPEND_MASK)
+ { // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
+ if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
+ {
+ usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_SUSPENDED);
+ }
+ }
+ }
- // TODO disconnection does not generate interrupt !!!!!!
+ // TODO disconnection does not generate interrupt !!!!!!
// if (int_status & INT_MASK_PORT_CHANGE)
// {
// if ( !(lpc_usb->PORTSC1_D & PORTSC_CURRENT_CONNECT_STATUS_MASK) )
@@ -577,47 +580,47 @@ void dcd_isr(uint8_t coreid) // }
// }
- if (int_status & INT_MASK_USB)
- {
- uint32_t const edpt_complete = lpc_usb->ENDPTCOMPLETE;
- lpc_usb->ENDPTCOMPLETE = edpt_complete; // acknowledge
+ if (int_status & INT_MASK_USB)
+ {
+ uint32_t const edpt_complete = lpc_usb->ENDPTCOMPLETE;
+ lpc_usb->ENDPTCOMPLETE = edpt_complete; // acknowledge
- dcd_data_t* const p_dcd = dcd_data_ptr[coreid];
+ dcd_data_t* const p_dcd = dcd_data_ptr[coreid];
- //------------- Set up Received -------------//
- if (lpc_usb->ENDPTSETUPSTAT)
- { // 23.10.10.2 Operational model for setup transfers
- tusb_control_request_t control_request = p_dcd->qhd[0].setup_request;
- lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT; // acknowledge
+ //------------- Set up Received -------------//
+ if (lpc_usb->ENDPTSETUPSTAT)
+ { // 23.10.10.2 Operational model for setup transfers
+ tusb_control_request_t control_request = p_dcd->qhd[0].setup_request;
+ lpc_usb->ENDPTSETUPSTAT = lpc_usb->ENDPTSETUPSTAT;// acknowledge
- usbd_setup_received_isr(coreid, &control_request);
- }
- //------------- Control Request Completed -------------//
- else if ( edpt_complete & 0x03 )
- { // only either of Endpoint Control is set with interrupt on complete flag
- endpoint_handle_t edpt_hdl =
+ usbd_setup_received_isr(coreid, &control_request);
+ }
+ //------------- Control Request Completed -------------//
+ else if ( edpt_complete & 0x03 )
+ { // only either of Endpoint Control is set with interrupt on complete flag
+ endpoint_handle_t edpt_hdl =
{
- .coreid = coreid,
- .index = 0,
- .class_code = 0
+ .coreid = coreid,
+ .index = 0,
+ .class_code = 0
};
- dcd_qtd_t volatile * const p_qtd = &p_dcd->qhd[ (edpt_complete & BIT_(0)) ? 0 : 1 ].qtd_overlay;
- tusb_event_t event = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_COMPLETE;
+ dcd_qtd_t volatile * const p_qtd = &p_dcd->qhd[ (edpt_complete & BIT_(0)) ? 0 : 1 ].qtd_overlay;
+ tusb_event_t event = ( p_qtd->xact_err || p_qtd->halted || p_qtd->buffer_err ) ? TUSB_EVENT_XFER_ERROR : TUSB_EVENT_XFER_COMPLETE;
- usbd_xfer_isr(edpt_hdl, event, 0); // TODO xferred bytes for control xfer is not needed yet !!!!
- }
+ usbd_xfer_isr(edpt_hdl, event, 0); // TODO xferred bytes for control xfer is not needed yet !!!!
+ }
- //------------- Transfer Complete -------------//
- if ( edpt_complete & ~(0x03UL) )
- {
- xfer_complete_isr(coreid, edpt_complete);
- }
- }
+ //------------- Transfer Complete -------------//
+ if ( edpt_complete & ~(0x03UL) )
+ {
+ xfer_complete_isr(coreid, edpt_complete);
+ }
+ }
- if (int_status & INT_MASK_SOF) { }
- if (int_status & INT_MASK_NAK) { }
- if (int_status & INT_MASK_ERROR) ASSERT(false, VOID_RETURN);
+ if (int_status & INT_MASK_SOF) {}
+ if (int_status & INT_MASK_NAK) {}
+ if (int_status & INT_MASK_ERROR) ASSERT(false, VOID_RETURN);
}
//--------------------------------------------------------------------+
diff --git a/tinyusb/device/dcd_lpc_11uxx_13uxx.c b/tinyusb/device/dcd_lpc_11uxx_13uxx.c index 35c4f47fb..4692779d4 100644 --- a/tinyusb/device/dcd_lpc_11uxx_13uxx.c +++ b/tinyusb/device/dcd_lpc_11uxx_13uxx.c @@ -297,7 +297,8 @@ void dcd_isr(uint8_t coreid) {
(void) coreid;
- uint32_t const int_status = LPC_USB->INTSTAT & LPC_USB->INTEN;
+ uint32_t const int_enable = LPC_USB->INTEN;
+ uint32_t const int_status = LPC_USB->INTSTAT & int_enable;
LPC_USB->INTSTAT = int_status; // Acknowledge handled interrupt
if (int_status == 0) return;
|
