diff options
| author | hathach <[email protected]> | 2019-01-29 20:13:17 +0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2019-01-29 20:13:17 +0700 |
| commit | 29b49199beb8e9b5fead83e5cd36105f8746f1d7 (patch) | |
| tree | 5fec0508a84fd7b75b21b16b13ef6181d97eaaa5 /src | |
| parent | bd5325612620209e7964f10817a57f916d3bc13f (diff) | |
| parent | 1a84f5da5496e7ea410e9023253b30933c207159 (diff) | |
Merge pull request #34 from hathach/develop
add tusb_inited(), better compatible with nrf SD
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/cdc/cdc_device.c | 2 | ||||
| -rw-r--r-- | src/class/hid/hid_device.c | 2 | ||||
| -rw-r--r-- | src/class/msc/msc_device.c | 2 | ||||
| -rw-r--r-- | src/device/usbd.c | 5 | ||||
| -rw-r--r-- | src/host/usbh.c | 3 | ||||
| -rw-r--r-- | src/portable/nordic/nrf5x/hal_nrf5x.c | 14 | ||||
| -rw-r--r-- | src/tusb.c | 5 | ||||
| -rw-r--r-- | src/tusb.h | 3 |
8 files changed, 20 insertions, 16 deletions
diff --git a/src/class/cdc/cdc_device.c b/src/class/cdc/cdc_device.c index b8678c1c4..0cfb2377b 100644 --- a/src/class/cdc/cdc_device.c +++ b/src/class/cdc/cdc_device.c @@ -85,7 +85,7 @@ typedef struct //--------------------------------------------------------------------+
// INTERNAL OBJECT & FUNCTION DECLARATION
//--------------------------------------------------------------------+
-CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
+CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC] = { { 0 } };
//--------------------------------------------------------------------+
// APPLICATION API
diff --git a/src/class/hid/hid_device.c b/src/class/hid/hid_device.c index 3b882f705..5f6843d90 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_MEM_SECTION static hidd_interface_t _hidd_itf[ITF_COUNT];
+CFG_TUSB_MEM_SECTION static hidd_interface_t _hidd_itf[ITF_COUNT] = { { 0 } };
#if CFG_TUD_HID_KEYBOARD
diff --git a/src/class/msc/msc_device.c b/src/class/msc/msc_device.c index 5d2758414..76d647dcc 100644 --- a/src/class/msc/msc_device.c +++ b/src/class/msc/msc_device.c @@ -83,7 +83,7 @@ typedef struct { uint8_t add_sense_qualifier;
}mscd_interface_t;
-CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf;
+CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static mscd_interface_t _mscd_itf = { 0 };
CFG_TUSB_MEM_SECTION CFG_TUSB_MEM_ALIGN static uint8_t _mscd_buf[CFG_TUD_MSC_BUFSIZE];
//--------------------------------------------------------------------+
diff --git a/src/device/usbd.c b/src/device/usbd.c index 9c08a7932..5baea8460 100644 --- a/src/device/usbd.c +++ b/src/device/usbd.c @@ -61,7 +61,7 @@ typedef struct { }usbd_device_t;
-static usbd_device_t _usbd_dev;
+static usbd_device_t _usbd_dev = { 0 };
// Auto descriptor is enabled, descriptor set point to auto generated one
#if CFG_TUD_DESC_AUTO
@@ -240,6 +240,9 @@ static void usbd_reset(uint8_t rhport) */
void tud_task (void)
{
+ // Skip if stack is not initialized
+ if ( !tusb_inited() ) return;
+
// Loop until there is no more events in the queue
while (1)
{
diff --git a/src/host/usbh.c b/src/host/usbh.c index 4334729e9..a7e7c2acd 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -620,6 +620,9 @@ bool enum_task(hcd_event_t* event) */
void tuh_task(void)
{
+ // Skip if stack is not initialized
+ if ( !tusb_inited() ) return;
+
// Loop until there is no more events in the queue
while (1)
{
diff --git a/src/portable/nordic/nrf5x/hal_nrf5x.c b/src/portable/nordic/nrf5x/hal_nrf5x.c index f0a0b9632..52743ce6f 100644 --- a/src/portable/nordic/nrf5x/hal_nrf5x.c +++ b/src/portable/nordic/nrf5x/hal_nrf5x.c @@ -49,16 +49,9 @@ #ifdef SOFTDEVICE_PRESENT #include "nrf_sdm.h" #include "nrf_soc.h" +#endif -// TODO fully move to nrfx -enum { - NRFX_POWER_USB_EVT_DETECTED, /**< USB power detected on the connector (plugged in). */ - NRFX_POWER_USB_EVT_REMOVED, /**< USB power removed from the connector. */ - NRFX_POWER_USB_EVT_READY /**< USB power regulator ready. */ -}; -#else #include "nrfx_power.h" -#endif #include "tusb_hal.h" #include "device/dcd.h" @@ -66,8 +59,6 @@ enum { /*------------------------------------------------------------------*/ /* MACRO TYPEDEF CONSTANT ENUM *------------------------------------------------------------------*/ -#define USB_NVIC_PRIO 7 - void tusb_hal_nrf_power_event(uint32_t event); /*------------------------------------------------------------------*/ @@ -239,8 +230,7 @@ void tusb_hal_nrf_power_event (uint32_t event) NRF_USBD->INTENSET = USBD_INTEN_USBRESET_Msk | USBD_INTEN_USBEVENT_Msk | USBD_INTEN_EPDATA_Msk | USBD_INTEN_EP0SETUP_Msk | USBD_INTEN_EP0DATADONE_Msk | USBD_INTEN_ENDEPIN0_Msk | USBD_INTEN_ENDEPOUT0_Msk; - // Enable interrupt, Priorities 0,1,4,5 (nRF52) are reserved for SoftDevice - NVIC_SetPriority(USBD_IRQn, USB_NVIC_PRIO); + // Enable interrupt, priorities should be set by application NVIC_ClearPendingIRQ(USBD_IRQn); NVIC_EnableIRQ(USBD_IRQn); diff --git a/src/tusb.c b/src/tusb.c index ad2dcbfd3..566d74df7 100644 --- a/src/tusb.c +++ b/src/tusb.c @@ -68,6 +68,11 @@ bool tusb_init(void) return TUSB_ERROR_NONE;
}
+bool tusb_inited(void)
+{
+ return _initialized;
+}
+
/*------------------------------------------------------------------*/
/* Debug
*------------------------------------------------------------------*/
diff --git a/src/tusb.h b/src/tusb.h index fb20c5ff7..69c4d16d2 100644 --- a/src/tusb.h +++ b/src/tusb.h @@ -108,6 +108,9 @@ // Initialize device/host stack
bool tusb_init(void);
+// Check if stack is initialized
+bool tusb_inited(void);
+
// TODO
// bool tusb_teardown(void);
|
