aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKing Kévin <kingkevin@cuvoodoo.info>2015-11-08 18:56:14 +0100
committerKing Kévin <kingkevin@cuvoodoo.info>2015-11-08 18:56:14 +0100
commit6066ef44d8694068fd7b01f12474d65821f16c44 (patch)
tree57295c380e704b16d30691ab8b485fc1da1b921d
parent65807c648c8e9accd7f205a843e8439d6258d086 (diff)
remove configuration from eeprom and define it in header
-rw-r--r--arduino_nano/main.c17
-rw-r--r--arduino_nano/main.h9
2 files changed, 4 insertions, 22 deletions
diff --git a/arduino_nano/main.c b/arduino_nano/main.c
index d47c3b9..f2fc8ba 100644
--- a/arduino_nano/main.c
+++ b/arduino_nano/main.c
@@ -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
diff --git a/arduino_nano/main.h b/arduino_nano/main.h
index dc2916e..0b91aa5 100644
--- a/arduino_nano/main.h
+++ b/arduino_nano/main.h
@@ -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};