mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2025-08-05 21:14:23 -04:00
Cleanup
This commit is contained in:
parent
a739d6f3ab
commit
97806d1684
2 changed files with 44 additions and 43 deletions
|
@ -995,9 +995,9 @@ void serialCallback(uint8_t sbyte) {
|
||||||
if (sbyte == TFESC) sbyte = FESC;
|
if (sbyte == TFESC) sbyte = FESC;
|
||||||
ESCAPE = false;
|
ESCAPE = false;
|
||||||
}
|
}
|
||||||
npi = sbyte;
|
sbyte;
|
||||||
led_set_intensity(npi);
|
led_set_intensity(sbyte);
|
||||||
np_int_conf_save(npi);
|
np_int_conf_save(sbyte);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
81
Utilities.h
81
Utilities.h
|
@ -117,8 +117,9 @@ uint8_t boot_vector = 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
void led_init() {
|
void led_init() {
|
||||||
if (EEPROM.read(eeprom_addr(ADDR_CONF_PSET)) != 0xFF) {
|
if (EEPROM.read(eeprom_addr(ADDR_CONF_PSET)) == CONF_OK_BYTE) {
|
||||||
led_set_intensity(EEPROM.read(eeprom_addr(ADDR_CONF_PINT)));
|
uint8_t int_val = EEPROM.read(eeprom_addr(ADDR_CONF_PINT));
|
||||||
|
led_set_intensity(int_val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1181,11 +1182,11 @@ void promisc_disable() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool eeprom_info_locked() {
|
bool eeprom_info_locked() {
|
||||||
#if HAS_EEPROM
|
#if HAS_EEPROM
|
||||||
uint8_t lock_byte = EEPROM.read(eeprom_addr(ADDR_INFO_LOCK));
|
uint8_t lock_byte = EEPROM.read(eeprom_addr(ADDR_INFO_LOCK));
|
||||||
#elif MCU_VARIANT == MCU_NRF52
|
#elif MCU_VARIANT == MCU_NRF52
|
||||||
uint8_t lock_byte = eeprom_read(eeprom_addr(ADDR_INFO_LOCK));
|
uint8_t lock_byte = eeprom_read(eeprom_addr(ADDR_INFO_LOCK));
|
||||||
#endif
|
#endif
|
||||||
if (lock_byte == INFO_LOCK_BYTE) {
|
if (lock_byte == INFO_LOCK_BYTE) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1250,31 +1251,31 @@ void eeprom_update(int mapped_addr, uint8_t byte) {
|
||||||
EEPROM.write(mapped_addr, byte);
|
EEPROM.write(mapped_addr, byte);
|
||||||
EEPROM.commit();
|
EEPROM.commit();
|
||||||
}
|
}
|
||||||
#elif !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
#elif !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
||||||
// todo: clean up this implementation, writing one byte and syncing
|
// todo: clean up this implementation, writing one byte and syncing
|
||||||
// each time is really slow, but this is also suboptimal
|
// each time is really slow, but this is also suboptimal
|
||||||
uint8_t read_byte;
|
uint8_t read_byte;
|
||||||
void* read_byte_ptr = &read_byte;
|
void* read_byte_ptr = &read_byte;
|
||||||
file.seek(mapped_addr);
|
file.seek(mapped_addr);
|
||||||
file.read(read_byte_ptr, 1);
|
file.read(read_byte_ptr, 1);
|
||||||
file.seek(mapped_addr);
|
file.seek(mapped_addr);
|
||||||
if (read_byte != byte) {
|
if (read_byte != byte) {
|
||||||
file.write(byte);
|
file.write(byte);
|
||||||
}
|
}
|
||||||
written_bytes++;
|
written_bytes++;
|
||||||
|
|
||||||
if ((mapped_addr - eeprom_addr(0)) == ADDR_INFO_LOCK) {
|
if ((mapped_addr - eeprom_addr(0)) == ADDR_INFO_LOCK) {
|
||||||
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
||||||
// have to do a flush because we're only writing 1 byte and it syncs after 4
|
// have to do a flush because we're only writing 1 byte and it syncs after 4
|
||||||
eeprom_flush();
|
eeprom_flush();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (written_bytes >= 4) {
|
if (written_bytes >= 4) {
|
||||||
file.close();
|
file.close();
|
||||||
file.open(EEPROM_FILE, FILE_O_WRITE);
|
file.open(EEPROM_FILE, FILE_O_WRITE);
|
||||||
written_bytes = 0;
|
written_bytes = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1416,16 +1417,16 @@ bool eeprom_checksum_valid() {
|
||||||
void bt_conf_save(bool is_enabled) {
|
void bt_conf_save(bool is_enabled) {
|
||||||
if (is_enabled) {
|
if (is_enabled) {
|
||||||
eeprom_update(eeprom_addr(ADDR_CONF_BT), BT_ENABLE_BYTE);
|
eeprom_update(eeprom_addr(ADDR_CONF_BT), BT_ENABLE_BYTE);
|
||||||
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
||||||
// have to do a flush because we're only writing 1 byte and it syncs after 8
|
// have to do a flush because we're only writing 1 byte and it syncs after 8
|
||||||
eeprom_flush();
|
eeprom_flush();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
eeprom_update(eeprom_addr(ADDR_CONF_BT), 0x00);
|
eeprom_update(eeprom_addr(ADDR_CONF_BT), 0x00);
|
||||||
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
#if !HAS_EEPROM && MCU_VARIANT == MCU_NRF52
|
||||||
// have to do a flush because we're only writing 1 byte and it syncs after 8
|
// have to do a flush because we're only writing 1 byte and it syncs after 8
|
||||||
eeprom_flush();
|
eeprom_flush();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,7 +1443,7 @@ void db_conf_save(uint8_t val) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void np_int_conf_save(uint8_t p_int) {
|
void np_int_conf_save(uint8_t p_int) {
|
||||||
eeprom_update(eeprom_addr(ADDR_CONF_PSET), 0x01);
|
eeprom_update(eeprom_addr(ADDR_CONF_PSET), CONF_OK_BYTE);
|
||||||
eeprom_update(eeprom_addr(ADDR_CONF_PINT), p_int);
|
eeprom_update(eeprom_addr(ADDR_CONF_PINT), p_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue