Define and utilize memory region backup_ram.

This commit is contained in:
Jared Boone 2016-02-05 16:45:23 -08:00
parent 682c87e3ff
commit fd3f962e40
2 changed files with 7 additions and 2 deletions

View File

@ -69,6 +69,8 @@ constexpr region_t ahb_ram_0 { 0x20000000, 32_KiB };
constexpr region_t ahb_ram_1 { 0x20008000, 16_KiB }; constexpr region_t ahb_ram_1 { 0x20008000, 16_KiB };
constexpr region_t ahb_ram_2 { 0x2000c000, 16_KiB }; constexpr region_t ahb_ram_2 { 0x2000c000, 16_KiB };
constexpr region_t backup_ram { LPC_BACKUP_REG_BASE, 256 };
constexpr region_t spifi_uncached { LPC_SPIFI_DATA_BASE, 1_MiB }; constexpr region_t spifi_uncached { LPC_SPIFI_DATA_BASE, 1_MiB };
constexpr region_t spifi_cached { LPC_SPIFI_DATA_CACHED_BASE, spifi_uncached.size() }; constexpr region_t spifi_cached { LPC_SPIFI_DATA_CACHED_BASE, spifi_uncached.size() };

View File

@ -25,6 +25,9 @@
#include "utility.hpp" #include "utility.hpp"
#include "memory_map.hpp"
using portapack::memory::map::backup_ram;
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
@ -43,9 +46,9 @@ struct data_t {
int32_t correction_ppb; int32_t correction_ppb;
}; };
static_assert(sizeof(data_t) <= 0x100, "Persistent memory structure too large for VBAT-maintained region"); static_assert(sizeof(data_t) <= backup_ram.size(), "Persistent memory structure too large for VBAT-maintained region");
static data_t* const data = reinterpret_cast<data_t*>(LPC_BACKUP_REG_BASE); static data_t* const data = reinterpret_cast<data_t*>(backup_ram.base());
rf::Frequency tuned_frequency() { rf::Frequency tuned_frequency() {
rf::tuning_range.reset_if_outside(data->tuned_frequency, tuned_frequency_reset_value); rf::tuning_range.reset_if_outside(data->tuned_frequency, tuned_frequency_reset_value);