Skip to content

Commit 2dc97b4

Browse files
committed
options: save power on AC immediately on set()
Signed-off-by: Michał Kopeć <michal.kopec@3mdeb.com>
1 parent d51e946 commit 2dc97b4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/board/system76/common/options.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <board/flash.h>
44
#include <board/options.h>
55
#include <common/debug.h>
6+
#include <common/macro.h>
67

78
uint8_t __xdata OPTIONS[NUM_OPTIONS];
89

@@ -17,6 +18,8 @@ uint8_t DEFAULT_OPTIONS[NUM_OPTIONS] = {
1718
};
1819
// clang-format on
1920

21+
#define SAVE_IMMEDIATELY BIT(OPT_POWER_ON_AC)
22+
2023
// Config is in the second to last sector of flash
2124
const uint32_t OPTIONS_ADDR = 0x1F800;
2225
// Signature is the size of the config
@@ -91,7 +94,7 @@ bool options_save_config(void) {
9194
// TODO error handling
9295
uint8_t options_get(uint16_t index) {
9396
if (index < NUM_OPTIONS) {
94-
TRACE("OPTION %x READ %x\n", index, OPTIONS[index]);
97+
DEBUG("OPTION %x READ %x\n", index, OPTIONS[index]);
9598
return OPTIONS[index];
9699
} else {
97100
return 0;
@@ -100,8 +103,10 @@ uint8_t options_get(uint16_t index) {
100103

101104
bool options_set(uint16_t index, uint8_t value) {
102105
if (index < NUM_OPTIONS) {
106+
DEBUG("OPTION %x WRITE %x\n", index, value);
103107
OPTIONS[index] = value;
104-
TRACE("OPTION %x WRITE %x\n", index, value);
108+
if (SAVE_IMMEDIATELY & BIT(index))
109+
return options_save_config();
105110
return true;
106111
} else {
107112
return false;

0 commit comments

Comments
 (0)