Use RC as LF source for all board compatible
This commit is contained in:
@ -61,7 +61,8 @@ uint16_t _pwm_blue_seq[PWM_CHANNEL_NUM] = { PWM_MAXCOUNT/2, 0, 0 , 0 };
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
NRF_CLOCK->LFCLKSRC = (uint32_t)((CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos) & CLOCK_LFCLKSRC_SRC_Msk);
|
||||
// Use Internal OSC to compatible with all boards
|
||||
NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_RC;
|
||||
NRF_CLOCK->TASKS_LFCLKSTART = 1UL;
|
||||
|
||||
// stop WDT if started by application, when jumping from application using BLE DFU
|
||||
@ -106,6 +107,9 @@ void board_teardown(void)
|
||||
NRF_RTC1->INTENCLR = RTC_INTENSET_COMPARE0_Msk;
|
||||
NRF_RTC1->TASKS_STOP = 1;
|
||||
NRF_RTC1->TASKS_CLEAR = 1;
|
||||
|
||||
// Stop LF clock
|
||||
NRF_CLOCK->TASKS_LFCLKSTOP = 1UL;
|
||||
}
|
||||
|
||||
uint32_t tusb_hal_millis(void)
|
||||
@ -113,8 +117,6 @@ uint32_t tusb_hal_millis(void)
|
||||
return ( ( ((uint64_t)app_timer_cnt_get())*1000*(APP_TIMER_CONFIG_RTC_FREQUENCY+1)) / APP_TIMER_CLOCK_FREQ );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void led_pwm_init(uint32_t led_pin)
|
||||
{
|
||||
NRF_PWM_Type* pwm = (led_pin == LED_RED) ? NRF_PWM0 : NRF_PWM1;
|
||||
|
11
src/main.c
11
src/main.c
@ -298,20 +298,13 @@ static uint32_t softdev_init(bool init_softdevice)
|
||||
// map vector table to bootloader address
|
||||
APP_ERROR_CHECK( sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START) );
|
||||
|
||||
// Enable Softdevice
|
||||
// Enable Softdevice, Use Internal OSC to compatible with all boards
|
||||
nrf_clock_lf_cfg_t clock_cfg =
|
||||
{
|
||||
#if defined(NRF52840_XXAA) // TODO use xtal source for feather52832
|
||||
.source = NRF_CLOCK_LF_SRC_XTAL,
|
||||
.rc_ctiv = 0,
|
||||
.rc_temp_ctiv = 0,
|
||||
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
|
||||
#else
|
||||
.source = NRF_CLOCK_LF_SRC_RC,
|
||||
.rc_ctiv = 16,
|
||||
.rc_temp_ctiv = 2,
|
||||
.accuracy = NRF_CLOCK_LF_ACCURACY_20_PPM
|
||||
#endif
|
||||
.accuracy = NRF_CLOCK_LF_ACCURACY_250_PPM
|
||||
};
|
||||
|
||||
APP_ERROR_CHECK( sd_softdevice_enable(&clock_cfg, app_error_fault_handler) );
|
||||
|
Reference in New Issue
Block a user