mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-19 09:12:45 +00:00
Static memory pool allocation (#7966)
* Static memory pool * Initializer * T-Lora Pager: Support LR1121 and SX1280 models (#7956) * T-Lora Pager: Support LR1121 and SX1280 models * Remove ifdefs --------- Co-authored-by: WillyJL <me@willyjl.dev>
This commit is contained in:
@@ -115,12 +115,11 @@ template <class T, int MaxSize> class MemoryPool : public Allocator<T>
|
||||
bool used[MaxSize];
|
||||
|
||||
public:
|
||||
MemoryPool()
|
||||
MemoryPool() : pool{}, used{}
|
||||
{
|
||||
// Initialize the used array to false (all slots free)
|
||||
for (int i = 0; i < MaxSize; i++) {
|
||||
used[i] = false;
|
||||
}
|
||||
// Arrays are now zero-initialized by member initializer list
|
||||
// pool array: all elements are default-constructed (zero for POD types)
|
||||
// used array: all elements are false (zero-initialized)
|
||||
}
|
||||
|
||||
/// Return a buffer for use by others
|
||||
|
||||
@@ -46,11 +46,14 @@ the new node can build its node db)
|
||||
|
||||
MeshService *service;
|
||||
|
||||
static MemoryDynamic<meshtastic_MqttClientProxyMessage> staticMqttClientProxyMessagePool;
|
||||
#define MAX_MQTT_PROXY_MESSAGES 16
|
||||
static MemoryPool<meshtastic_MqttClientProxyMessage, MAX_MQTT_PROXY_MESSAGES> staticMqttClientProxyMessagePool;
|
||||
|
||||
static MemoryDynamic<meshtastic_QueueStatus> staticQueueStatusPool;
|
||||
#define MAX_QUEUE_STATUS 4
|
||||
static MemoryPool<meshtastic_QueueStatus, MAX_QUEUE_STATUS> staticQueueStatusPool;
|
||||
|
||||
static MemoryDynamic<meshtastic_ClientNotification> staticClientNotificationPool;
|
||||
#define MAX_CLIENT_NOTIFICATIONS 4
|
||||
static MemoryPool<meshtastic_ClientNotification, MAX_CLIENT_NOTIFICATIONS> staticClientNotificationPool;
|
||||
|
||||
Allocator<meshtastic_MqttClientProxyMessage> &mqttClientProxyMessagePool = staticMqttClientProxyMessagePool;
|
||||
|
||||
|
||||
@@ -31,8 +31,7 @@
|
||||
(MAX_RX_TOPHONE + MAX_RX_FROMRADIO + 2 * MAX_TX_QUEUE + \
|
||||
2) // max number of packets which can be in flight (either queued from reception or queued for sending)
|
||||
|
||||
// static MemoryPool<MeshPacket> staticPool(MAX_PACKETS);
|
||||
static MemoryDynamic<meshtastic_MeshPacket> staticPool;
|
||||
static MemoryPool<meshtastic_MeshPacket, MAX_PACKETS> staticPool;
|
||||
|
||||
Allocator<meshtastic_MeshPacket> &packetPool = staticPool;
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@ static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
// mode DIO5 DIO6
|
||||
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {LOW, HIGH}},
|
||||
{LR11x0::MODE_TX, {HIGH, LOW}}, {LR11x0::MODE_TX_HP, {HIGH, LOW}},
|
||||
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
|
||||
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
|
||||
{LR11x0::MODE_STBY, {LOW, LOW}},
|
||||
{LR11x0::MODE_RX, {LOW, HIGH}},
|
||||
{LR11x0::MODE_TX, {HIGH, LOW}},
|
||||
{LR11x0::MODE_TX_HP, {HIGH, LOW}},
|
||||
{LR11x0::MODE_TX_HF, {LOW, LOW}},
|
||||
{LR11x0::MODE_GNSS, {LOW, LOW}},
|
||||
{LR11x0::MODE_WIFI, {LOW, LOW}},
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
Reference in New Issue
Block a user