trunk fmt
This commit is contained in:
+18
-18
@@ -351,19 +351,19 @@ class AnalogBatteryLevel : public HasBatteryLevel
|
|||||||
virtual bool isVbusIn() override
|
virtual bool isVbusIn() override
|
||||||
{
|
{
|
||||||
#ifdef EXT_PWR_DETECT
|
#ifdef EXT_PWR_DETECT
|
||||||
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
||||||
// if external powered that pin will be pulled down
|
// if external powered that pin will be pulled down
|
||||||
if (digitalRead(EXT_PWR_DETECT) == LOW) {
|
if (digitalRead(EXT_PWR_DETECT) == LOW) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if it's not LOW - check the battery
|
// if it's not LOW - check the battery
|
||||||
#else
|
#else
|
||||||
// if external powered that pin will be pulled up
|
// if external powered that pin will be pulled up
|
||||||
if (digitalRead(EXT_PWR_DETECT) == HIGH) {
|
if (digitalRead(EXT_PWR_DETECT) == HIGH) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if it's not HIGH - check the battery
|
// if it's not HIGH - check the battery
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return getBattVoltage() > chargingVolt;
|
return getBattVoltage() > chargingVolt;
|
||||||
}
|
}
|
||||||
@@ -461,11 +461,11 @@ Power::Power() : OSThread("Power")
|
|||||||
bool Power::analogInit()
|
bool Power::analogInit()
|
||||||
{
|
{
|
||||||
#ifdef EXT_PWR_DETECT
|
#ifdef EXT_PWR_DETECT
|
||||||
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
#ifdef HELTEC_CAPSULE_SENSOR_V3
|
||||||
pinMode(EXT_PWR_DETECT, INPUT_PULLUP);
|
pinMode(EXT_PWR_DETECT, INPUT_PULLUP);
|
||||||
#else
|
#else
|
||||||
pinMode(EXT_PWR_DETECT, INPUT);
|
pinMode(EXT_PWR_DETECT, INPUT);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef EXT_CHRG_DETECT
|
#ifdef EXT_CHRG_DETECT
|
||||||
pinMode(EXT_CHRG_DETECT, ext_chrg_detect_mode);
|
pinMode(EXT_CHRG_DETECT, ext_chrg_detect_mode);
|
||||||
|
|||||||
+20
-20
@@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../variants/rak2560/RAK9154Sensor.h"
|
||||||
#include "PowerStatus.h"
|
#include "PowerStatus.h"
|
||||||
#include "concurrency/OSThread.h"
|
#include "concurrency/OSThread.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "../variants/rak2560/RAK9154Sensor.h"
|
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#include <esp_adc_cal.h>
|
#include <esp_adc_cal.h>
|
||||||
@@ -56,31 +56,31 @@ extern RAK9154Sensor rak9154Sensor;
|
|||||||
class Power : private concurrency::OSThread
|
class Power : private concurrency::OSThread
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Observable<const meshtastic::PowerStatus *> newStatus;
|
Observable<const meshtastic::PowerStatus *> newStatus;
|
||||||
|
|
||||||
Power();
|
Power();
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
void readPowerStatus();
|
void readPowerStatus();
|
||||||
virtual bool setup();
|
virtual bool setup();
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
void setStatusHandler(meshtastic::PowerStatus *handler) { statusHandler = handler; }
|
||||||
const uint16_t OCV[11] = {OCV_ARRAY};
|
const uint16_t OCV[11] = {OCV_ARRAY};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
meshtastic::PowerStatus *statusHandler;
|
meshtastic::PowerStatus *statusHandler;
|
||||||
|
|
||||||
/// Setup a xpowers chip axp192/axp2101, return true if found
|
/// Setup a xpowers chip axp192/axp2101, return true if found
|
||||||
bool axpChipInit();
|
bool axpChipInit();
|
||||||
/// Setup a simple ADC input based battery sensor
|
/// Setup a simple ADC input based battery sensor
|
||||||
bool analogInit();
|
bool analogInit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// open circuit voltage lookup table
|
// open circuit voltage lookup table
|
||||||
uint8_t low_voltage_counter;
|
uint8_t low_voltage_counter;
|
||||||
#ifdef DEBUG_HEAP
|
#ifdef DEBUG_HEAP
|
||||||
uint32_t lastheap;
|
uint32_t lastheap;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+103
-111
@@ -4,8 +4,8 @@
|
|||||||
#include "../modules/Telemetry/Sensor/TelemetrySensor.h"
|
#include "../modules/Telemetry/Sensor/TelemetrySensor.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
#include <RAK-OneWireSerial.h>
|
|
||||||
#include "concurrency/Periodic.h"
|
#include "concurrency/Periodic.h"
|
||||||
|
#include <RAK-OneWireSerial.h>
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
|
|
||||||
@@ -27,165 +27,157 @@ static uint8_t provision = 0;
|
|||||||
|
|
||||||
static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT_E eid, uint8_t *msg, uint16_t len)
|
static void onewire_evt(const uint8_t pid, const uint8_t sid, const SNHUBAPI_EVT_E eid, uint8_t *msg, uint16_t len)
|
||||||
{
|
{
|
||||||
switch (eid)
|
switch (eid) {
|
||||||
{
|
case SNHUBAPI_EVT_RECV_REQ:
|
||||||
case SNHUBAPI_EVT_RECV_REQ:
|
case SNHUBAPI_EVT_RECV_RSP:
|
||||||
case SNHUBAPI_EVT_RECV_RSP:
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case SNHUBAPI_EVT_QSEND:
|
case SNHUBAPI_EVT_QSEND:
|
||||||
mySerial.write(msg, len);
|
mySerial.write(msg, len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_ADD_SID:
|
case SNHUBAPI_EVT_ADD_SID:
|
||||||
// LOG_INFO("+ADD:SID:[%02x]\r\n", msg[0]);
|
// LOG_INFO("+ADD:SID:[%02x]\r\n", msg[0]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_ADD_PID:
|
case SNHUBAPI_EVT_ADD_PID:
|
||||||
// LOG_INFO("+ADD:PID:[%02x]\r\n", msg[0]);
|
// LOG_INFO("+ADD:PID:[%02x]\r\n", msg[0]);
|
||||||
#ifdef BOOT_DATA_REQ
|
#ifdef BOOT_DATA_REQ
|
||||||
provision = msg[0];
|
provision = msg[0];
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_GET_INTV:
|
case SNHUBAPI_EVT_GET_INTV:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_GET_ENABLE:
|
case SNHUBAPI_EVT_GET_ENABLE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_SDATA_REQ:
|
case SNHUBAPI_EVT_SDATA_REQ:
|
||||||
|
|
||||||
// LOG_INFO("+EVT:PID[%02x],IPSO[%02x]\r\n",pid,msg[0]);
|
// LOG_INFO("+EVT:PID[%02x],IPSO[%02x]\r\n",pid,msg[0]);
|
||||||
// for( uint16_t i=1; i<len; i++)
|
// for( uint16_t i=1; i<len; i++)
|
||||||
// {
|
// {
|
||||||
// LOG_INFO("%02x,", msg[i]);
|
// LOG_INFO("%02x,", msg[i]);
|
||||||
// }
|
// }
|
||||||
// LOG_INFO("\r\n");
|
// LOG_INFO("\r\n");
|
||||||
switch (msg[0])
|
switch (msg[0]) {
|
||||||
{
|
case RAK_IPSO_CAPACITY:
|
||||||
case RAK_IPSO_CAPACITY:
|
dc_prec = msg[1];
|
||||||
dc_prec = msg[1];
|
if (dc_prec > 100) {
|
||||||
if (dc_prec > 100)
|
dc_prec = 100;
|
||||||
{
|
}
|
||||||
dc_prec = 100;
|
break;
|
||||||
}
|
case RAK_IPSO_DC_CURRENT:
|
||||||
break;
|
dc_cur = (msg[2] << 8) + msg[1];
|
||||||
case RAK_IPSO_DC_CURRENT:
|
break;
|
||||||
dc_cur = (msg[2] << 8) + msg[1];
|
case RAK_IPSO_DC_VOLTAGE:
|
||||||
break;
|
dc_vol = (msg[2] << 8) + msg[1];
|
||||||
case RAK_IPSO_DC_VOLTAGE:
|
dc_vol *= 10;
|
||||||
dc_vol = (msg[2] << 8) + msg[1];
|
break;
|
||||||
dc_vol *= 10;
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SNHUBAPI_EVT_REPORT:
|
case SNHUBAPI_EVT_REPORT:
|
||||||
|
|
||||||
// LOG_INFO("+EVT:PID[%02x],IPSO[%02x]\r\n",pid,msg[0]);
|
// LOG_INFO("+EVT:PID[%02x],IPSO[%02x]\r\n",pid,msg[0]);
|
||||||
// for( uint16_t i=1; i<len; i++)
|
// for( uint16_t i=1; i<len; i++)
|
||||||
// {
|
// {
|
||||||
// LOG_INFO("%02x,", msg[i]);
|
// LOG_INFO("%02x,", msg[i]);
|
||||||
// }
|
// }
|
||||||
// LOG_INFO("\r\n");
|
// LOG_INFO("\r\n");
|
||||||
|
|
||||||
switch (msg[0])
|
switch (msg[0]) {
|
||||||
{
|
case RAK_IPSO_CAPACITY:
|
||||||
case RAK_IPSO_CAPACITY:
|
dc_prec = msg[1];
|
||||||
dc_prec = msg[1];
|
if (dc_prec > 100) {
|
||||||
if (dc_prec > 100)
|
dc_prec = 100;
|
||||||
{
|
}
|
||||||
dc_prec = 100;
|
break;
|
||||||
}
|
case RAK_IPSO_DC_CURRENT:
|
||||||
break;
|
dc_cur = (msg[1] << 8) + msg[2];
|
||||||
case RAK_IPSO_DC_CURRENT:
|
break;
|
||||||
dc_cur = (msg[1] << 8) + msg[2];
|
case RAK_IPSO_DC_VOLTAGE:
|
||||||
break;
|
dc_vol = (msg[1] << 8) + msg[2];
|
||||||
case RAK_IPSO_DC_VOLTAGE:
|
dc_vol *= 10;
|
||||||
dc_vol = (msg[1] << 8) + msg[2];
|
break;
|
||||||
dc_vol *= 10;
|
default:
|
||||||
break;
|
break;
|
||||||
default:
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_CHKSUM_ERR:
|
case SNHUBAPI_EVT_CHKSUM_ERR:
|
||||||
LOG_INFO("+ERR:CHKSUM\r\n");
|
LOG_INFO("+ERR:CHKSUM\r\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SNHUBAPI_EVT_SEQ_ERR:
|
case SNHUBAPI_EVT_SEQ_ERR:
|
||||||
LOG_INFO("+ERR:SEQUCE\r\n");
|
LOG_INFO("+ERR:SEQUCE\r\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t onewireHandle()
|
static int32_t onewireHandle()
|
||||||
{
|
{
|
||||||
if (provision != 0)
|
if (provision != 0) {
|
||||||
{
|
RakSNHub_Protocl_API.get.data(provision);
|
||||||
RakSNHub_Protocl_API.get.data(provision);
|
provision = 0;
|
||||||
provision = 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
while (mySerial.available())
|
while (mySerial.available()) {
|
||||||
{
|
char a = mySerial.read();
|
||||||
char a = mySerial.read();
|
buff[bufflen++] = a;
|
||||||
buff[bufflen++] = a;
|
delay(2); // continue data, timeout=2ms
|
||||||
delay(2); // continue data, timeout=2ms
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (bufflen != 0)
|
if (bufflen != 0) {
|
||||||
{
|
RakSNHub_Protocl_API.process((uint8_t *)buff, bufflen);
|
||||||
RakSNHub_Protocl_API.process((uint8_t *)buff, bufflen);
|
bufflen = 0;
|
||||||
bufflen = 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 50;
|
return 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t RAK9154Sensor::runOnce()
|
int32_t RAK9154Sensor::runOnce()
|
||||||
{
|
{
|
||||||
onewirePeriodic = new Periodic("onewireHandle", onewireHandle);
|
onewirePeriodic = new Periodic("onewireHandle", onewireHandle);
|
||||||
|
|
||||||
mySerial.begin(9600);
|
mySerial.begin(9600);
|
||||||
|
|
||||||
RakSNHub_Protocl_API.init(onewire_evt);
|
RakSNHub_Protocl_API.init(onewire_evt);
|
||||||
|
|
||||||
status = true;
|
status = true;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RAK9154Sensor::setup()
|
void RAK9154Sensor::setup()
|
||||||
{
|
{
|
||||||
// Set up oversampling and filter initialization
|
// Set up oversampling and filter initialization
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RAK9154Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
bool RAK9154Sensor::getMetrics(meshtastic_Telemetry *measurement)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t RAK9154Sensor::getBusVoltageMv()
|
uint16_t RAK9154Sensor::getBusVoltageMv()
|
||||||
{
|
{
|
||||||
return dc_vol;
|
return dc_vol;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RAK9154Sensor::getBusBatteryPercent()
|
int RAK9154Sensor::getBusBatteryPercent()
|
||||||
{
|
{
|
||||||
return (int)dc_prec;
|
return (int)dc_prec;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RAK9154Sensor::isCharging()
|
bool RAK9154Sensor::isCharging()
|
||||||
{
|
{
|
||||||
return (dc_cur > 0) ? true : false;
|
return (dc_cur > 0) ? true : false;
|
||||||
}
|
}
|
||||||
#endif // HAS_RAKPROT
|
#endif // HAS_RAKPROT
|
||||||
@@ -1,22 +1,23 @@
|
|||||||
import sys
|
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
Import("env")
|
Import("env")
|
||||||
|
|
||||||
|
|
||||||
# Parse input and create UF2 file
|
# Parse input and create UF2 file
|
||||||
def create_uf2(source, target, env):
|
def create_uf2(source, target, env):
|
||||||
# source_hex = target[0].get_abspath()
|
# source_hex = target[0].get_abspath()
|
||||||
source_hex = target[0].get_string(False)
|
source_hex = target[0].get_string(False)
|
||||||
source_hex = '.\\'+source_hex
|
source_hex = ".\\" + source_hex
|
||||||
print("#########################################################")
|
print("#########################################################")
|
||||||
print("Create UF2 from "+source_hex)
|
print("Create UF2 from " + source_hex)
|
||||||
print("#########################################################")
|
print("#########################################################")
|
||||||
# print("Source: " + source_hex)
|
# print("Source: " + source_hex)
|
||||||
target = source_hex.replace(".hex", "")
|
target = source_hex.replace(".hex", "")
|
||||||
target = target + ".uf2"
|
target = target + ".uf2"
|
||||||
# print("Target: " + target)
|
# print("Target: " + target)
|
||||||
|
|
||||||
with open(source_hex, mode='rb') as f:
|
with open(source_hex, mode="rb") as f:
|
||||||
inpbuf = f.read()
|
inpbuf = f.read()
|
||||||
|
|
||||||
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
|
outbuf = convert_from_hex_to_uf2(inpbuf.decode("utf-8"))
|
||||||
@@ -48,9 +49,17 @@ class Block:
|
|||||||
flags = 0x0
|
flags = 0x0
|
||||||
if familyid:
|
if familyid:
|
||||||
flags |= 0x2000
|
flags |= 0x2000
|
||||||
hd = struct.pack("<IIIIIIII",
|
hd = struct.pack(
|
||||||
UF2_MAGIC_START0, UF2_MAGIC_START1,
|
"<IIIIIIII",
|
||||||
flags, self.addr, 256, blockno, numblocks, familyid)
|
UF2_MAGIC_START0,
|
||||||
|
UF2_MAGIC_START1,
|
||||||
|
flags,
|
||||||
|
self.addr,
|
||||||
|
256,
|
||||||
|
blockno,
|
||||||
|
numblocks,
|
||||||
|
familyid,
|
||||||
|
)
|
||||||
hd += self.bytes[0:256]
|
hd += self.bytes[0:256]
|
||||||
while len(hd) < 512 - 4:
|
while len(hd) < 512 - 4:
|
||||||
hd += b"\x00"
|
hd += b"\x00"
|
||||||
@@ -70,20 +79,20 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
upper = 0
|
upper = 0
|
||||||
currblock = None
|
currblock = None
|
||||||
blocks = []
|
blocks = []
|
||||||
for line in buf.split('\n'):
|
for line in buf.split("\n"):
|
||||||
if line[0] != ":":
|
if line[0] != ":":
|
||||||
continue
|
continue
|
||||||
i = 1
|
i = 1
|
||||||
rec = []
|
rec = []
|
||||||
while i < len(line) - 1:
|
while i < len(line) - 1:
|
||||||
rec.append(int(line[i:i+2], 16))
|
rec.append(int(line[i : i + 2], 16))
|
||||||
i += 2
|
i += 2
|
||||||
tp = rec[3]
|
tp = rec[3]
|
||||||
if tp == 4:
|
if tp == 4:
|
||||||
upper = ((rec[4] << 8) | rec[5]) << 16
|
upper = ((rec[4] << 8) | rec[5]) << 16
|
||||||
elif tp == 2:
|
elif tp == 2:
|
||||||
upper = ((rec[4] << 8) | rec[5]) << 4
|
upper = ((rec[4] << 8) | rec[5]) << 4
|
||||||
assert (upper & 0xffff) == 0
|
assert (upper & 0xFFFF) == 0
|
||||||
elif tp == 1:
|
elif tp == 1:
|
||||||
break
|
break
|
||||||
elif tp == 0:
|
elif tp == 0:
|
||||||
@@ -92,10 +101,10 @@ def convert_from_hex_to_uf2(buf):
|
|||||||
appstartaddr = addr
|
appstartaddr = addr
|
||||||
i = 4
|
i = 4
|
||||||
while i < len(rec) - 1:
|
while i < len(rec) - 1:
|
||||||
if not currblock or currblock.addr & ~0xff != addr & ~0xff:
|
if not currblock or currblock.addr & ~0xFF != addr & ~0xFF:
|
||||||
currblock = Block(addr & ~0xff)
|
currblock = Block(addr & ~0xFF)
|
||||||
blocks.append(currblock)
|
blocks.append(currblock)
|
||||||
currblock.bytes[addr & 0xff] = rec[i]
|
currblock.bytes[addr & 0xFF] = rec[i]
|
||||||
addr += 1
|
addr += 1
|
||||||
i += 1
|
i += 1
|
||||||
numblocks = len(blocks)
|
numblocks = len(blocks)
|
||||||
|
|||||||
+51
-52
@@ -34,8 +34,7 @@
|
|||||||
#include "WVariant.h"
|
#include "WVariant.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C" {
|
||||||
{
|
|
||||||
#endif // __cplusplus
|
#endif // __cplusplus
|
||||||
|
|
||||||
// Number of pins defined in PinDescription array
|
// Number of pins defined in PinDescription array
|
||||||
@@ -56,9 +55,9 @@ extern "C"
|
|||||||
|
|
||||||
#define LED_STATE_ON 1 // State when LED is litted
|
#define LED_STATE_ON 1 // State when LED is litted
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Buttons
|
* Buttons
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PIN_BUTTON1 9 // Pin for button on E-ink button module or IO expansion
|
#define PIN_BUTTON1 9 // Pin for button on E-ink button module or IO expansion
|
||||||
#define BUTTON_NEED_PULLUP
|
#define BUTTON_NEED_PULLUP
|
||||||
@@ -78,14 +77,14 @@ extern "C"
|
|||||||
#define PIN_A6 (0xff)
|
#define PIN_A6 (0xff)
|
||||||
#define PIN_A7 (0xff)
|
#define PIN_A7 (0xff)
|
||||||
|
|
||||||
static const uint8_t A0 = PIN_A0;
|
static const uint8_t A0 = PIN_A0;
|
||||||
static const uint8_t A1 = PIN_A1;
|
static const uint8_t A1 = PIN_A1;
|
||||||
static const uint8_t A2 = PIN_A2;
|
static const uint8_t A2 = PIN_A2;
|
||||||
static const uint8_t A3 = PIN_A3;
|
static const uint8_t A3 = PIN_A3;
|
||||||
static const uint8_t A4 = PIN_A4;
|
static const uint8_t A4 = PIN_A4;
|
||||||
static const uint8_t A5 = PIN_A5;
|
static const uint8_t A5 = PIN_A5;
|
||||||
static const uint8_t A6 = PIN_A6;
|
static const uint8_t A6 = PIN_A6;
|
||||||
static const uint8_t A7 = PIN_A7;
|
static const uint8_t A7 = PIN_A7;
|
||||||
#define ADC_RESOLUTION 14
|
#define ADC_RESOLUTION 14
|
||||||
|
|
||||||
// Other pins
|
// Other pins
|
||||||
@@ -93,7 +92,7 @@ extern "C"
|
|||||||
#define PIN_NFC1 (9)
|
#define PIN_NFC1 (9)
|
||||||
#define PIN_NFC2 (10)
|
#define PIN_NFC2 (10)
|
||||||
|
|
||||||
static const uint8_t AREF = PIN_AREF;
|
static const uint8_t AREF = PIN_AREF;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Serial interfaces
|
* Serial interfaces
|
||||||
@@ -118,14 +117,14 @@ extern "C"
|
|||||||
#define PIN_SPI1_MOSI (30) // (0 + 30)
|
#define PIN_SPI1_MOSI (30) // (0 + 30)
|
||||||
#define PIN_SPI1_SCK (3) // (0 + 3)
|
#define PIN_SPI1_SCK (3) // (0 + 3)
|
||||||
|
|
||||||
static const uint8_t SS = 42;
|
static const uint8_t SS = 42;
|
||||||
static const uint8_t MOSI = PIN_SPI_MOSI;
|
static const uint8_t MOSI = PIN_SPI_MOSI;
|
||||||
static const uint8_t MISO = PIN_SPI_MISO;
|
static const uint8_t MISO = PIN_SPI_MISO;
|
||||||
static const uint8_t SCK = PIN_SPI_SCK;
|
static const uint8_t SCK = PIN_SPI_SCK;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* eink display pins
|
* eink display pins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PIN_EINK_CS (0 + 26)
|
#define PIN_EINK_CS (0 + 26)
|
||||||
#define PIN_EINK_BUSY (0 + 4)
|
#define PIN_EINK_BUSY (0 + 4)
|
||||||
@@ -159,44 +158,44 @@ extern "C"
|
|||||||
#define EXTERNAL_FLASH_DEVICES IS25LP080D
|
#define EXTERNAL_FLASH_DEVICES IS25LP080D
|
||||||
#define EXTERNAL_FLASH_USE_QSPI
|
#define EXTERNAL_FLASH_USE_QSPI
|
||||||
|
|
||||||
/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports
|
/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports
|
||||||
RAK5005-O <-> nRF52840
|
RAK5005-O <-> nRF52840
|
||||||
IO1 <-> P0.17 (Arduino GPIO number 17)
|
IO1 <-> P0.17 (Arduino GPIO number 17)
|
||||||
IO2 <-> P1.02 (Arduino GPIO number 34)
|
IO2 <-> P1.02 (Arduino GPIO number 34)
|
||||||
IO3 <-> P0.21 (Arduino GPIO number 21)
|
IO3 <-> P0.21 (Arduino GPIO number 21)
|
||||||
IO4 <-> P0.04 (Arduino GPIO number 4)
|
IO4 <-> P0.04 (Arduino GPIO number 4)
|
||||||
IO5 <-> P0.09 (Arduino GPIO number 9)
|
IO5 <-> P0.09 (Arduino GPIO number 9)
|
||||||
IO6 <-> P0.10 (Arduino GPIO number 10)
|
IO6 <-> P0.10 (Arduino GPIO number 10)
|
||||||
IO7 <-> P0.28 (Arduino GPIO number 28)
|
IO7 <-> P0.28 (Arduino GPIO number 28)
|
||||||
SW1 <-> P0.01 (Arduino GPIO number 1)
|
SW1 <-> P0.01 (Arduino GPIO number 1)
|
||||||
A0 <-> P0.04/AIN2 (Arduino Analog A2
|
A0 <-> P0.04/AIN2 (Arduino Analog A2
|
||||||
A1 <-> P0.31/AIN7 (Arduino Analog A7
|
A1 <-> P0.31/AIN7 (Arduino Analog A7
|
||||||
SPI_CS <-> P0.26 (Arduino GPIO number 26)
|
SPI_CS <-> P0.26 (Arduino GPIO number 26)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// RAK4630 LoRa module
|
// RAK4630 LoRa module
|
||||||
|
|
||||||
/* Setup of the SX1262 LoRa module ( https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/ )
|
/* Setup of the SX1262 LoRa module ( https://docs.rakwireless.com/Product-Categories/WisBlock/RAK4631/Datasheet/ )
|
||||||
|
|
||||||
P1.10 NSS SPI NSS (Arduino GPIO number 42)
|
P1.10 NSS SPI NSS (Arduino GPIO number 42)
|
||||||
P1.11 SCK SPI CLK (Arduino GPIO number 43)
|
P1.11 SCK SPI CLK (Arduino GPIO number 43)
|
||||||
P1.12 MOSI SPI MOSI (Arduino GPIO number 44)
|
P1.12 MOSI SPI MOSI (Arduino GPIO number 44)
|
||||||
P1.13 MISO SPI MISO (Arduino GPIO number 45)
|
P1.13 MISO SPI MISO (Arduino GPIO number 45)
|
||||||
P1.14 BUSY BUSY signal (Arduino GPIO number 46)
|
P1.14 BUSY BUSY signal (Arduino GPIO number 46)
|
||||||
P1.15 DIO1 DIO1 event interrupt (Arduino GPIO number 47)
|
P1.15 DIO1 DIO1 event interrupt (Arduino GPIO number 47)
|
||||||
P1.06 NRESET NRESET manual reset of the SX1262 (Arduino GPIO number 38)
|
P1.06 NRESET NRESET manual reset of the SX1262 (Arduino GPIO number 38)
|
||||||
|
|
||||||
Important for successful SX1262 initialization:
|
Important for successful SX1262 initialization:
|
||||||
|
|
||||||
* Setup DIO2 to control the antenna switch
|
* Setup DIO2 to control the antenna switch
|
||||||
* Setup DIO3 to control the TCXO power supply
|
* Setup DIO3 to control the TCXO power supply
|
||||||
* Setup the SX1262 to use it's DCDC regulator and not the LDO
|
* Setup the SX1262 to use it's DCDC regulator and not the LDO
|
||||||
* RAK4630 schematics show GPIO P1.07 connected to the antenna switch, but it should not be initialized, as DIO2 will do the
|
* RAK4630 schematics show GPIO P1.07 connected to the antenna switch, but it should not be initialized, as DIO2 will do the
|
||||||
control of the antenna switch
|
control of the antenna switch
|
||||||
|
|
||||||
SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
SO GPIO 39/TXEN MAY NOT BE DEFINED FOR SUCCESSFUL OPERATION OF THE SX1262 - TG
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DETECTION_SENSOR_EN 4
|
#define DETECTION_SENSOR_EN 4
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user