Merge pull request #67 from kadrim/patch-1

Add EEPROM Emulation Layer for SAMD CPU (Feather M0 etc.)
This commit is contained in:
Paweł Spychalski
2018-07-10 10:27:01 +02:00
committed by GitHub
4 changed files with 17 additions and 5 deletions

View File

@@ -23,7 +23,7 @@ before_install:
fi
- arduino --pref "boardsmanager.additional.urls=" --save-prefs
install:
- arduino --install-library "U8g2"
- arduino --install-library "U8g2","FlashStorage"
script:
- cp -f $PWD/crossbow/configurations/config_${CONFIG}.h $PWD/crossbow/config.h &&
arduino --verify --board $BOARD $PWD/crossbow/crossbow.ino

View File

@@ -23,6 +23,7 @@ Needs implementation:
To compile, following libraries have to be installed:
* [U8g2](https://github.com/olikraus/u8g2) for OLED support in TX module
* [FlashStorage](https://github.com/cmaglie/FlashStorage) for EEPROM-Emulation if using a SAMD-Board (M0 etc.)
# Protocol

View File

@@ -20,6 +20,9 @@ void PlatformNode::seed(void) {
EEPROM.write(EEPROM_ADDRESS_BIND_2, random(1, 255)); //Yes, from 1 to 254
EEPROM.write(EEPROM_ADDRESS_BIND_3, random(1, 255)); //Yes, from 1 to 254
EEPROM.write(EEPROM_ADDRESS_BIND_KEY_SEEDED, 0xf1);
#ifdef ARDUINO_SAMD_FEATHER_M0
EEPROM.commit();
#endif
}
}
@@ -36,6 +39,9 @@ void PlatformNode::saveBindKey(uint8_t key[]) {
EEPROM.write(EEPROM_ADDRESS_BIND_2, key[2]);
EEPROM.write(EEPROM_ADDRESS_BIND_3, key[3]);
EEPROM.write(EEPROM_ADDRESS_BIND_KEY_SEEDED, 0xf1);
#ifdef ARDUINO_SAMD_FEATHER_M0
EEPROM.commit();
#endif
}
int PlatformNode::getRcChannel(uint8_t channel) {

View File

@@ -2,7 +2,12 @@
#include "Arduino.h"
#include "radio_node.h"
#ifdef ARDUINO_AVR_FEATHER32U4
#include <EEPROM.h>
#elif defined(ARDUINO_SAMD_FEATHER_M0)
// Include EEPROM-like API for FlashStorage
#include <FlashAsEEPROM.h>
#endif
#ifndef PLATFORM_NODE_H
#define PLATFORM_NODE_H