Started to implement some functions of the watch power management system (dynamically change CPU clock), more to be done.
This commit is contained in:
parent
b5efc4f3a2
commit
da65442ad5
@ -80,6 +80,46 @@ bool watch_power_management_check_current_power_state_is(watch_power_state_e pow
|
|||||||
return power_state == _watch_power_management.current_power_state;
|
return power_state == _watch_power_management.current_power_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void watch_power_management_overwrite_default_cpu_clocks(enum CPU_CLK idle, enum CPU_CLK full_speed)
|
||||||
|
{
|
||||||
|
if(CPU_CLK_NO_CHANGE != idle) _watch_power_management.cpu_clock_idle = idle;
|
||||||
|
if(CPU_CLK_NO_CHANGE != full_speed) _watch_power_management.cpu_clock_full_speed = full_speed;
|
||||||
|
|
||||||
|
// Let's apply the restored clock
|
||||||
|
switch (_watch_power_management.current_power_state)
|
||||||
|
{
|
||||||
|
case WATCH_POWER_STATE_IDLE:
|
||||||
|
_set_cpu_clock(_watch_power_management.cpu_clock_idle);
|
||||||
|
break;
|
||||||
|
case WATCH_POWER_STATE_FULL_SPEED:
|
||||||
|
_set_cpu_clock(_watch_power_management.cpu_clock_full_speed);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Nothing to do
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void watch_power_management_restore_default_cpu_clocks(bool idle, bool full_speed)
|
||||||
|
{
|
||||||
|
if(idle) _watch_power_management.cpu_clock_idle = CPU_CLK_80M;
|
||||||
|
if(full_speed) _watch_power_management.cpu_clock_full_speed = CPU_CLK_160M;
|
||||||
|
|
||||||
|
// Let's apply the restored clock
|
||||||
|
switch (_watch_power_management.current_power_state)
|
||||||
|
{
|
||||||
|
case WATCH_POWER_STATE_IDLE:
|
||||||
|
_set_cpu_clock(_watch_power_management.cpu_clock_idle);
|
||||||
|
break;
|
||||||
|
case WATCH_POWER_STATE_FULL_SPEED:
|
||||||
|
_set_cpu_clock(_watch_power_management.cpu_clock_full_speed);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Nothing to do
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void _set_cpu_clock(enum CPU_CLK cpu_clock)
|
static void _set_cpu_clock(enum CPU_CLK cpu_clock)
|
||||||
{
|
{
|
||||||
// First let's get the current clock speed
|
// First let's get the current clock speed
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
#include "wm_type_def.h"
|
#include "wm_type_def.h"
|
||||||
#include "wm_cpu.h"
|
#include "wm_cpu.h"
|
||||||
|
|
||||||
|
#define CPU_CLK_NO_CHANGE (0)
|
||||||
|
|
||||||
typedef enum watch_power_state
|
typedef enum watch_power_state
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -56,4 +58,8 @@ watch_power_state_e watch_power_management_get_current_power_state(void);
|
|||||||
|
|
||||||
bool watch_power_management_check_current_power_state_is(watch_power_state_e power_state);
|
bool watch_power_management_check_current_power_state_is(watch_power_state_e power_state);
|
||||||
|
|
||||||
|
void watch_power_management_overwrite_default_cpu_clocks(enum CPU_CLK idle, enum CPU_CLK full_speed);
|
||||||
|
|
||||||
|
void watch_power_management_restore_default_cpu_clocks(bool idle, bool full_speed);
|
||||||
|
|
||||||
#endif //WATCH_POWER_MANAGEMENT_H
|
#endif //WATCH_POWER_MANAGEMENT_H
|
Loading…
Reference in New Issue
Block a user