mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Added default temperature from ESP32 MCU and NRF52 MCU
Added NRF52Board.h and NRF52Board.cpp Modified NRF52 variants to extend from NRF52Board to share common feature
This commit is contained in:
parent
9bba417ebc
commit
4504ad4daf
24 changed files with 86 additions and 19 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#define MAX_HASH_SIZE 8
|
||||
#define PUB_KEY_SIZE 32
|
||||
|
|
@ -42,6 +43,7 @@ namespace mesh {
|
|||
class MainBoard {
|
||||
public:
|
||||
virtual uint16_t getBattMilliVolts() = 0;
|
||||
virtual float getMCUTemperature() { return NAN; }
|
||||
virtual bool setAdcMultiplier(float multiplier) { return false; };
|
||||
virtual float getAdcMultiplier() const { return 0.0f; }
|
||||
virtual const char* getManufacturerName() const = 0;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ public:
|
|||
#endif
|
||||
}
|
||||
|
||||
// Temperature from ESP32 MCU
|
||||
float getMCUTemperature() override {
|
||||
return temperatureRead();
|
||||
}
|
||||
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
#if defined(P_LORA_TX_LED)
|
||||
|
|
|
|||
23
src/helpers/NRF52Board.cpp
Normal file
23
src/helpers/NRF52Board.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#if defined(NRF52_PLATFORM)
|
||||
#include "NRF52Board.h"
|
||||
|
||||
// Temperature from NRF52 MCU
|
||||
float NRF52Board::getMCUTemperature() {
|
||||
NRF_TEMP->TASKS_START = 1; // Start temperature measurement
|
||||
|
||||
long startTime = millis();
|
||||
while (NRF_TEMP->EVENTS_DATARDY == 0) { // Wait for completion. Should complete in 50us
|
||||
if(millis() - startTime > 5) { // To wait 5ms just in case
|
||||
NRF_TEMP->TASKS_STOP = 1;
|
||||
return NAN;
|
||||
}
|
||||
}
|
||||
|
||||
NRF_TEMP->EVENTS_DATARDY = 0; // Clear event flag
|
||||
|
||||
int32_t temp = NRF_TEMP->TEMP; // In 0.25 *C units
|
||||
NRF_TEMP->TASKS_STOP = 1;
|
||||
|
||||
return temp * 0.25f; // Convert to *C
|
||||
}
|
||||
#endif
|
||||
12
src/helpers/NRF52Board.h
Normal file
12
src/helpers/NRF52Board.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
|
||||
#if defined(NRF52_PLATFORM)
|
||||
|
||||
class NRF52Board : public mesh::MainBoard {
|
||||
public:
|
||||
float getMCUTemperature() override;
|
||||
};
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue