remove configuration from eeprom and define it in header
This commit is contained in:
parent
65807c648c
commit
6066ef44d8
|
@ -30,8 +30,6 @@
|
|||
#include <avr/wdt.h> // Watchdog timer handling
|
||||
#include <avr/pgmspace.h> // Program Space Utilities
|
||||
#include <avr/sleep.h> // Power Management and Sleep Modes
|
||||
#include <avr/eeprom.h> // EEPROM handling
|
||||
#include <util/crc16.h> // CRC Computations
|
||||
|
||||
#include "main.h" // main definitions
|
||||
#include "usart.h" // basic USART functions
|
||||
|
@ -77,18 +75,7 @@ int main(void)
|
|||
|
||||
printf(PSTR("welcome to the spar counter power meter monitor\n"));
|
||||
|
||||
struct configuration conf; // node configuration
|
||||
// read configuration data from EEPROM + CRC-8-iButton value
|
||||
uint8_t eeprom_conf[sizeof(struct configuration)+1];
|
||||
uint8_t crc = 0; // CRC8 iButton/1Wire/Dallas/Maxim calculation
|
||||
for (uint16_t i=0; i<sizeof(eeprom_conf); i++) {
|
||||
eeprom_conf[i] = eeprom_read_byte((const uint8_t*)i); // read data
|
||||
crc = _crc_ibutton_update(crc, eeprom_conf[i]); // calculate CRC
|
||||
}
|
||||
if (crc) { // CRC failed
|
||||
return 1; // stop doing anything
|
||||
}
|
||||
memcpy(&conf,eeprom_conf,sizeof(struct configuration)); // get configuration
|
||||
/* configure nRF24 transceiver */
|
||||
nrf24_set_rx_addr(conf.rx_addr); // set device receiving address
|
||||
nrf24_set_tx_addr(conf.tx_addr); // set transmission destination address
|
||||
nrf24_set_rf_channel(conf.channel); // set transceiver channel
|
||||
|
@ -112,6 +99,7 @@ int main(void)
|
|||
bool action = false; // to know if we performed any king of action during which some other activity could have happened
|
||||
|
||||
/* start watchdog */
|
||||
/*
|
||||
wdt_enable(WDTO_4S);
|
||||
while (true);
|
||||
WDTCSR = (1<<WDCE); // change settings
|
||||
|
@ -120,6 +108,7 @@ int main(void)
|
|||
WDTCSR = (1<<WDCE); // change settings
|
||||
WDTCSR = (1<<WDE)|(1<<WDIE); // enable interrupt than system reset mode
|
||||
while (true);
|
||||
*/
|
||||
|
||||
while (true) { // endless loop for micro-controller
|
||||
action = false; // new cycle of actions
|
||||
|
|
|
@ -25,11 +25,4 @@ struct configuration {
|
|||
uint8_t channel; // nRF24 channel
|
||||
uint8_t request_period; // how many seconds between power meter requests
|
||||
};
|
||||
|
||||
/* spark counter default configuration stored in EEPROM
|
||||
* it's corresponds to the configuration structure
|
||||
* there is an additional CRC8 iButton/1Wire/Dallas/Maxim checksum
|
||||
* the variable order is reversed (avr-gcc behaviour?)
|
||||
*/
|
||||
uint8_t EEMEM eeprom_crc = 0xf6; // CRC8-ibutton checksum
|
||||
struct configuration EEMEM eeprom_default_conf = {{1,'h','o','m','e'},{0,'h','o','m','e'},42,5};
|
||||
struct configuration conf = {{1,'h','o','m','e'},{0,'h','o','m','e'},42,5};
|
||||
|
|
Loading…
Reference in New Issue