mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-25 17:42:48 +00:00
cubecell wip
This commit is contained in:
parent
fd2f5a5ba4
commit
a47524b762
@ -9,7 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = cubecellplus ; Note: the github actions CI test build can't yet build NRF52 targets
|
default_envs = nrf52dk ; Note: the github actions CI test build can't yet build NRF52 targets
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
; common is not currently used
|
; common is not currently used
|
||||||
@ -131,9 +131,9 @@ platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we us
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
board = cubecell_board_plus
|
board = cubecell_board_plus
|
||||||
; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO
|
; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO
|
||||||
build_flags = ${env.build_flags} -DARDUINO=100
|
build_flags = ${env.build_flags} -DARDUINO=100 -Isrc/cubecell
|
||||||
src_filter =
|
src_filter =
|
||||||
${env.src_filter} -<esp32/>
|
${env.src_filter} -<esp32/> -<nrf52/>
|
||||||
|
|
||||||
; Common settings for NRF52 based targets
|
; Common settings for NRF52 based targets
|
||||||
[nrf52_base]
|
[nrf52_base]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "freertosinc.h"
|
||||||
|
|
||||||
// FIXME - ugly check to see if we have freertos
|
#ifdef HAS_FREE_RTOS
|
||||||
#ifdef configUSE_PREEMPTION
|
|
||||||
|
|
||||||
class Thread
|
class Thread
|
||||||
{
|
{
|
||||||
|
@ -81,13 +81,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
#define NO_ESP32 // Don't use ESP32 libs (mainly bluetooth)
|
||||||
|
|
||||||
// We bind to the GPS using variant.h instead for this platform (Serial1)
|
|
||||||
|
|
||||||
// FIXME, not yet ready for NRF52
|
// FIXME, not yet ready for NRF52
|
||||||
#define RTC_DATA_ATTR
|
#define RTC_DATA_ATTR
|
||||||
|
|
||||||
#define LED_PIN PIN_LED1 // LED1 on nrf52840-DK
|
#define LED_PIN -1 // FIXME totally bogus
|
||||||
#define BUTTON_PIN PIN_BUTTON1
|
#define BUTTON_PIN -1
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
@ -189,7 +187,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define HW_VENDOR "heltec"
|
#define HW_VENDOR "heltec"
|
||||||
|
|
||||||
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
|
// the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine.
|
||||||
//Tested on Neo6m module.
|
// Tested on Neo6m module.
|
||||||
#undef GPS_RX_PIN
|
#undef GPS_RX_PIN
|
||||||
#undef GPS_TX_PIN
|
#undef GPS_TX_PIN
|
||||||
#define GPS_RX_PIN 36
|
#define GPS_RX_PIN 36
|
||||||
|
1
src/cubecell/FS.h
Normal file
1
src/cubecell/FS.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
// Placeholder FIXME
|
@ -1,19 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// The FreeRTOS includes are in a different directory on ESP32 and I can't figure out how to make that work with platformio gcc options
|
// The FreeRTOS includes are in a different directory on ESP32 and I can't figure out how to make that work with platformio gcc
|
||||||
// so this is my quick hack to make things work
|
// options so this is my quick hack to make things work
|
||||||
|
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
#define HAS_FREE_RTOS
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
|
||||||
#include <freertos/semphr.h>
|
|
||||||
#include <freertos/queue.h>
|
#include <freertos/queue.h>
|
||||||
|
#include <freertos/semphr.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
#else
|
#else
|
||||||
// not yet supported on cubecell
|
// not yet supported on cubecell
|
||||||
#ifndef CubeCell_BoardPlus
|
#ifndef CubeCell_BoardPlus
|
||||||
|
#define HAS_FREE_RTOS
|
||||||
#include <FreeRTOS.h>
|
#include <FreeRTOS.h>
|
||||||
#include <task.h>
|
|
||||||
#include <semphr.h>
|
|
||||||
#include <queue.h>
|
#include <queue.h>
|
||||||
|
#include <semphr.h>
|
||||||
|
#include <task.h>
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
typedef uint32_t TickType_t;
|
||||||
|
typedef uint32_t BaseType_t;
|
||||||
|
|
||||||
|
#define portMAX_DELAY UINT32_MAX
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
12
src/main.cpp
12
src/main.cpp
@ -44,6 +44,13 @@
|
|||||||
#include "BluetoothUtil.h"
|
#include "BluetoothUtil.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "RF95Interface.h"
|
||||||
|
#include "SX1262Interface.h"
|
||||||
|
|
||||||
|
#ifdef NRF52_SERIES
|
||||||
|
#include "variant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// We always create a screen object, but we only init it if we find the hardware
|
// We always create a screen object, but we only init it if we find the hardware
|
||||||
meshtastic::Screen screen(SSD1306_ADDRESS);
|
meshtastic::Screen screen(SSD1306_ADDRESS);
|
||||||
|
|
||||||
@ -117,12 +124,7 @@ static uint32_t ledBlinker()
|
|||||||
|
|
||||||
Periodic ledPeriodic(ledBlinker);
|
Periodic ledPeriodic(ledBlinker);
|
||||||
|
|
||||||
#include "RF95Interface.h"
|
|
||||||
#include "SX1262Interface.h"
|
|
||||||
|
|
||||||
#ifdef NO_ESP32
|
|
||||||
#include "variant.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -107,6 +107,7 @@ template <class T> class MemoryPool : public Allocator<T>
|
|||||||
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
|
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FREE_RTOS
|
||||||
/// Return a buffer from an ISR, if higherPriWoken is set to true you have some work to do ;-)
|
/// Return a buffer from an ISR, if higherPriWoken is set to true you have some work to do ;-)
|
||||||
void releaseFromISR(T *p, BaseType_t *higherPriWoken)
|
void releaseFromISR(T *p, BaseType_t *higherPriWoken)
|
||||||
{
|
{
|
||||||
@ -115,6 +116,7 @@ template <class T> class MemoryPool : public Allocator<T>
|
|||||||
(size_t)(p - buf) <
|
(size_t)(p - buf) <
|
||||||
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
|
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// Return a queable object which has been prefilled with zeros - allow timeout to wait for available buffers (you
|
/// Return a queable object which has been prefilled with zeros - allow timeout to wait for available buffers (you
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "SPIFFS.h"
|
|
||||||
|
|
||||||
#include "CryptoEngine.h"
|
#include "CryptoEngine.h"
|
||||||
#include "GPS.h"
|
#include "GPS.h"
|
||||||
@ -34,11 +33,14 @@ DeviceState versions used to be defined in the .proto file but really only this
|
|||||||
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
|
#define DEVICESTATE_MIN_VER DEVICESTATE_CUR_VER
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
|
// ESP32 version
|
||||||
|
#include "SPIFFS.h"
|
||||||
#define FS SPIFFS
|
#define FS SPIFFS
|
||||||
#define FSBegin() FS.begin(true)
|
#define FSBegin() FS.begin(true)
|
||||||
#define FILE_O_WRITE "w"
|
#define FILE_O_WRITE "w"
|
||||||
#define FILE_O_READ "r"
|
#define FILE_O_READ "r"
|
||||||
#else
|
#else
|
||||||
|
// NRF52 version
|
||||||
#include "InternalFileSystem.h"
|
#include "InternalFileSystem.h"
|
||||||
#define FS InternalFS
|
#define FS InternalFS
|
||||||
#define FSBegin() FS.begin()
|
#define FSBegin() FS.begin()
|
||||||
|
@ -35,9 +35,8 @@ class PacketRecordOrderFunction
|
|||||||
// If the timer ticks have rolled over the difference between times will be _enormous_. Handle that case specially
|
// If the timer ticks have rolled over the difference between times will be _enormous_. Handle that case specially
|
||||||
uint32_t t1 = p1.rxTimeMsec, t2 = p2.rxTimeMsec;
|
uint32_t t1 = p1.rxTimeMsec, t2 = p2.rxTimeMsec;
|
||||||
|
|
||||||
if (abs(t1 - t2) >
|
if (t1 - t2 > UINT32_MAX / 2) {
|
||||||
UINT32_MAX /
|
// time must have rolled over, swap them because the new little number is 'bigger' than the old big number
|
||||||
2) { // time must have rolled over, swap them because the new little number is 'bigger' than the old big number
|
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
t2 = p1.rxTimeMsec;
|
t2 = p1.rxTimeMsec;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ template <class T> class PointerQueue : public TypedQueue<T *>
|
|||||||
return this->dequeue(&p, maxWait) ? p : nullptr;
|
return this->dequeue(&p, maxWait) ? p : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAS_FREE_RTOS
|
||||||
// returns a ptr or null if the queue was empty
|
// returns a ptr or null if the queue was empty
|
||||||
T *dequeuePtrFromISR(BaseType_t *higherPriWoken)
|
T *dequeuePtrFromISR(BaseType_t *higherPriWoken)
|
||||||
{
|
{
|
||||||
@ -25,4 +26,5 @@ template <class T> class PointerQueue : public TypedQueue<T *>
|
|||||||
|
|
||||||
return this->dequeueFromISR(&p, higherPriWoken) ? p : nullptr;
|
return this->dequeueFromISR(&p, higherPriWoken) ? p : nullptr;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
#include "PeriodicTask.h"
|
#include "PeriodicTask.h"
|
||||||
#include "RadioInterface.h"
|
#include "RadioInterface.h"
|
||||||
|
|
||||||
|
#ifdef CubeCell_BoardPlus
|
||||||
|
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <RadioLib.h>
|
#include <RadioLib.h>
|
||||||
|
|
||||||
// ESP32 has special rules about ISR code
|
// ESP32 has special rules about ISR code
|
||||||
|
@ -48,7 +48,7 @@ struct PendingPacket {
|
|||||||
PendingPacket() {}
|
PendingPacket() {}
|
||||||
PendingPacket(MeshPacket *p);
|
PendingPacket(MeshPacket *p);
|
||||||
|
|
||||||
void setNextTx() { nextTxMsec = millis() + random(20 * 1000, 22 * 1000); }
|
void setNextTx() { nextTxMsec = millis() + random(20 * 1000L, 22 * 1000L); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalPacketIdHashFunction
|
class GlobalPacketIdHashFunction
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
#include "freertosinc.h"
|
#include "freertosinc.h"
|
||||||
|
|
||||||
|
#ifdef HAS_FREE_RTOS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for freertos queues. Note: each element object should be small
|
* A wrapper for freertos queues. Note: each element object should be small
|
||||||
* and POD (Plain Old Data type) as elements are memcpied by value.
|
* and POD (Plain Old Data type) as elements are memcpied by value.
|
||||||
@ -35,3 +37,45 @@ template <class T> class TypedQueue
|
|||||||
|
|
||||||
bool dequeueFromISR(T *p, BaseType_t *higherPriWoken) { return xQueueReceiveFromISR(h, p, higherPriWoken); }
|
bool dequeueFromISR(T *p, BaseType_t *higherPriWoken) { return xQueueReceiveFromISR(h, p, higherPriWoken); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A wrapper for freertos queues. Note: each element object should be small
|
||||||
|
* and POD (Plain Old Data type) as elements are memcpied by value.
|
||||||
|
*/
|
||||||
|
template <class T> class TypedQueue
|
||||||
|
{
|
||||||
|
std::queue<T> q;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TypedQueue(int maxElements) {}
|
||||||
|
|
||||||
|
// int numFree() { return uxQueueSpacesAvailable(h); }
|
||||||
|
|
||||||
|
bool isEmpty() { return q.empty(); }
|
||||||
|
|
||||||
|
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
|
||||||
|
{
|
||||||
|
q.push(x);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool enqueueFromISR(T x, BaseType_t *higherPriWoken) { return xQueueSendToBackFromISR(h, &x, higherPriWoken) == pdTRUE; }
|
||||||
|
|
||||||
|
bool dequeue(T *p, TickType_t maxWait = portMAX_DELAY)
|
||||||
|
{
|
||||||
|
if (isEmpty())
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
*p = q.front();
|
||||||
|
q.pop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool dequeueFromISR(T *p, BaseType_t *higherPriWoken) { return xQueueReceiveFromISR(h, p, higherPriWoken); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
@ -1,100 +0,0 @@
|
|||||||
#ifdef ARDUINO_NRF52840_PPR
|
|
||||||
#include "PmuBQ25703A.h"
|
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
// Default address for device. Note, it is without read/write bit. When read with analyser,
|
|
||||||
// this will appear 1 bit shifted to the left
|
|
||||||
#define BQ25703ADevaddr 0xD6
|
|
||||||
|
|
||||||
const byte Lorro_BQ25703A::BQ25703Aaddr = BQ25703ADevaddr;
|
|
||||||
|
|
||||||
void PmuBQ25703A::init()
|
|
||||||
{
|
|
||||||
// Set the watchdog timer to not have a timeout
|
|
||||||
regs.chargeOption0.set_WDTMR_ADJ(0);
|
|
||||||
assert(writeRegEx(regs.chargeOption0)); // FIXME, instead log a critical hw failure and reboot
|
|
||||||
delay(15); // FIXME, why are these delays required? - check datasheet
|
|
||||||
|
|
||||||
// Set the ADC on IBAT and PSYS to record values
|
|
||||||
// When changing bitfield values, call the writeRegEx function
|
|
||||||
// This is so you can change all the bits you want before sending out the byte.
|
|
||||||
regs.chargeOption1.set_EN_IBAT(1);
|
|
||||||
regs.chargeOption1.set_EN_PSYS(1);
|
|
||||||
assert(writeRegEx(regs.chargeOption1));
|
|
||||||
delay(15);
|
|
||||||
|
|
||||||
// Set ADC to make continuous readings. (uses more power)
|
|
||||||
regs.aDCOption.set_ADC_CONV(1);
|
|
||||||
// Set individual ADC registers to read. All have default off.
|
|
||||||
regs.aDCOption.set_EN_ADC_VBUS(1);
|
|
||||||
regs.aDCOption.set_EN_ADC_PSYS(1);
|
|
||||||
regs.aDCOption.set_EN_ADC_IDCHG(1);
|
|
||||||
regs.aDCOption.set_EN_ADC_ICHG(1);
|
|
||||||
regs.aDCOption.set_EN_ADC_VSYS(1);
|
|
||||||
regs.aDCOption.set_EN_ADC_VBAT(1);
|
|
||||||
// Once bits have been twiddled, send bytes to device
|
|
||||||
assert(writeRegEx(regs.aDCOption));
|
|
||||||
delay(15);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
|
|
||||||
//Initialise the device and library
|
|
||||||
Lorro_BQ25703A BQ25703A;
|
|
||||||
|
|
||||||
//Instantiate with reference to global set
|
|
||||||
extern Lorro_BQ25703A::Regt BQ25703Areg;
|
|
||||||
|
|
||||||
uint32_t previousMillis;
|
|
||||||
uint16_t loopInterval = 1000;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
|
|
||||||
Serial.begin(115200);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
|
|
||||||
uint32_t currentMillis = millis();
|
|
||||||
|
|
||||||
if( currentMillis - previousMillis > loopInterval ){
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
|
|
||||||
Serial.print( "Voltage of VBUS: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCVBUSPSYS.get_VBUS() );
|
|
||||||
Serial.println( "mV" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
Serial.print( "System power usage: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCVBUSPSYS.get_sysPower() );
|
|
||||||
Serial.println( "W" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
Serial.print( "Voltage of VBAT: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VBAT() );
|
|
||||||
Serial.println( "mV" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
Serial.print( "Voltage of VSYS: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCVSYSVBAT.get_VSYS() );
|
|
||||||
Serial.println( "mV" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
Serial.print( "Charging current: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCIBAT.get_ICHG() );
|
|
||||||
Serial.println( "mA" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
Serial.print( "Voltage of VSYS: " );
|
|
||||||
Serial.print( BQ25703Areg.aDCIBAT.get_IDCHG() );
|
|
||||||
Serial.println( "mA" );
|
|
||||||
delay( 15 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}*/
|
|
@ -1,22 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Lorro_BQ25703A.h>
|
|
||||||
|
|
||||||
class PmuBQ25703A : private Lorro_BQ25703A
|
|
||||||
{
|
|
||||||
Lorro_BQ25703A::Regt regs;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Configure the PMU for our board
|
|
||||||
*/
|
|
||||||
void init();
|
|
||||||
|
|
||||||
// Methods to have a common API with AXP192
|
|
||||||
bool isBatteryConnect() { return true; } // FIXME
|
|
||||||
bool isVBUSPlug() { return true; }
|
|
||||||
bool isChargeing() { return true; } // FIXME, intentional misspelling
|
|
||||||
|
|
||||||
/// battery voltage in mV
|
|
||||||
int getBattVoltage() { return 3200; }
|
|
||||||
};
|
|
@ -1,3 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// FIXME - make a FS abstraction for NRF52
|
|
Loading…
Reference in New Issue
Block a user