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
 
43
 
44
 For dependencies to compile, on Arch install these.
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
 ## Proper Debugging
48
 ## Proper Debugging
49
 
49
 

+ 3
- 0
src/console.c View File

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

+ 4
- 1
src/mem.c View File

48
     .data = MEM_DATA_INIT,  \
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
 static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);
53
 static const uint8_t *data_flash = (const uint8_t *)(XIP_BASE + FLASH_OFFSET);
53
 
54
 
54
 static_assert(sizeof(struct mem_contents) < FLASH_SECTOR_SIZE,
55
 static_assert(sizeof(struct mem_contents) < FLASH_SECTOR_SIZE,
78
 }
79
 }
79
 
80
 
80
 void mem_load_defaults(void) {
81
 void mem_load_defaults(void) {
82
+    data_ram = data_defaults;
83
+
81
     data_ram.data.wf_count = wf_default_count;
84
     data_ram.data.wf_count = wf_default_count;
82
     for (uint16_t i = 0; i < wf_default_count; i++) {
85
     for (uint16_t i = 0; i < wf_default_count; i++) {
83
         data_ram.data.wf[i] = wf_default_data[i];
86
         data_ram.data.wf[i] = wf_default_data[i];

Loading…
Cancel
Save