Browse Source

fix mem init

Thomas Buck 11 months ago
parent
commit
f25a6d161b
3 changed files with 8 additions and 2 deletions
  1. 1
    1
      README.md
  2. 3
    0
      src/console.c
  3. 4
    1
      src/mem.c

+ 1
- 1
README.md View File

@@ -43,7 +43,7 @@ Open it using eg. `picocom`, or with the included `debug.sh` script.
43 43
 
44 44
 For dependencies to compile, on Arch install these.
45 45
 
46
-    sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib picocom cmake
46
+    sudo pacman -S arm-none-eabi-gcc arm-none-eabi-newlib picocom cmake cxxtest
47 47
 
48 48
 ## Proper Debugging
49 49
 

+ 3
- 0
src/console.c View File

@@ -103,6 +103,7 @@ static void cnsl_interpret(const char *line) {
103 103
         println("  mount - make mass storage medium (un)available");
104 104
         println("  power - show Lipo battery status");
105 105
         println("   memr - reset flash memory config");
106
+        println("     bl - print backlight pwm level");
106 107
         println("");
107 108
         println("   scan - start or stop BLE scan");
108 109
         println("scanres - print list of found BLE devices");
@@ -156,6 +157,8 @@ static void cnsl_interpret(const char *line) {
156 157
     } else if (strcmp(line, "memr") == 0) {
157 158
         mem_load_defaults();
158 159
         mem_write();
160
+    } else if (strcmp(line, "bl") == 0) {
161
+        println("bl: 0x%04X", mem_data()->backlight);
159 162
     } else if (strcmp(line, "scan") == 0) {
160 163
         ble_scan(BLE_SCAN_TOGGLE);
161 164
     } else if (strcmp(line, "scanres") == 0) {

+ 4
- 1
src/mem.c View File

@@ -48,7 +48,8 @@ struct mem_contents {
48 48
     .data = MEM_DATA_INIT,  \
49 49
 }
50 50
 
51
-static struct mem_contents data_ram = MEM_CONTENTS_INIT;
51
+static const struct mem_contents data_defaults = MEM_CONTENTS_INIT;
52
+static struct mem_contents data_ram = data_defaults;
52 53
 static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);
53 54
 
54 55
 static_assert(sizeof(struct mem_contents) < FLASH_SECTOR_SIZE,
@@ -78,6 +79,8 @@ static uint32_t calc_checksum(const struct mem_contents *data) {
78 79
 }
79 80
 
80 81
 void mem_load_defaults(void) {
82
+    data_ram = data_defaults;
83
+
81 84
     data_ram.data.wf_count = wf_default_count;
82 85
     for (uint16_t i = 0; i < wf_default_count; i++) {
83 86
         data_ram.data.wf[i] = wf_default_data[i];

Loading…
Cancel
Save