Robot Control Library
cpu.h
Go to the documentation of this file.
1/**
2 * <rc/cpu.h>
3 *
4 * @brief Control CPU scaling governer
5 *
6 * Functions to read and set the current CPU scaling function. This is not
7 * specific to the beaglebone and should work on any linux system, however since
8 * the beaglebone has a single cpu core, this only changes the govenor for one
9 * core.
10 *
11 * @author James Strawson
12 * @date 3/7/2018
13 *
14 * @addtogroup CPU
15 * @{
16 */
17
18#ifndef RC_CPU_H
19#define RC_CPU_H
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * available CPU governors
27 */
28typedef enum rc_governor_t{
29 RC_GOV_POWERSAVE, ///< Sets CPU to slowest speed
30 RC_GOV_PERFORMANCE, ///< Sets CPU to fastest speed
31 RC_GOV_ONDEMAND, ///< Default automatic scaling
32 RC_GOV_SCHEDUTIL, ///< Like ONDEMAND but newer algorithm
33 RC_GOV_CONSERVATIVE ///< Automatically scales the cpu but still tries to save power
35
36/**
37 * @brief Sets the CPU governor. See rc_governor_t
38 *
39 * This is the equivalent to running 'cpufreq-set -g {governor}' from the
40 * command line but can be called in your C program instead.
41 *
42 * @param[in] gov Desired governor
43 *
44 * @return 0 on success, -1 on failure.
45 */
47
48/**
49 * @brief Returns the current clock speed of the Beaglebone's Sitara
50 * processor in the form of the provided enumerated type. It will never return
51 * the FREQ_ONDEMAND value as the intention of this function is to see the clock
52 * speed as set by either the user or the ondemand governor itself.
53 *
54 * @return frequency in hz
55 */
57
58/**
59 * @brief Prints the current frequency to the screen. For example "600mhz".
60 *
61 * @return 0 on success or -1 on failure.
62 */
64
65
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif // RC_CPU_H
72
73/** @} end group CPU */
int rc_cpu_set_governor(rc_governor_t gov)
Sets the CPU governor. See rc_governor_t.
int rc_cpu_get_freq(void)
Returns the current clock speed of the Beaglebone's Sitara processor in the form of the provided enum...
rc_governor_t
Definition: cpu.h:28
int rc_cpu_print_freq(void)
Prints the current frequency to the screen. For example "600mhz".
@ RC_GOV_POWERSAVE
Sets CPU to slowest speed.
Definition: cpu.h:29
@ RC_GOV_SCHEDUTIL
Like ONDEMAND but newer algorithm.
Definition: cpu.h:32
@ RC_GOV_PERFORMANCE
Sets CPU to fastest speed.
Definition: cpu.h:30
@ RC_GOV_CONSERVATIVE
Automatically scales the cpu but still tries to save power.
Definition: cpu.h:33
@ RC_GOV_ONDEMAND
Default automatic scaling.
Definition: cpu.h:31