mirror of https://github.com/meshcore-dev/MeshCore
Browse Source
Added NRF52Board.h and NRF52Board.cpp Modified NRF52 variants to extend from NRF52Board to share common featurepull/1206/head
24 changed files with 86 additions and 19 deletions
@ -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 |
||||
@ -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…
Reference in new issue