Appiko
Macros | Enumerations | Functions

Hardware abstraction layer of the high frequency and low frequency clock. More...

Macros

#define LFCLK_FREQ   32768
 Frequency of the low frequency clock is 32.768 kHz.
 

Enumerations

enum  lfclk_src_t { LFCLK_SRC_RC = CLOCK_LFCLKSRC_SRC_RC, LFCLK_SRC_Xtal = CLOCK_LFCLKSRC_SRC_Xtal, LFCLK_SRC_Synth = CLOCK_LFCLKSRC_SRC_Synth }
 

Functions

void lfclk_init (lfclk_src_t lfclk_src)
 Function to initialize the LF clock. More...
 
void lfclk_deinit (void)
 Function to de-initialize the LF clock. Saves a bit of power as LF clock is not running, but RTC or WDT cannot run. More...
 
void hfclk_xtal_init_blocking (void)
 Function to start the crystal oscillator to be used for HF clock. This function blocks until the crystal oscillator starts. More...
 
void hfclk_xtal_init_nonblocking (void)
 Function to initialize the HF clock to use the crystal. This function returns immediately after triggering the start task.
 
void hfclk_block_till_xtal (void)
 Blocks until the HF crystal oscillator is running. More...
 
void hfclk_xtal_deinit (void)
 Function to de-initialize the HF clock from using the crystal. RC oscillator will be used to generate HF clock. More power and not accurate. Starts quick though.
 

Detailed Description

Enumeration Type Documentation

◆ lfclk_src_t

The possible sources for Low frequency clock's 32 kHz input

Enumerator
LFCLK_SRC_RC 

Internal RC oscillator.

LFCLK_SRC_Xtal 

External crystal.

LFCLK_SRC_Synth 

Synthesizer from HFCLK clock.

Definition at line 36 of file hal_clocks.h.

Function Documentation

◆ hfclk_block_till_xtal()

void hfclk_block_till_xtal ( void  )
Warning
The HF crystal oscillator must be started before this call.
Beware of errata 68 in nRF52

Definition at line 112 of file hal_clocks.c.

◆ hfclk_xtal_init_blocking()

void hfclk_xtal_init_blocking ( void  )
Warning
Beware of errata 68 in nRF52

Definition at line 71 of file hal_clocks.c.

◆ lfclk_deinit()

void lfclk_deinit ( void  )
Warning
Might be better to leave it on as it consumes little power.
Be aware of errata 132 in nRF52 (LF RC Osc doesn't restart in some cases)

Definition at line 66 of file hal_clocks.c.

◆ lfclk_init()

void lfclk_init ( lfclk_src_t  lfclk_src)
Parameters
lfclk_srcThe source for the lf clock (RC, Xtal or systhesis from HF-clk)
Warning
If the clock source is RC oscillator, calibrate it to use (errata 77 in nRF52)

hal_clocks.c : Clocks HAL Copyright (C) 2019 Appiko

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Definition at line 23 of file hal_clocks.c.

Referenced by main().