Implement memory wear leveling algorithm
This commit is contained in:
17
src/main.c
17
src/main.c
@@ -7,6 +7,7 @@
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
// TODO: Config header for chip specifics like EEPROM size.
|
||||
// TODO: Make sure wear leveling resets memory correctly.
|
||||
// TODO: Implement primary state machine for update loop.
|
||||
// TODO: Migrate to ATMega 1284P-PU for 2nd 16-bit timer.
|
||||
// TODO: Keep persistent TEMP and DEWP targets in EEPROM.
|
||||
@@ -26,8 +27,8 @@ enum state_e
|
||||
};
|
||||
|
||||
static enum state_e state;
|
||||
static float temp, temp_target;
|
||||
static float dewp, dewp_target;
|
||||
static word temp, temp_target;
|
||||
static word dewp, dewp_target;
|
||||
|
||||
static int Init(void)
|
||||
{
|
||||
@@ -67,6 +68,18 @@ static int Init(void)
|
||||
WDT_Enable();
|
||||
WDT_SetTimeoutFlag(WDT2000); // 2 seconds
|
||||
|
||||
// Test persistent settings from EEPROM. There must
|
||||
// be some sanity checking before these values are
|
||||
// used.
|
||||
|
||||
MEM_Init();
|
||||
MEM_Read(&temp_target, &dewp_target);
|
||||
Info("Persistent memory contains [%d, %d]",
|
||||
temp_target, dewp_target);
|
||||
|
||||
// MEM_Write(20, 60);
|
||||
// MEM_Dump();
|
||||
|
||||
// There is a possiblity to use interrupt signals
|
||||
// for I2C communication but only as one large
|
||||
// branching routine for the whole I2C system.
|
||||
|
||||
Reference in New Issue
Block a user