mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys: introduce coreclk utility function
This commit is contained in:
parent
e3f6212708
commit
ec41c43751
49
sys/include/clk.h
Normal file
49
sys/include/clk.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Inria
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup sys_clk System core clock
|
||||||
|
* @ingroup sys
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief System core clock utility functions
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CLK_H
|
||||||
|
#define CLK_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include "periph_conf.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current system core clock frequency in Hz.
|
||||||
|
*
|
||||||
|
* @returns current system core clock frequency in Hz
|
||||||
|
*/
|
||||||
|
static inline uint32_t coreclk(void) {
|
||||||
|
#if defined(CLOCK_CORECLOCK)
|
||||||
|
return CLOCK_CORECLOCK;
|
||||||
|
#else
|
||||||
|
extern uint32_t cpu_coreclk;
|
||||||
|
assert(cpu_coreclk != 0);
|
||||||
|
return cpu_coreclk;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* CLK_H */
|
||||||
|
/** @} */
|
Loading…
Reference in New Issue
Block a user