mirror of
https://github.com/pelgraine/Meck.git
synced 2026-03-28 17:42:44 +01:00
Add Minewsemi ME25LS01 variant
This commit is contained in:
59
boards/minewsemi_me25ls01.json
Normal file
59
boards/minewsemi_me25ls01.json
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"build": {
|
||||
"arduino": {
|
||||
"ldscript": "nrf52840_s140_v7.ld"
|
||||
},
|
||||
"core": "nRF5",
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DARDUINO_WIO_WM1110 -DNRF52840_XXAA",
|
||||
"f_cpu": "64000000L",
|
||||
"hwids": [
|
||||
["0x239A", "0x8029"],
|
||||
["0x239A", "0x0029"],
|
||||
["0x239A", "0x002A"],
|
||||
["0x239A", "0x802A"]
|
||||
],
|
||||
"usb_product": "me25ls01-BOOT",
|
||||
"mcu": "nrf52840",
|
||||
"variant": "minewsemi_me25ls01",
|
||||
"bsp": {
|
||||
"name": "adafruit"
|
||||
},
|
||||
"softdevice": {
|
||||
"sd_flags": "-DS140",
|
||||
"sd_name": "s140",
|
||||
"sd_version": "7.3.0",
|
||||
"sd_fwid": "0x0123"
|
||||
},
|
||||
"bootloader": {
|
||||
"settings_addr": "0xFF000"
|
||||
}
|
||||
},
|
||||
"connectivity": ["bluetooth"],
|
||||
"debug": {
|
||||
"jlink_device": "nRF52840_xxAA",
|
||||
"svd_path": "nrf52840.svd",
|
||||
"openocd_target": "nrf52.cfg"
|
||||
},
|
||||
"frameworks": ["arduino"],
|
||||
"name": "Minewsemi ME25LS01",
|
||||
"upload": {
|
||||
"maximum_ram_size": 248832,
|
||||
"maximum_size": 815104,
|
||||
"speed": 115200,
|
||||
"protocol": "nrfutil",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"nrfjprog",
|
||||
"nrfutil",
|
||||
"stlink",
|
||||
"cmsis-dap",
|
||||
"blackmagic"
|
||||
],
|
||||
"use_1200bps_touch": true,
|
||||
"require_upload_port": true,
|
||||
"wait_for_upload_port": true
|
||||
},
|
||||
"url": "https://en.minewsemi.com/lora-module/lr1110-nrf52840-me25LS01",
|
||||
"vendor": "MINEWSEMI"
|
||||
}
|
||||
92
src/helpers/nrf52/MinewsemiME25LS01Board.cpp
Normal file
92
src/helpers/nrf52/MinewsemiME25LS01Board.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include <Arduino.h>
|
||||
#include "MinewsemiME25LS01Board.h"
|
||||
#include <Wire.h>
|
||||
|
||||
#include <bluefruit.h>
|
||||
|
||||
void MinewsemiME25LS01Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
btn_prev_state = HIGH;
|
||||
|
||||
sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
|
||||
|
||||
#ifdef BUTTON_PIN
|
||||
// pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(BUTTON_PIN, INPUT);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
|
||||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
||||
#endif
|
||||
|
||||
Wire.begin();
|
||||
|
||||
#ifdef P_LORA_TX_LED
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
#endif
|
||||
|
||||
delay(10); // give sx1262 some time to power up
|
||||
}
|
||||
|
||||
#if 0
|
||||
static BLEDfu bledfu;
|
||||
|
||||
static void connect_callback(uint16_t conn_handle) {
|
||||
(void)conn_handle;
|
||||
MESH_DEBUG_PRINTLN("BLE client connected");
|
||||
}
|
||||
|
||||
static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
||||
(void)conn_handle;
|
||||
(void)reason;
|
||||
|
||||
MESH_DEBUG_PRINTLN("BLE client disconnected");
|
||||
}
|
||||
|
||||
|
||||
bool TrackerT1000eBoard::startOTAUpdate(const char* id, char reply[]) {
|
||||
// Config the peripheral connection with maximum bandwidth
|
||||
// more SRAM required by SoftDevice
|
||||
// Note: All config***() function must be called before begin()
|
||||
Bluefruit.configPrphBandwidth(BANDWIDTH_MAX);
|
||||
Bluefruit.configPrphConn(92, BLE_GAP_EVENT_LENGTH_MIN, 16, 16);
|
||||
|
||||
Bluefruit.begin(1, 0);
|
||||
// Set max power. Accepted values are: -40, -30, -20, -16, -12, -8, -4, 0, 4
|
||||
Bluefruit.setTxPower(4);
|
||||
// Set the BLE device name
|
||||
Bluefruit.setName("T1000E_OTA");
|
||||
|
||||
Bluefruit.Periph.setConnectCallback(connect_callback);
|
||||
Bluefruit.Periph.setDisconnectCallback(disconnect_callback);
|
||||
|
||||
// To be consistent OTA DFU should be added first if it exists
|
||||
bledfu.begin();
|
||||
|
||||
// Set up and start advertising
|
||||
// Advertising packet
|
||||
Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE);
|
||||
Bluefruit.Advertising.addTxPower();
|
||||
Bluefruit.Advertising.addName();
|
||||
|
||||
/* Start Advertising
|
||||
- Enable auto advertising if disconnected
|
||||
- Interval: fast mode = 20 ms, slow mode = 152.5 ms
|
||||
- Timeout for fast mode is 30 seconds
|
||||
- Start(timeout) with timeout = 0 will advertise forever (until connected)
|
||||
|
||||
For recommended advertising interval
|
||||
https://developer.apple.com/library/content/qa/qa1931/_index.html
|
||||
*/
|
||||
Bluefruit.Advertising.restartOnDisconnect(true);
|
||||
Bluefruit.Advertising.setInterval(32, 244); // in unit of 0.625 ms
|
||||
Bluefruit.Advertising.setFastTimeout(30); // number of seconds in fast mode
|
||||
Bluefruit.Advertising.start(0); // 0 = Don't stop advertising after n seconds
|
||||
|
||||
strcpy(reply, "OK - started");
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
112
src/helpers/nrf52/MinewsemiME25LS01Board.h
Normal file
112
src/helpers/nrf52/MinewsemiME25LS01Board.h
Normal file
@@ -0,0 +1,112 @@
|
||||
#pragma once
|
||||
|
||||
#include <MeshCore.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
// LoRa and SPI pins
|
||||
|
||||
#define P_LORA_DIO_1 (32 + 12) // P1.12
|
||||
#define P_LORA_NSS (32 + 13) // P1.13
|
||||
#define P_LORA_RESET (32 + 11) // P1.11
|
||||
#define P_LORA_BUSY (32 + 10) // P1.10
|
||||
#define P_LORA_SCLK (32 + 15) // P1.15
|
||||
#define P_LORA_MISO (0 + 29) // P0.29
|
||||
#define P_LORA_MOSI (0 + 2) // P0.2
|
||||
|
||||
#define LR11X0_DIO_AS_RF_SWITCH true
|
||||
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
|
||||
|
||||
// built-ins
|
||||
//#define PIN_VBAT_READ 5
|
||||
//#define ADC_MULTIPLIER (3 * 1.73 * 1000)
|
||||
|
||||
class MinewsemiME25LS01Board : public mesh::MainBoard {
|
||||
protected:
|
||||
uint8_t startup_reason;
|
||||
uint8_t btn_prev_state;
|
||||
|
||||
public:
|
||||
void begin();
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
#ifdef BATTERY_PIN
|
||||
#ifdef PIN_3V3_EN
|
||||
digitalWrite(PIN_3V3_EN, HIGH);
|
||||
#endif
|
||||
analogReference(AR_INTERNAL_3_0);
|
||||
analogReadResolution(12);
|
||||
delay(10);
|
||||
float volts = (analogRead(BATTERY_PIN) * ADC_MULTIPLIER * AREF_VOLTAGE) / 4096;
|
||||
#ifdef PIN_3V3_EN
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
#endif
|
||||
|
||||
analogReference(AR_DEFAULT); // put back to default
|
||||
analogReadResolution(10);
|
||||
|
||||
return volts * 1000;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t getStartupReason() const override { return startup_reason; }
|
||||
|
||||
const char* getManufacturerName() const override {
|
||||
return "m25ls01";
|
||||
}
|
||||
|
||||
int buttonStateChanged() {
|
||||
#ifdef BUTTON_PIN
|
||||
uint8_t v = digitalRead(BUTTON_PIN);
|
||||
if (v != btn_prev_state) {
|
||||
btn_prev_state = v;
|
||||
return (v == LOW) ? 1 : -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
#ifdef HAS_GPS
|
||||
digitalWrite(GPS_VRTC_EN, LOW);
|
||||
digitalWrite(GPS_RESET, LOW);
|
||||
digitalWrite(GPS_SLEEP_INT, LOW);
|
||||
digitalWrite(GPS_RTC_INT, LOW);
|
||||
pinMode(GPS_RESETB, OUTPUT);
|
||||
digitalWrite(GPS_RESETB, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef BUZZER_EN
|
||||
digitalWrite(BUZZER_EN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef PIN_3V3_EN
|
||||
digitalWrite(PIN_3V3_EN, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef LED_PIN
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
#endif
|
||||
#ifdef BUTTON_PIN
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_HIGH);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
#if defined(P_LORA_TX_LED)
|
||||
void onBeforeTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, HIGH);// turn TX LED on
|
||||
}
|
||||
void onAfterTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void reboot() override {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
// bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
24
variants/minewsemi_me25ls01/NullDisplayDriver.h
Normal file
24
variants/minewsemi_me25ls01/NullDisplayDriver.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <helpers/ui/DisplayDriver.h>
|
||||
|
||||
class NullDisplayDriver : public DisplayDriver {
|
||||
public:
|
||||
NullDisplayDriver() : DisplayDriver(128, 64) { }
|
||||
bool begin() { return false; } // not present
|
||||
|
||||
bool isOn() override { return false; }
|
||||
void turnOn() override { }
|
||||
void turnOff() override { }
|
||||
void clear() override { }
|
||||
void startFrame(Color bkg = DARK) override { }
|
||||
void setTextSize(int sz) override { }
|
||||
void setColor(Color c) override { }
|
||||
void setCursor(int x, int y) override { }
|
||||
void print(const char* str) override { }
|
||||
void fillRect(int x, int y, int w, int h) override { }
|
||||
void drawRect(int x, int y, int w, int h) override { }
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { }
|
||||
uint16_t getTextWidth(const char* str) override { return 0; }
|
||||
void endFrame() { }
|
||||
};
|
||||
184
variants/minewsemi_me25ls01/platformio.ini
Normal file
184
variants/minewsemi_me25ls01/platformio.ini
Normal file
@@ -0,0 +1,184 @@
|
||||
; ----------------- NRF52 me25ls01---------------------
|
||||
[nrf52840_me25ls01]
|
||||
extends = nrf52_base
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include
|
||||
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
|
||||
lib_ignore =
|
||||
BluetoothOTA
|
||||
lvgl
|
||||
lib5b4
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
rweather/Crypto @ ^0.4.0
|
||||
|
||||
[me25ls01]
|
||||
extends = nrf52840_me25ls01
|
||||
board = minewsemi_me25ls01
|
||||
board_build.ldscript = boards/nrf52840_s140_v7.ld
|
||||
build_flags = ${nrf52840_me25ls01.build_flags}
|
||||
-I variants/minewsemi_me25ls01
|
||||
-D me25ls01
|
||||
-D PIN_USER_BTN=27
|
||||
-D USER_BTN_PRESSED=HIGH
|
||||
-D PIN_STATUS_LED=39
|
||||
-D P_LORA_TX_LED=22
|
||||
-D RADIO_CLASS=CustomLR1110
|
||||
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D ENV_INCLUDE_GPS=0
|
||||
-D ENV_INCLUDE_AHTX0=1
|
||||
-D ENV_INCLUDE_BME280=1
|
||||
-D ENV_INCLUDE_INA3221=1
|
||||
-D ENV_INCLUDE_INA219=1
|
||||
build_src_filter = ${nrf52840_me25ls01.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/nrf52/MinewsemiME25LS01Board.cpp>
|
||||
+<../variants/minewsemi_me25ls01>
|
||||
+<helpers/sensors>
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
lib_deps = ${nrf52840_me25ls01.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
adafruit/Adafruit INA3221 Library @ ^1.0.1
|
||||
adafruit/Adafruit INA219 @ ^1.2.3
|
||||
adafruit/Adafruit AHTX0 @ ^2.0.5
|
||||
adafruit/Adafruit BME280 Library @ ^2.3.0
|
||||
|
||||
[env:Minewsemi_me25ls01_companion_radio_ble]
|
||||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
;-D PIN_BUZZER=25
|
||||
;-D PIN_BUZZER_EN=37
|
||||
build_src_filter = ${me25ls01.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
;+<helpers/ui/buzzer.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
lib_deps = ${me25ls01.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
|
||||
[env:Minewsemi_me25ls01_repeater]
|
||||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D ADVERT_NAME='"ME25LS01 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
build_src_filter = ${me25ls01.build_src_filter}
|
||||
;+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
;+<helpers/ui/buzzer.cpp>
|
||||
;+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps = ${me25ls01.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
|
||||
|
||||
[env:Minewsemi_me25ls01_room_server]
|
||||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D ADVERT_NAME='"ME25LS01 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
build_src_filter = ${me25ls01.build_src_filter}
|
||||
;+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
;+<helpers/ui/buzzer.cpp>
|
||||
;+<../examples/companion_radio/*.cpp>
|
||||
;+<../examples/simple_repeater>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps = ${me25ls01.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
[env:Minewsemi_me25ls01_terminal_chat]
|
||||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D ADVERT_NAME='"ME25LS01 Chat"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
build_src_filter = ${me25ls01.build_src_filter}
|
||||
;+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
;+<helpers/ui/buzzer.cpp>
|
||||
;+<../examples/companion_radio/*.cpp>
|
||||
;+<../examples/simple_repeater>
|
||||
;+<../examples/simple_room_server>
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps = ${me25ls01.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
[env:Minewsemi_me25ls01_companion_radio_usb]
|
||||
extends = me25ls01
|
||||
build_flags = ${me25ls01.build_flags}
|
||||
-D MAX_CONTACTS=100
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
;-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D RF_SWITCH_TABLE
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
build_src_filter = ${me25ls01.build_src_filter}
|
||||
+<helpers/nrf52/*.cpp>
|
||||
;+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
;+<helpers/ui/buzzer.cpp>
|
||||
;+<../examples/companion_radio/*.cpp>
|
||||
;+<../examples/simple_repeater>
|
||||
;+<../examples/simple_room_server>
|
||||
+<../examples/companion_radio>
|
||||
lib_deps = ${me25ls01.lib_deps}
|
||||
adafruit/RTClib @ ^2.1.3
|
||||
|
||||
209
variants/minewsemi_me25ls01/target.cpp
Normal file
209
variants/minewsemi_me25ls01/target.cpp
Normal file
@@ -0,0 +1,209 @@
|
||||
#include <Arduino.h>
|
||||
//#include "t1000e_sensors.h"
|
||||
#include "target.h"
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
MinewsemiME25LS01Board board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
VolatileRTCClock rtc_clock;
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
//T1000SensorManager sensors = T1000SensorManager(nmea);
|
||||
me25ls01SensorManager sensors = me25ls01SensorManager(nmea);
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
|
||||
RADIOLIB_LR11X0_DIO5,
|
||||
RADIOLIB_LR11X0_DIO6,
|
||||
RADIOLIB_LR11X0_DIO7,
|
||||
RADIOLIB_LR11X0_DIO8,
|
||||
RADIOLIB_NC
|
||||
};
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
// mode DIO5 DIO6 DIO7 DIO8
|
||||
{ LR11x0::MODE_STBY, {LOW, LOW, LOW, LOW }},
|
||||
{ LR11x0::MODE_RX, {HIGH, LOW, LOW, HIGH }},
|
||||
{ LR11x0::MODE_TX, {HIGH, HIGH, LOW, HIGH }},
|
||||
{ LR11x0::MODE_TX_HP, {LOW, HIGH, LOW, HIGH }},
|
||||
{ LR11x0::MODE_TX_HF, {LOW, LOW, LOW, LOW }},
|
||||
{ LR11x0::MODE_GNSS, {LOW, LOW, HIGH, LOW }},
|
||||
{ LR11x0::MODE_WIFI, {LOW, LOW, LOW, LOW }},
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
//rtc_clock.begin(Wire);
|
||||
|
||||
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
|
||||
SPI.begin();
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(1);
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
|
||||
#endif
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint32_t radio_get_rng_seed() {
|
||||
return radio.random(0x7FFFFFFF);
|
||||
}
|
||||
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) {
|
||||
radio.setFrequency(freq);
|
||||
radio.setSpreadingFactor(sf);
|
||||
radio.setBandwidth(bw);
|
||||
radio.setCodingRate(cr);
|
||||
}
|
||||
|
||||
void radio_set_tx_power(uint8_t dbm) {
|
||||
radio.setOutputPower(dbm);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
void me25ls01SensorManager::start_gps() {
|
||||
gps_active = false;
|
||||
//_nmea->begin();
|
||||
// this init sequence should be better
|
||||
// comes from seeed examples and deals with all gps pins
|
||||
// pinMode(GPS_EN, OUTPUT);
|
||||
// digitalWrite(GPS_EN, HIGH);
|
||||
// delay(10);
|
||||
// pinMode(GPS_VRTC_EN, OUTPUT);
|
||||
// digitalWrite(GPS_VRTC_EN, HIGH);
|
||||
// delay(10);
|
||||
|
||||
// pinMode(GPS_RESET, OUTPUT);
|
||||
// digitalWrite(GPS_RESET, HIGH);
|
||||
// delay(10);
|
||||
// digitalWrite(GPS_RESET, LOW);
|
||||
|
||||
// pinMode(GPS_SLEEP_INT, OUTPUT);
|
||||
// digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
// pinMode(GPS_RTC_INT, OUTPUT);
|
||||
// digitalWrite(GPS_RTC_INT, LOW);
|
||||
// pinMode(GPS_RESETB, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
void me25ls01SensorManager::sleep_gps() {
|
||||
gps_active = false;
|
||||
// digitalWrite(GPS_VRTC_EN, HIGH);
|
||||
// digitalWrite(GPS_EN, LOW);
|
||||
// digitalWrite(GPS_RESET, HIGH);
|
||||
// digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
// digitalWrite(GPS_RTC_INT, LOW);
|
||||
// pinMode(GPS_RESETB, OUTPUT);
|
||||
// digitalWrite(GPS_RESETB, LOW);
|
||||
//_nmea->stop();
|
||||
}
|
||||
|
||||
void me25ls01SensorManager::stop_gps() {
|
||||
gps_active = false;
|
||||
// digitalWrite(GPS_VRTC_EN, LOW);
|
||||
// digitalWrite(GPS_EN, LOW);
|
||||
// digitalWrite(GPS_RESET, HIGH);
|
||||
// digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
// digitalWrite(GPS_RTC_INT, LOW);
|
||||
// pinMode(GPS_RESETB, OUTPUT);
|
||||
// digitalWrite(GPS_RESETB, LOW);
|
||||
// //_nmea->stop();
|
||||
}
|
||||
|
||||
|
||||
bool me25ls01SensorManager::begin() {
|
||||
// init GPS
|
||||
Serial1.begin(115200);
|
||||
|
||||
// make sure gps pin are off
|
||||
// digitalWrite(GPS_VRTC_EN, LOW);
|
||||
// digitalWrite(GPS_RESET, LOW);
|
||||
// digitalWrite(GPS_SLEEP_INT, LOW);
|
||||
// digitalWrite(GPS_RTC_INT, LOW);
|
||||
// pinMode(GPS_RESETB, OUTPUT);
|
||||
// digitalWrite(GPS_RESETB, LOW);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool me25ls01SensorManager::querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) {
|
||||
if (requester_permissions & TELEM_PERM_LOCATION) { // does requester have permission?
|
||||
//telemetry.addGPS(TELEM_CHANNEL_SELF, node_lat, node_lon, node_altitude);
|
||||
}
|
||||
if (requester_permissions & TELEM_PERM_ENVIRONMENT) {
|
||||
//telemetry.addLuminosity(TELEM_CHANNEL_SELF, t1000e_get_light());
|
||||
//telemetry.addTemperature(TELEM_CHANNEL_SELF, t1000e_get_temperature());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void me25ls01SensorManager::loop() {
|
||||
static long next_gps_update = 0;
|
||||
|
||||
//_nmea->loop();
|
||||
|
||||
// if (millis() > next_gps_update) {
|
||||
// if (_nmea->isValid()) {
|
||||
// node_lat = ((double)_nmea->getLatitude())/1000000.;
|
||||
// node_lon = ((double)_nmea->getLongitude())/1000000.;
|
||||
// node_altitude = ((double)_nmea->getAltitude()) / 1000.0;
|
||||
// //Serial.printf("lat %f lon %f\r\n", _lat, _lon);
|
||||
// }
|
||||
// next_gps_update = millis() + 1000;
|
||||
//}
|
||||
}
|
||||
|
||||
int me25ls01SensorManager::getNumSettings() const { return 1; } // just one supported: "gps" (power switch)
|
||||
|
||||
const char* me25ls01SensorManager::getSettingName(int i) const {
|
||||
return i == 0 ? "gps" : NULL;
|
||||
}
|
||||
const char* me25ls01SensorManager::getSettingValue(int i) const {
|
||||
if (i == 0) {
|
||||
return gps_active ? "1" : "0";
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
bool me25ls01SensorManager::setSettingValue(const char* name, const char* value) {
|
||||
if (strcmp(name, "gps") == 0) {
|
||||
// if (strcmp(value, "0") == 0) {
|
||||
// sleep_gps(); // sleep for faster fix !
|
||||
// } else {
|
||||
// start_gps();
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
46
variants/minewsemi_me25ls01/target.h
Normal file
46
variants/minewsemi_me25ls01/target.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/RadioLibWrappers.h>
|
||||
#include <helpers/nrf52/MinewsemiME25LS01Board.h>
|
||||
#include <helpers/CustomLR1110Wrapper.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
class me25ls01SensorManager: public SensorManager {
|
||||
bool gps_active = false;
|
||||
LocationProvider * _nmea;
|
||||
|
||||
void start_gps();
|
||||
void sleep_gps();
|
||||
void stop_gps();
|
||||
public:
|
||||
me25ls01SensorManager(LocationProvider &nmea): _nmea(&nmea) { }
|
||||
bool begin() override;
|
||||
bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
|
||||
void loop() override;
|
||||
int getNumSettings() const override;
|
||||
const char* getSettingName(int i) const override;
|
||||
const char* getSettingValue(int i) const override;
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
};
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
extern MinewsemiME25LS01Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern VolatileRTCClock rtc_clock;
|
||||
extern me25ls01SensorManager sensors;
|
||||
|
||||
bool radio_init();
|
||||
uint32_t radio_get_rng_seed();
|
||||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
|
||||
void radio_set_tx_power(uint8_t dbm);
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
98
variants/minewsemi_me25ls01/variant.cpp
Normal file
98
variants/minewsemi_me25ls01/variant.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* variant.cpp
|
||||
* Copyright (C) 2023 Seeed K.K.
|
||||
* MIT License
|
||||
*/
|
||||
|
||||
#include "variant.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[PINS_COUNT + 1] =
|
||||
{
|
||||
0, // P0.00
|
||||
1, // P0.01
|
||||
2, // P0.02, AIN0 BATTERY_PIN
|
||||
3, // P0.03
|
||||
4, // P0.04, SENSOR_EN
|
||||
5, // P0.05, EXT_PWR_DETEC
|
||||
6, // P0.06, PIN_BUTTON1
|
||||
7, // P0.07, LORA_BUSY
|
||||
8, // P0.08, GPS_VRTC_EN
|
||||
9, // P0.09
|
||||
10, // P0.10
|
||||
11, // P0.11, PIN_SPI_SCK
|
||||
12, // P0.12, PIN_SPI_NSS
|
||||
13, // P0.13, PIN_SERIAL1_TX
|
||||
14, // P0.14, PIN_SERIAL1_RX
|
||||
15, // P0.15, GPS_RTC_INT
|
||||
16, // P0.16, PIN_SERIAL2_TX
|
||||
17, // P0.17, PIN_SERIAL2_RX
|
||||
18, // P0.18
|
||||
19, // P0.19
|
||||
20, // P0.20
|
||||
21, // P0.21
|
||||
22, // P0.22
|
||||
23, // P0.23
|
||||
24, // P0.24, LED_GREEN
|
||||
25, // P0.25, BUZZER_PIN
|
||||
26, // P0.26, PIN_WIRE_SDA
|
||||
27, // P0.27, PIN_WIRE_SCL
|
||||
28, // P0.28
|
||||
29, // P0.29, AIN5, LUX_SENSOR
|
||||
30, // P0.30
|
||||
31, // P0.31, AIN7, TEMP_SENSOR
|
||||
32, // P1.00
|
||||
33, // P1.01, LORA_DIO_1
|
||||
34, // P1.02
|
||||
35, // P1.03, EXT_CHRG_DETECT
|
||||
36, // P1.04
|
||||
37, // P1.05, LR1110_EN
|
||||
38, // P1.06, 3V3_EN PWR TO SENSORS
|
||||
39, // P1.07, PIN_3V3_ACC_EN
|
||||
40, // P1.08, PIN_SPI_MISO
|
||||
41, // P1.09, PIN_SPI_MOSI
|
||||
42, // P1.10, LORA_RESET
|
||||
43, // P1.11, GPS_EN
|
||||
44, // P1.12, GPS_SLEEP_INT
|
||||
45, // P1.13
|
||||
46, // P1.14, GPS_RESETB
|
||||
47, // P1.15, PIN_GPS_RESET
|
||||
255, // NRFX_SPIM_PIN_NOT_USED
|
||||
};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
// All pins output HIGH by default.
|
||||
// https://github.com/Seeed-Studio/Adafruit_nRF52_Arduino/blob/fab7d30a997a1dfeef9d1d59bfb549adda73815a/cores/nRF5/wiring.c#L65-L69
|
||||
|
||||
pinMode(BATTERY_PIN, INPUT);
|
||||
pinMode(EXT_CHRG_DETECT, INPUT);
|
||||
pinMode(EXT_PWR_DETECT, INPUT);
|
||||
// pinMode(GPS_RESETB, INPUT);
|
||||
pinMode(PIN_BUTTON1, INPUT);
|
||||
|
||||
pinMode(PIN_3V3_EN, OUTPUT);
|
||||
pinMode(PIN_3V3_ACC_EN, OUTPUT);
|
||||
// pinMode(BUZZER_EN, OUTPUT);
|
||||
// pinMode(SENSOR_EN, OUTPUT);
|
||||
// pinMode(GPS_EN, OUTPUT);
|
||||
// pinMode(GPS_RESET, OUTPUT);
|
||||
// pinMode(GPS_VRTC_EN, OUTPUT);
|
||||
// pinMode(GPS_SLEEP_INT, OUTPUT);
|
||||
// pinMode(GPS_RTC_INT, OUTPUT);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
|
||||
// digitalWrite(PIN_3V3_EN, LOW);
|
||||
// digitalWrite(PIN_3V3_ACC_EN, LOW);
|
||||
// digitalWrite(BUZZER_EN, LOW);
|
||||
// digitalWrite(SENSOR_EN, LOW);
|
||||
// digitalWrite(GPS_EN, LOW);
|
||||
// digitalWrite(GPS_RESET, LOW);
|
||||
// digitalWrite(GPS_VRTC_EN, LOW);
|
||||
// digitalWrite(GPS_SLEEP_INT, HIGH);
|
||||
// digitalWrite(GPS_RTC_INT, LOW);
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
}
|
||||
147
variants/minewsemi_me25ls01/variant.h
Normal file
147
variants/minewsemi_me25ls01/variant.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* variant.h
|
||||
* Copyright (C) 2023 Seeed K.K.
|
||||
* MIT License
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Low frequency clock source
|
||||
|
||||
#define USE_LFXO // 32.768 kHz crystal oscillator
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
// #define USE_LFRC // 32.768 kHz RC oscillator
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Power
|
||||
|
||||
#define NRF_APM // detect usb power
|
||||
#define PIN_3V3_EN (32 + 5) // P1.6 Power to Sensors
|
||||
#define PIN_3V3_ACC_EN -1
|
||||
|
||||
#define BATTERY_PIN (-1) // P0.2/AIN0
|
||||
#define BATTERY_IMMUTABLE
|
||||
#define ADC_MULTIPLIER (2.0F)
|
||||
|
||||
#define EXT_CHRG_DETECT (-1) // P1.3
|
||||
#define EXT_PWR_DETECT (-1) // P0.5
|
||||
|
||||
#define ADC_RESOLUTION (14)
|
||||
#define BATTERY_SENSE_RES (12)
|
||||
|
||||
#define AREF_VOLTAGE (3.0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Number of pins
|
||||
|
||||
#define PINS_COUNT (48)
|
||||
#define NUM_DIGITAL_PINS (48)
|
||||
#define NUM_ANALOG_INPUTS (6)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// UART pin definition
|
||||
|
||||
#define PIN_SERIAL1_RX (14) // P0.14 - checked
|
||||
#define PIN_SERIAL1_TX (13) // P0.13 - checked
|
||||
|
||||
#define PIN_SERIAL2_RX (17) // P0.17 - checked
|
||||
#define PIN_SERIAL2_TX (16) // P0.16 - checked
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C pin definition
|
||||
|
||||
#define HAS_WIRE (1) // checked
|
||||
#define WIRE_INTERFACES_COUNT (1) // checked
|
||||
|
||||
#define PIN_WIRE_SDA (15) // P0.26 - checked
|
||||
#define PIN_WIRE_SCL (17) // P0.27 - checked
|
||||
#define I2C_NO_RESCAN
|
||||
// #define HAS_QMA6100P
|
||||
// #define QMA_6100P_INT_PIN (-1) // P1.2
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// SPI pin definition
|
||||
|
||||
#define SPI_INTERFACES_COUNT (1)
|
||||
|
||||
#define PIN_SPI_MISO (0 + 29) // P0.29
|
||||
#define PIN_SPI_MOSI (0 + 2) // P0.2
|
||||
#define PIN_SPI_SCK (32 + 15) // P1.15
|
||||
#define PIN_SPI_NSS (32 + 13) // P1.13
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin LEDs
|
||||
|
||||
#define LED_BUILTIN (-1)
|
||||
#define LED_RED (32 + 5) // P1.5
|
||||
#define LED_BLUE (32 + 7) // P1.7
|
||||
#define LED_PIN LED_BLUE
|
||||
#define P_LORA_TX_LED LED_RED
|
||||
|
||||
#define LED_STATE_ON HIGH
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Builtin buttons
|
||||
|
||||
#define PIN_BUTTON1 (0 + 27) // P0.6
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// LR1110
|
||||
|
||||
#define LORA_DIO_1 (32 + 12) // P1.12
|
||||
#define LORA_DIO_2 (32 + 10) // P1.10
|
||||
#define LORA_NSS (PIN_SPI_NSS) // P1.13
|
||||
#define LORA_RESET (32 + 11) // P1.11
|
||||
#define LORA_BUSY (32 + 10) // P1.10
|
||||
#define LORA_SCLK (PIN_SPI_SCK) // P1.15
|
||||
#define LORA_MISO (PIN_SPI_MISO) // P0.29
|
||||
#define LORA_MOSI (PIN_SPI_MOSI) // P0.2
|
||||
#define LORA_CS PIN_SPI_NSS // P1.13
|
||||
|
||||
#define LR11X0_DIO_AS_RF_SWITCH true
|
||||
#define LR11X0_DIO3_TCXO_VOLTAGE 1.6
|
||||
|
||||
#define LR1110_IRQ_PIN LORA_DIO_1
|
||||
#define LR1110_NRESET_PIN LORA_RESET
|
||||
#define LR1110_BUSY_PIN LORA_DIO_2
|
||||
#define LR1110_SPI_NSS_PIN LORA_CS
|
||||
#define LR1110_SPI_SCK_PIN LORA_SCLK
|
||||
#define LR1110_SPI_MOSI_PIN LORA_MOSI
|
||||
#define LR1110_SPI_MISO_PIN LORA_MISO
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// GPS
|
||||
|
||||
//#define HAS_GPS 0
|
||||
#define GPS_RX_PIN PIN_SERIAL1_RX
|
||||
#define GPS_TX_PIN PIN_SERIAL1_TX
|
||||
|
||||
#define GPS_EN (-1) // P1.11
|
||||
#define GPS_RESET (-1) // P1.15
|
||||
|
||||
#define GPS_VRTC_EN (-1) // P0.8
|
||||
#define GPS_SLEEP_INT (-1) // P1.12
|
||||
#define GPS_RTC_INT (-1) // P0.15
|
||||
#define GPS_RESETB (-1) // P1.14
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Temp+Lux Sensor
|
||||
|
||||
#define SENSOR_EN (-1) // P0.4
|
||||
#define TEMP_SENSOR (-1) // P0.31/AIN7
|
||||
#define LUX_SENSOR (-1) // P0.29/AIN5
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accelerometer (I2C addr : ??? )
|
||||
|
||||
#define PIN_3V3_ACC_EN (-1) // P1.7
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Buzzer
|
||||
|
||||
#define BUZZER_EN (-1) // P1.5
|
||||
#define BUZZER_PIN (0 + 25) // P0.25
|
||||
Reference in New Issue
Block a user