Update NRF52 build to work again

This commit is contained in:
geeksville 2020-07-09 19:57:55 -07:00
parent 62c9bad183
commit ed589727d6
13 changed files with 82 additions and 24 deletions

View File

@ -8,7 +8,7 @@
"extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA", "extra_flags": "-DARDUINO_NRF52840_PCA10056 -DNRF52840_XXAA",
"f_cpu": "64000000L", "f_cpu": "64000000L",
"hwids": [["0x239A", "0x4404"]], "hwids": [["0x239A", "0x4404"]],
"usb_product": "SimPPR", "usb_product": "nrf52840dk",
"mcu": "nrf52840", "mcu": "nrf52840",
"variant": "pca10056-rc-clock", "variant": "pca10056-rc-clock",
"variants_dir": "variants", "variants_dir": "variants",

14
docs/software/ant.md Normal file
View File

@ -0,0 +1,14 @@
# ANT protocol notes
SD340 terms are reasonable for NRF52
https://www.thisisant.com/developer/components/nrf52832#tab_protocol_stacks_tab
Profiles to implement:
tracker
https://www.thisisant.com/developer/ant-plus/device-profiles/#4365_tab
ebike
https://www.thisisant.com/developer/ant-plus/device-profiles/#527_tab
no profile for messaging?

View File

@ -5,8 +5,11 @@
RAM investigation. RAM investigation.
nRF52832-QFAA 64KB ram, 512KB flash vs nRF52832-QFAA 64KB ram, 512KB flash vs
nrf52832-QFAB 32KB ram, 512kb flash nrf52832-QFAB 32KB ram, 512kb flash
nrf52833 128KB RAM
nrf52840 256KB RAM, 1MB flash nrf52840 256KB RAM, 1MB flash
Manual hacks needed to build (for now):
platform.json platform.json
"framework-arduinoadafruitnrf52": { "framework-arduinoadafruitnrf52": {
@ -15,6 +18,8 @@ platform.json
"version": "https://github.com/meshtastic/Adafruit_nRF52_Arduino.git" "version": "https://github.com/meshtastic/Adafruit_nRF52_Arduino.git"
}, },
kevinh@kevin-server:~/.platformio/packages/framework-arduinoadafruitnrf52/variants$ ln -s ~/development/meshtastic/meshtastic-esp32/variants/* .
## Initial work items ## Initial work items
Minimum items needed to make sure hardware is good. Minimum items needed to make sure hardware is good.

6
docs/software/rak815.md Normal file
View File

@ -0,0 +1,6 @@
# RAK815
Notes on trying to get the RAK815 working with meshtastic.
good tutorial: https://www.hackster.io/naresh-krish/getting-started-with-rak815-tracker-module-and-arduino-1c7bc9
(includes software serial link - possibly useful for GPS)

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
default_envs = tbeam ; 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
@ -74,7 +74,7 @@ lib_deps =
Wire ; explicitly needed here because the AXP202 library forgets to add it Wire ; explicitly needed here because the AXP202 library forgets to add it
https://github.com/meshtastic/arduino-fsm.git https://github.com/meshtastic/arduino-fsm.git
https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git https://github.com/meshtastic/SparkFun_Ublox_Arduino_Library.git
https://github.com/meshtastic/RadioLib.git#6aa38a85856012c99c4e9b4e7cee35e37671a4bc https://github.com/meshtastic/RadioLib.git#d6b12f7eb0a06bd2414c79b437b25d377e3f603f
https://github.com/meshtastic/TinyGPSPlus.git https://github.com/meshtastic/TinyGPSPlus.git
; Common settings for ESP targes, mixin with extends = esp32_base ; Common settings for ESP targes, mixin with extends = esp32_base

8
src/BluetoothCommon.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
/**
* Common lib functions for all platforms that have bluetooth
*/
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level);

View File

@ -1,7 +1,13 @@
#include "Thread.h" #include "Thread.h"
#include "timing.h" #include "timing.h"
#include <assert.h>
namespace concurrency { #ifdef ARDUINO_ARCH_ESP32
#include "esp_task_wdt.h"
#endif
namespace concurrency
{
void Thread::start(const char *name, size_t stackSize, uint32_t priority) void Thread::start(const char *name, size_t stackSize, uint32_t priority)
{ {
@ -14,4 +20,27 @@ void Thread::callRun(void *_this)
((Thread *)_this)->doRun(); ((Thread *)_this)->doRun();
} }
void Thread::serviceWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
esp_task_wdt_reset();
#endif
}
void Thread::startWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
#endif
}
void Thread::stopWatchdog()
{
#ifdef ARDUINO_ARCH_ESP32
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
#endif
}
} // namespace concurrency } // namespace concurrency

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "freertosinc.h" #include "freertosinc.h"
#include "esp_task_wdt.h"
namespace concurrency { namespace concurrency {
@ -36,17 +35,9 @@ class Thread
* *
* this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog() * this only applies after startWatchdog() has been called. If you need to sleep for a long time call stopWatchdog()
*/ */
void serviceWatchdog() { esp_task_wdt_reset(); } void serviceWatchdog();
void startWatchdog() void startWatchdog();
{ void stopWatchdog();
auto r = esp_task_wdt_add(taskHandle);
assert(r == ESP_OK);
}
void stopWatchdog()
{
auto r = esp_task_wdt_delete(taskHandle);
assert(r == ESP_OK);
}
private: private:
static void callRun(void *_this); static void callRun(void *_this);

View File

@ -62,6 +62,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Standard definitions for NRF52 targets // Standard definitions for NRF52 targets
// //
// Nop definition for these attributes - not used on NRF52
#define EXT_RAM_ATTR
#define IRAM_ATTR
#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) // We bind to the GPS using variant.h instead for this platform (Serial1)

View File

@ -35,8 +35,5 @@ BLECharacteristic *addBLECharacteristic(BLECharacteristic *c);
/// Add a characteristic that we will delete when we restart /// Add a characteristic that we will delete when we restart
BLEDescriptor *addBLEDescriptor(BLEDescriptor *c); BLEDescriptor *addBLEDescriptor(BLEDescriptor *c);
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level);
/// Any bluetooth objects you allocate _must_ come from this pool if you want to be able to call deinitBLE() /// Any bluetooth objects you allocate _must_ come from this pool if you want to be able to call deinitBLE()
extern SimpleAllocator btPool; extern SimpleAllocator btPool;

View File

@ -33,7 +33,7 @@
#include "power.h" #include "power.h"
// #include "rom/rtc.h" // #include "rom/rtc.h"
#include "DSRRouter.h" #include "DSRRouter.h"
#include "debug.h" // #include "debug.h"
#include "graphics/Screen.h" #include "graphics/Screen.h"
#include "main.h" #include "main.h"
#include "sleep.h" #include "sleep.h"

View File

@ -5,14 +5,14 @@
#include "GPS.h" #include "GPS.h"
//#include "MeshBluetoothService.h" //#include "MeshBluetoothService.h"
#include "../concurrency/Periodic.h"
#include "BluetoothCommon.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
#include "MeshService.h" #include "MeshService.h"
#include "NodeDB.h" #include "NodeDB.h"
#include "../concurrency/Periodic.h"
#include "PowerFSM.h" #include "PowerFSM.h"
#include "main.h" #include "main.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "power.h" #include "power.h"
#include "BluetoothUtil.h" // needed for updateBatteryLevel, FIXME, eventually when we pull mesh out into a lib we shouldn't be whacking bluetooth from here
#include "timing.h" #include "timing.h"
/* /*
@ -283,8 +283,6 @@ void MeshService::sendOurPosition(NodeNum dest, bool wantReplies)
sendToMesh(p); sendToMesh(p);
} }
int MeshService::onGPSChanged(void *unused) int MeshService::onGPSChanged(void *unused)
{ {
// DEBUG_MSG("got gps notify\n"); // DEBUG_MSG("got gps notify\n");

View File

@ -1,6 +1,7 @@
#include "NRF52Bluetooth.h" #include "NRF52Bluetooth.h"
#include "configuration.h" #include "configuration.h"
#include "main.h" #include "main.h"
#include "BluetoothCommon.h"
#include <bluefruit.h> #include <bluefruit.h>
/* HRM Service Definitions /* HRM Service Definitions
@ -192,6 +193,11 @@ void NRF52Bluetooth::setup()
} }
} }
/// Given a level between 0-100, update the BLE attribute
void updateBatteryLevel(uint8_t level) {
// FIXME - implement
}
/* /*
void loop() void loop()
{ {