mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
cpu/nrfxx: simplify LFCLK source selection
Signed-off-by: Dylan Laduranty <dylan.laduranty@mesotic.com>
This commit is contained in:
parent
0a5d07c391
commit
1d0177dc31
@ -25,6 +25,15 @@
|
||||
#include "periph/init.h"
|
||||
#include "stdio_base.h"
|
||||
|
||||
/**
|
||||
* @brief LFCLK Clock selection configuration guard
|
||||
*/
|
||||
#if ((CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_RC) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_Xtal) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_Synth))
|
||||
#error "LFCLK init: CLOCK_LFCLK has invalid value"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the CPU, set IRQ priorities
|
||||
*/
|
||||
|
@ -35,6 +35,15 @@ static bool ftpan_32(void);
|
||||
static bool ftpan_37(void);
|
||||
static bool ftpan_36(void);
|
||||
|
||||
/**
|
||||
* @brief LFCLK Clock selection configuration guard
|
||||
*/
|
||||
#if ((CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_RC) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_Xtal) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_Synth))
|
||||
#error "LFCLK init: CLOCK_LFCLK has invalid value"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the CPU, set IRQ priorities
|
||||
*/
|
||||
|
@ -27,6 +27,15 @@
|
||||
#include "stdio_base.h"
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
* @brief LFCLK Clock selection configuration guard
|
||||
*/
|
||||
#if ((CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_LFRC) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_LFXO) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_LFSYNT))
|
||||
#error "LFCLK init: CLOCK_LFCLK has invalid value"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the CPU, set IRQ priorities
|
||||
*/
|
||||
|
@ -23,23 +23,16 @@
|
||||
#include "nrf_clock.h"
|
||||
#include "periph_conf.h"
|
||||
|
||||
/* make sure both clocks are configured */
|
||||
/* make HFCLK clock is configured */
|
||||
#ifndef CLOCK_HFCLK
|
||||
#error "Clock init: CLOCK_HFCLK is not defined by your board!"
|
||||
#endif
|
||||
#ifndef CLOCK_LFCLK
|
||||
#error "Clock init: CLOCK_LFCLK is not defined by your board!"
|
||||
#endif
|
||||
|
||||
/* Add compatibility wrapper defines for nRF families with Cortex-M33 core */
|
||||
#ifdef NRF_CLOCK_S
|
||||
#define NRF_CLOCK NRF_CLOCK_S
|
||||
#endif
|
||||
|
||||
#ifdef CLOCK_LFCLKSRC_SRC_LFRC
|
||||
#define CLOCK_LFCLKSRC_SRC_RC CLOCK_LFCLKSRC_SRC_LFRC
|
||||
#endif
|
||||
|
||||
static unsigned _hfxo_requests = 0;
|
||||
|
||||
void clock_init_hf(void)
|
||||
@ -92,17 +85,9 @@ void clock_start_lf(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#if (CLOCK_LFCLK == 0)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC);
|
||||
#elif (CLOCK_LFCLK == 1)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal);
|
||||
#elif (CLOCK_LFCLK == 2)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Synth);
|
||||
#elif (CLOCK_LFCLK == 3)
|
||||
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_LFXO);
|
||||
#else
|
||||
#error "LFCLK init: CLOCK_LFCLK has invalid value"
|
||||
#endif
|
||||
/* Select LFCLK source */
|
||||
NRF_CLOCK->LFCLKSRC = CLOCK_LFCLK;
|
||||
|
||||
/* enable LF clock */
|
||||
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
|
||||
NRF_CLOCK->TASKS_LFCLKSTART = 1;
|
||||
|
@ -25,6 +25,14 @@
|
||||
#include "periph/init.h"
|
||||
#include "stdio_base.h"
|
||||
|
||||
/**
|
||||
* @brief LFCLK Clock selection configuration guard
|
||||
*/
|
||||
#if ((CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_LFRC) && \
|
||||
(CLOCK_LFCLK != CLOCK_LFCLKSRC_SRC_LFXO))
|
||||
#error "LFCLK init: CLOCK_LFCLK has invalid value"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the CPU, set IRQ priorities
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user