More low power work

This commit is contained in:
Joey Castillo 2021-05-09 12:19:40 -04:00
parent 7ff91a2f67
commit 7e9ef16a18
5 changed files with 33 additions and 41 deletions

View file

@ -517,10 +517,10 @@ drivers:
functionality: System functionality: System
api: HAL:HPL:GCLK api: HAL:HPL:GCLK
configuration: configuration:
$input: 32768 $input: 400000
$input_id: 32kHz External Crystal Oscillator (XOSC32K) $input_id: External Crystal Oscillator 0.4-32MHz (XOSC)
RESERVED_InputFreq: 32768 RESERVED_InputFreq: 400000
RESERVED_InputFreq_id: 32kHz External Crystal Oscillator (XOSC32K) RESERVED_InputFreq_id: External Crystal Oscillator 0.4-32MHz (XOSC)
_$freq_output_Generic clock generator 0: 4000000 _$freq_output_Generic clock generator 0: 4000000
_$freq_output_Generic clock generator 1: 400000 _$freq_output_Generic clock generator 1: 400000
_$freq_output_Generic clock generator 2: 400000 _$freq_output_Generic clock generator 2: 400000
@ -594,7 +594,7 @@ drivers:
cpu_clock_source: Generic clock generator 0 cpu_clock_source: Generic clock generator 0
cpu_div: '1' cpu_div: '1'
enable_cpu_clock: true enable_cpu_clock: true
mclk_arch_bupdiv: Divide by 8 mclk_arch_bupdiv: Divide by 1
nvm_wait_states: '0' nvm_wait_states: '0'
optional_signals: [] optional_signals: []
variant: null variant: null
@ -646,9 +646,9 @@ drivers:
functionality: System functionality: System
api: HAL:HPL:OSCCTRL api: HAL:HPL:OSCCTRL
configuration: configuration:
$input: 32768 $input: 16000000
$input_id: 32kHz External Crystal Oscillator (XOSC32K) $input_id: 32kHz External Crystal Oscillator (XOSC32K)
RESERVED_InputFreq: 32768 RESERVED_InputFreq: 16000000
RESERVED_InputFreq_id: 32kHz External Crystal Oscillator (XOSC32K) RESERVED_InputFreq_id: 32kHz External Crystal Oscillator (XOSC32K)
_$freq_output_16MHz Internal Oscillator (OSC16M): 4000000 _$freq_output_16MHz Internal Oscillator (OSC16M): 4000000
_$freq_output_Digital Frequency Locked Loop (DFLL48M): 48000000 _$freq_output_Digital Frequency Locked Loop (DFLL48M): 48000000

View file

@ -48,7 +48,7 @@
// <MCLK_BUPDIV_BUPDIV_DIV128_Val"> Divide by 128 // <MCLK_BUPDIV_BUPDIV_DIV128_Val"> Divide by 128
// <id> mclk_arch_bupdiv // <id> mclk_arch_bupdiv
#ifndef CONF_MCLK_BUPDIV #ifndef CONF_MCLK_BUPDIV
#define CONF_MCLK_BUPDIV MCLK_BUPDIV_BUPDIV_DIV8_Val #define CONF_MCLK_BUPDIV MCLK_BUPDIV_BUPDIV_DIV1_Val
#endif #endif
// </h> // </h>

View file

@ -196,7 +196,7 @@
<AcmeProjectActionInfo Action="File" Source="config/hpl_dmac_config.h" IsConfig="true" Hash="w3WBXNAk4X2Eyml3c7tQSQ" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_dmac_config.h" IsConfig="true" Hash="w3WBXNAk4X2Eyml3c7tQSQ" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_eic_config.h" IsConfig="true" Hash="U9WSM5Hq8sGLa8ysciEfCg" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_eic_config.h" IsConfig="true" Hash="U9WSM5Hq8sGLa8ysciEfCg" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_gclk_config.h" IsConfig="true" Hash="VW757Ebgq5TyYTRcpY8M7w" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_gclk_config.h" IsConfig="true" Hash="VW757Ebgq5TyYTRcpY8M7w" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_mclk_config.h" IsConfig="true" Hash="CLrsNUvv74/qlHdF8aFndg" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_mclk_config.h" IsConfig="true" Hash="mlJgZO8dVVh4sN9KaO7rkA" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_osc32kctrl_config.h" IsConfig="true" Hash="LayjFcrIUjhOQ+E6G5sHRA" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_osc32kctrl_config.h" IsConfig="true" Hash="LayjFcrIUjhOQ+E6G5sHRA" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_oscctrl_config.h" IsConfig="true" Hash="Vc5u27WzT+UPF5aLAxl2lQ" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_oscctrl_config.h" IsConfig="true" Hash="Vc5u27WzT+UPF5aLAxl2lQ" />
<AcmeProjectActionInfo Action="File" Source="config/hpl_port_config.h" IsConfig="true" Hash="rMTNR+5FXtu+wfT1NbfRRA" /> <AcmeProjectActionInfo Action="File" Source="config/hpl_port_config.h" IsConfig="true" Hash="rMTNR+5FXtu+wfT1NbfRRA" />
@ -409,6 +409,7 @@
<Value>%24(PackRepoDir)\atmel\SAML22_DFP\1.2.77\include</Value> <Value>%24(PackRepoDir)\atmel\SAML22_DFP\1.2.77\include</Value>
</ListValues> </ListValues>
</armgcc.compiler.directories.IncludePaths> </armgcc.compiler.directories.IncludePaths>
<armgcc.compiler.optimization.level>Optimize debugging experience (-Og)</armgcc.compiler.optimization.level>
<armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>
<armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel> <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel>
<armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings> <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings>

View file

@ -11,9 +11,6 @@ void calendar_callback(struct calendar_descriptor *const calendar) {
static void mode_callback() { static void mode_callback() {
local = !local; local = !local;
struct calendar_date_time date_time;
calendar_get_date_time(&CALENDAR_0, &date_time);
update_display(&watch, date_time, local);
} }
static void light_callback() { static void light_callback() {
@ -21,7 +18,6 @@ static void light_callback() {
calendar_get_date_time(&CALENDAR_0, &date_time); calendar_get_date_time(&CALENDAR_0, &date_time);
date_time.time.min = (date_time.time.min + 1) % 60; date_time.time.min = (date_time.time.min + 1) % 60;
watch_set_date_time(date_time); watch_set_date_time(date_time);
update_display(&watch, date_time, local);
} }
static void alarm_callback() { static void alarm_callback() {
@ -29,19 +25,29 @@ static void alarm_callback() {
calendar_get_date_time(&CALENDAR_0, &date_time); calendar_get_date_time(&CALENDAR_0, &date_time);
date_time.time.sec = 0; date_time.time.sec = 0;
watch_set_date_time(date_time); watch_set_date_time(date_time);
update_display(&watch, date_time, local);
} }
static void tick_callback() { static void tick_callback() {
struct calendar_date_time date_time;
calendar_get_date_time(&CALENDAR_0, &date_time);
update_display(&watch, date_time, local);
} }
int main(void) int main(void)
{ {
atmel_start_init(); atmel_start_init();
watch_init(&watch);
watch_enable_date_time(&watch);
struct calendar_date_time date_time;
date_time.date.year = 2021;
date_time.date.month = 5;
date_time.date.day = 8;
date_time.time.hour = 19;
date_time.time.min = 40;
date_time.time.sec = 0;
watch_set_date_time(date_time);
update_display(&watch, date_time, local);
watch_enable_tick(tick_callback);
gpio_set_pin_level(RED, false); gpio_set_pin_level(RED, false);
gpio_set_pin_direction(RED, GPIO_DIRECTION_OUT); gpio_set_pin_direction(RED, GPIO_DIRECTION_OUT);
gpio_set_pin_function(RED, GPIO_PIN_FUNCTION_OFF); gpio_set_pin_function(RED, GPIO_PIN_FUNCTION_OFF);
@ -49,38 +55,19 @@ int main(void)
gpio_set_pin_direction(GREEN, GPIO_DIRECTION_OUT); gpio_set_pin_direction(GREEN, GPIO_DIRECTION_OUT);
gpio_set_pin_function(GREEN, GPIO_PIN_FUNCTION_OFF); gpio_set_pin_function(GREEN, GPIO_PIN_FUNCTION_OFF);
watch_init(&watch);
watch_enable_display(&watch);
watch_display_pixel(&watch, 1, 16);
watch_enable_buttons(&watch); watch_enable_buttons(&watch);
watch_register_button_callback(&watch, BTN_MODE, &mode_callback); watch_register_button_callback(&watch, BTN_MODE, &mode_callback);
watch_register_button_callback(&watch, BTN_ALARM, &alarm_callback); watch_register_button_callback(&watch, BTN_ALARM, &alarm_callback);
watch_register_button_callback(&watch, BTN_LIGHT, &light_callback); watch_register_button_callback(&watch, BTN_LIGHT, &light_callback);
watch_enable_date_time(&watch); watch_enable_display(&watch);
struct calendar_date_time date_time; watch_display_pixel(&watch, 1, 16);
date_time.date.year = 2021;
date_time.date.month = 5;
date_time.date.day = 6;
date_time.time.hour = 23;
date_time.time.min = 30;
date_time.time.sec = 0;
watch_set_date_time(date_time);
/* struct calendar_alarm alarm;
alarm.cal_alarm.mode = REPEAT;
alarm.cal_alarm.datetime = date_time;
alarm.cal_alarm.datetime.time.sec = 0;
alarm.cal_alarm.option = CALENDAR_ALARM_MATCH_SEC;
alarm.callback = calendar_callback;
calendar_set_alarm(&CALENDAR_0, &alarm, &calendar_callback);
*/
update_display(&watch, date_time, local);
watch_enable_tick(tick_callback);
while (1) { while (1) {
sleep(4); sleep(4);
struct calendar_date_time date_time;
calendar_get_date_time(&CALENDAR_0, &date_time);
update_display(&watch, date_time, local);
} }
return 0; return 0;

View file

@ -12,8 +12,12 @@
void watch_init(Watch *watch) { void watch_init(Watch *watch) {
memset(watch, 0, sizeof(*watch)); memset(watch, 0, sizeof(*watch));
// use switching regulator
SUPC->VREG.bit.SEL = 1; SUPC->VREG.bit.SEL = 1;
while(!SUPC->STATUS.bit.VREGRDY); while(!SUPC->STATUS.bit.VREGRDY);
// TODO: use performance level 0
// _set_performance_level(0);
// hri_pm_write_PLCFG_PLDIS_bit(PM, true);
} }
const uint8_t Character_Set[] = const uint8_t Character_Set[] =