mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-25 19:27:28 +00:00
cubecell wip
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
#ifdef HAS_FREE_RTOS
|
||||
/// 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)
|
||||
{
|
||||
@@ -115,6 +116,7 @@ template <class T> class MemoryPool : public Allocator<T>
|
||||
(size_t)(p - buf) <
|
||||
maxElements); // sanity check to make sure a programmer didn't free something that didn't come from this pool
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
/// 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 "FS.h"
|
||||
#include "SPIFFS.h"
|
||||
|
||||
#include "CryptoEngine.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
|
||||
|
||||
#ifndef NO_ESP32
|
||||
// ESP32 version
|
||||
#include "SPIFFS.h"
|
||||
#define FS SPIFFS
|
||||
#define FSBegin() FS.begin(true)
|
||||
#define FILE_O_WRITE "w"
|
||||
#define FILE_O_READ "r"
|
||||
#else
|
||||
// NRF52 version
|
||||
#include "InternalFileSystem.h"
|
||||
#define FS InternalFS
|
||||
#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
|
||||
uint32_t t1 = p1.rxTimeMsec, t2 = p2.rxTimeMsec;
|
||||
|
||||
if (abs(t1 - t2) >
|
||||
UINT32_MAX /
|
||||
2) { // time must have rolled over, swap them because the new little number is 'bigger' than the old big number
|
||||
if (t1 - t2 > UINT32_MAX / 2) {
|
||||
// time must have rolled over, swap them because the new little number is 'bigger' than the old big number
|
||||
t1 = t2;
|
||||
t2 = p1.rxTimeMsec;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ template <class T> class PointerQueue : public TypedQueue<T *>
|
||||
return this->dequeue(&p, maxWait) ? p : nullptr;
|
||||
}
|
||||
|
||||
#ifdef HAS_FREE_RTOS
|
||||
// returns a ptr or null if the queue was empty
|
||||
T *dequeuePtrFromISR(BaseType_t *higherPriWoken)
|
||||
{
|
||||
@@ -25,4 +26,5 @@ template <class T> class PointerQueue : public TypedQueue<T *>
|
||||
|
||||
return this->dequeueFromISR(&p, higherPriWoken) ? p : nullptr;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include "PeriodicTask.h"
|
||||
#include "RadioInterface.h"
|
||||
|
||||
#ifdef CubeCell_BoardPlus
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#endif
|
||||
|
||||
#include <RadioLib.h>
|
||||
|
||||
// ESP32 has special rules about ISR code
|
||||
|
||||
@@ -48,7 +48,7 @@ struct PendingPacket {
|
||||
PendingPacket() {}
|
||||
PendingPacket(MeshPacket *p);
|
||||
|
||||
void setNextTx() { nextTxMsec = millis() + random(20 * 1000, 22 * 1000); }
|
||||
void setNextTx() { nextTxMsec = millis() + random(20 * 1000L, 22 * 1000L); }
|
||||
};
|
||||
|
||||
class GlobalPacketIdHashFunction
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "freertosinc.h"
|
||||
|
||||
#ifdef HAS_FREE_RTOS
|
||||
|
||||
/**
|
||||
* A wrapper for freertos queues. Note: each element object should be small
|
||||
* 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); }
|
||||
};
|
||||
|
||||
#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
|
||||
|
||||
Reference in New Issue
Block a user