mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2024-10-01 03:15:39 -04:00
Prepared EEPROM functionality
This commit is contained in:
parent
8a604f911b
commit
4d943999d5
6
Config.h
6
Config.h
@ -1,9 +1,13 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#define MCU_328P 0x90
|
||||
#define MCU_328P 0x90
|
||||
#define MCU_1284P 0x91
|
||||
|
||||
#define PRODUCT_RNODE 0x03
|
||||
#define MODEL_A4 0xA4
|
||||
#define MODEL_A9 0xA9
|
||||
|
||||
#if defined(__AVR_ATmega328P__)
|
||||
#define MCU_VARIANT MCU_328P
|
||||
#warning "Firmware is being compiled for atmega328p based boards"
|
||||
|
36
EEPROM.cpp
Normal file
36
EEPROM.cpp
Normal file
@ -0,0 +1,36 @@
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
#include "Config.h"
|
||||
#include "Framing.h"
|
||||
|
||||
#define ADDR_PRODUCT 0x00
|
||||
#define ADDR_MODEL 0x01
|
||||
#define ADDR_HW_REV 0x02
|
||||
#define ADDR_SERIAL 0x03
|
||||
#define ADDR_MADE 0x06
|
||||
#define ADDR_CHKSUM 0x0A
|
||||
#define ADDR_SIGNATURE 0x1A
|
||||
#define ADDR_INFO_LOCK 0x9A
|
||||
#define INFO_LOCK_BYTE 0x73
|
||||
|
||||
#define ADDR_CONF_SF 0x74
|
||||
#define ADDR_CONF_CR 0x75
|
||||
#define ADDR_CONF_TXP 0x76
|
||||
#define ADDR_CONF_BW 0x77
|
||||
#define ADDR_CONF_FREQ 0x7B
|
||||
#define ADDR_CONF_OK 0x7F
|
||||
#define CONF_OK_BYTE 0x73
|
||||
|
||||
void eeprom_dump_info() {
|
||||
for (int addr = ADDR_PRODUCT; addr <= ADDR_INFO_LOCK; addr++) {
|
||||
uint8_t rom_byte = EEPROM.read(addr);
|
||||
Serial.write(rom_byte);
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_dump_config() {
|
||||
for (int addr = ADDR_CONF_SF; addr <= ADDR_CONF_OK; addr++) {
|
||||
uint8_t rom_byte = EEPROM.read(addr);
|
||||
Serial.write(rom_byte);
|
||||
}
|
||||
}
|
@ -22,6 +22,11 @@
|
||||
#define CMD_BLINK 0x30
|
||||
#define CMD_RANDOM 0x40
|
||||
|
||||
#define CMD_INFO_READ 0x50
|
||||
#define CMD_INFO_WRITE 0x51
|
||||
#define CMD_CONF_READ 0x52
|
||||
#define CMD_CONF_WRITE 0x53
|
||||
|
||||
#define RADIO_STATE_OFF 0x00
|
||||
#define RADIO_STATE_ON 0x01
|
||||
|
||||
|
6
LoRa.cpp
6
LoRa.cpp
@ -6,7 +6,7 @@
|
||||
|
||||
#include <LoRa.h>
|
||||
|
||||
// registers
|
||||
// Registers
|
||||
#define REG_FIFO 0x00
|
||||
#define REG_OP_MODE 0x01
|
||||
#define REG_FRF_MSB 0x06
|
||||
@ -39,7 +39,7 @@
|
||||
#define REG_DIO_MAPPING_1 0x40
|
||||
#define REG_VERSION 0x42
|
||||
|
||||
// modes
|
||||
// Modes
|
||||
#define MODE_LONG_RANGE_MODE 0x80
|
||||
#define MODE_SLEEP 0x00
|
||||
#define MODE_STDBY 0x01
|
||||
@ -112,7 +112,7 @@ int LoRaClass::begin(long frequency)
|
||||
writeRegister(REG_MODEM_CONFIG_3, 0x04);
|
||||
|
||||
// set output power to 17 dBm
|
||||
setTxPower(17);
|
||||
setTxPower(2);
|
||||
|
||||
// put in standby mode
|
||||
idle();
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <LoRa.h>
|
||||
#include "Config.h"
|
||||
#include "Framing.h"
|
||||
#include "EEPROM.cpp"
|
||||
#include "Utilities.cpp"
|
||||
|
||||
void setup() {
|
||||
@ -360,6 +361,8 @@ void loop() {
|
||||
dcd_waiting = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
led_indicate_standby();
|
||||
}
|
||||
|
||||
if (Serial.available()) {
|
||||
|
@ -51,6 +51,26 @@ void led_indicate_info(int cycles) {
|
||||
digitalWrite(pin_led_rx, LOW);
|
||||
}
|
||||
|
||||
uint8_t led_standby_min = 1;
|
||||
uint8_t led_standby_max = 22;
|
||||
uint8_t led_standby_value = led_standby_min;
|
||||
int8_t led_standby_direction = 0;
|
||||
unsigned long led_standby_ticks = 0;
|
||||
unsigned long led_standby_wait = 11000;
|
||||
void led_indicate_standby() {
|
||||
led_standby_ticks++;
|
||||
if (led_standby_ticks > led_standby_wait) {
|
||||
led_standby_ticks = 0;
|
||||
if (led_standby_value <= led_standby_min) {
|
||||
led_standby_direction = 1;
|
||||
} else if (led_standby_value >= led_standby_max) {
|
||||
led_standby_direction = -1;
|
||||
}
|
||||
led_standby_value += led_standby_direction;
|
||||
analogWrite(pin_led_rx, led_standby_value);
|
||||
}
|
||||
}
|
||||
|
||||
void escapedSerialWrite(uint8_t byte) {
|
||||
if (byte == FEND) { Serial.write(FESC); byte = TFEND; }
|
||||
if (byte == FESC) { Serial.write(FESC); byte = TFESC; }
|
||||
|
Loading…
Reference in New Issue
Block a user