summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2018-05-15 12:37:48 +0700
committerhathach <[email protected]>2018-05-15 12:37:48 +0700
commit1d428b7fefa1a41d47918b1c6ddd7c96e84f98e3 (patch)
treec3ff414460d7c6cd3ed938ba730f4f8df2e01d47
parent03d442a86124d759f294828b46ad134f3e2f18dc (diff)
get nrf5x hal work with SD and non_SD configure
-rw-r--r--hw/bsp/pca10056/board_pca10056.c18
-rw-r--r--tinyusb/portable/nordic/nrf5x/hal_nrf5x.c21
2 files changed, 22 insertions, 17 deletions
diff --git a/hw/bsp/pca10056/board_pca10056.c b/hw/bsp/pca10056/board_pca10056.c
index e1668ebb5..bfe0c00be 100644
--- a/hw/bsp/pca10056/board_pca10056.c
+++ b/hw/bsp/pca10056/board_pca10056.c
@@ -75,10 +75,26 @@ void board_init(void)
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_CONFIG_LF_SRC << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
+ nrf_gpio_cfg_output(LED_1);
+
+#ifdef SOFTDEVICE_PRESENT
+ // TODO support Softdevice config
+#else
+ // Softdevice is not present, init power module and register tusb power event function
+ // for vusb detect, ready, removed
+ extern void tusb_hal_nrf_power_event(uint32_t event);
+
nrf_drv_power_init(NULL);
- nrf_gpio_cfg_output(LED_1);
+ // USB Power detection
+ const nrf_drv_power_usbevt_config_t config =
+ {
+ .handler = (nrf_drv_power_usb_event_handler_t) tusb_hal_nrf_power_event
+ };
+ TU_ASSERT( NRF_SUCCESS == nrf_drv_power_usbevt_init(&config) );
+#endif
+ // Tick init
SysTick_Config(SystemCoreClock/1000);
NVIC_EnableIRQ(SysTick_IRQn);
}
diff --git a/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c b/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c
index fc4f55237..b90a09032 100644
--- a/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c
+++ b/tinyusb/portable/nordic/nrf5x/hal_nrf5x.c
@@ -136,6 +136,8 @@ static void hfclk_disable(void)
/*------------------------------------------------------------------*/
/* TUSB HAL
*------------------------------------------------------------------*/
+
+// tusb_hal_nrf_power_event must be called by SOC event handler
bool tusb_hal_init(void)
{
#ifdef SOFTDEVICE_PRESENT
@@ -159,23 +161,10 @@ bool tusb_hal_init(void)
{
tusb_hal_nrf_power_event(NRFX_POWER_USB_EVT_READY);
}
-
- // tusb_hal_nrf_power_event must be called by SOC event handler
- return true;
- }else
-#endif
- {
-#if 0
- // USB Power detection
- const nrf_drv_power_usbevt_config_t config =
- {
- .handler = (nrf_drv_power_usb_event_handler_t) tusb_hal_nrf_power_event
- };
- return ( NRF_SUCCESS == nrf_drv_power_usbevt_init(&config) );
-#else
- return true;
-#endif
}
+#endif
+
+ return true;
}
void tusb_hal_int_enable(uint8_t rhport)