8,6 → 8,7 |
#include "configuration.h" |
#include <avr/wdt.h> |
#include <avr/eeprom.h> |
#include <avr/interrupt.h> |
|
// byte array in eeprom |
uint8_t EEPromArray[E2END + 1] EEMEM; |
61,10 → 62,13 |
// length is the length of the pure data not including checksum and revision number. |
void writeChecksummedBlock(uint8_t revisionNumber, uint8_t* data, uint16_t offset, uint16_t length) { |
uint16_t CRC = CRC16(data, length); |
uint8_t sreg = SREG; |
cli(); |
eeprom_write_byte(&EEPromArray[offset], CRC&0xff); |
eeprom_write_byte(&EEPromArray[offset+1], CRC>>8); |
eeprom_write_byte(&EEPromArray[offset+2], revisionNumber); |
eeprom_write_block(data, &EEPromArray[offset+3], length); |
SREG = sreg; |
} |
|
// offset is where the checksum is stored, offset+1 is the revision number, and offset+2... are the data. |
101,7 → 105,6 |
void paramSet_writeToEEProm(uint8_t setnumber) { |
uint16_t offset = EEPROM_ADR_PARAMSET_BEGIN + (setnumber-1)*(sizeof(ParamSet_t)+EEPROM_CHECKSUMMED_BLOCK_OVERHEAD); |
writeChecksummedBlock(EEPARAM_REVISION, (uint8_t*)&staticParams, offset, sizeof(ParamSet_t)); |
// set this parameter set to active set |
} |
|
void paramSet_readOrDefault() { |