| 76 | static cfg_ram_t config_ram_copy; |
| 77 | |
| 78 | void config_init() |
| 79 | { |
| 80 | uint32_t new_size; |
| 81 | // Initialize RAM copy |
| 82 | memset(&config_ram_copy, 0, sizeof(config_ram_copy)); |
| 83 | // Read settings from RAM if the key is valid |
| 84 | new_size = sizeof(config_ram); |
| 85 | |
| 86 | if (CFG_KEY == config_ram.key) { |
| 87 | uint32_t size = MIN(config_ram.size, sizeof(config_ram)); |
| 88 | new_size = MAX(config_ram.size, sizeof(config_ram)); |
| 89 | memcpy(&config_ram_copy, (void *)&config_ram, size); |
| 90 | config_ram_copy.assert_file_name[sizeof(config_ram_copy.assert_file_name) - 1] = 0; |
| 91 | } |
| 92 | |
| 93 | // Initialize RAM |
| 94 | memset((void *)&config_ram, 0, sizeof(config_ram)); |
| 95 | config_ram.key = CFG_KEY; |
| 96 | config_ram.size = new_size; |
| 97 | // Copy assert info back over (must be explicitly cleared) |
| 98 | memcpy(config_ram.assert_file_name, |
| 99 | config_ram_copy.assert_file_name, |
| 100 | sizeof(config_ram_copy.assert_file_name)); |
| 101 | config_ram.assert_line = config_ram_copy.assert_line; |
| 102 | config_ram.assert_source = config_ram_copy.assert_source; |
| 103 | config_ram.valid_dumps = config_ram_copy.valid_dumps; |
| 104 | memcpy(config_ram.hexdump, config_ram_copy.hexdump, sizeof(config_ram_copy.hexdump[0]) * config_ram_copy.valid_dumps); |
| 105 | config_ram.disable_msd = config_ram_copy.disable_msd; |
| 106 | config_ram.page_erase_enable = config_ram_copy.page_erase_enable; |
| 107 | config_rom_init(); |
| 108 | } |
| 109 | |
| 110 | void config_ram_set_hold_in_bl(bool hold) |
| 111 | { |
no test coverage detected