clk.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Inria
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
20 #include <assert.h>
21 #include <stdint.h>
22 #include "periph_conf.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
33 static inline uint32_t coreclk(void) {
34 #if defined(CLOCK_CORECLOCK)
35  return CLOCK_CORECLOCK;
36 #else
37  extern uint32_t cpu_coreclk;
38  assert(cpu_coreclk != 0);
39  return cpu_coreclk;
40 #endif
41 }
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
#define CLOCK_CORECLOCK
Clock configuration.
Definition: periph_cpu.h:31
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:135
static uint32_t coreclk(void)
Get the current system core clock frequency in Hz.
Definition: clk.h:33