diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index af40d95b65..22ff92feb5 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -112,6 +112,7 @@ jobs: - board: rak4631_eink - board: monteops_hw1 - board: t-echo + - board: canaryone - board: pca10059_diy_eink - board: feather_diy - board: nano-g2-ultra @@ -128,6 +129,7 @@ jobs: - board: picow - board: rak11310 - board: senselora_rp2040 + - board: rp2040-lora uses: ./.github/workflows/build_rpi2040.yml with: board: ${{ matrix.board }} diff --git a/bin/check-all.sh b/bin/check-all.sh index 1475ac3ee6..cdd1ceb9d2 100755 --- a/bin/check-all.sh +++ b/bin/check-all.sh @@ -13,7 +13,7 @@ if [[ $# -gt 0 ]]; then # can override which environment by passing arg BOARDS="$@" else - BOARDS="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 rak4631 rak4631_eink rak11200 t-echo pca10059_diy_eink" + BOARDS="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 rak4631 rak4631_eink rak11200 t-echo canaryone pca10059_diy_eink" fi echo "BOARDS:${BOARDS}" diff --git a/bin/check-dependencies.sh b/bin/check-dependencies.sh index 27372487fc..52bc760890 100644 --- a/bin/check-dependencies.sh +++ b/bin/check-dependencies.sh @@ -5,17 +5,17 @@ set -e if [[ $# -gt 0 ]]; then - # can override which environment by passing arg - BOARDS="$@" + # can override which environment by passing arg + BOARDS="$@" else - BOARDS="rak4631 rak4631_eink t-echo pca10059_diy_eink pico rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink tbeam-s3-core" + BOARDS="rak4631 rak4631_eink t-echo canaryone pca10059_diy_eink pico rak11200 tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v1 heltec-v2.0 heltec-v2.1 tbeam0.7 meshtastic-diy-v1 nano-g1 station-g1 m5stack-core m5stack-coreink tbeam-s3-core" fi echo "BOARDS:${BOARDS}" CHECK="" for BOARD in $BOARDS; do - CHECK="${CHECK} -e ${BOARD}" + CHECK="${CHECK} -e ${BOARD}" done echo $CHECK diff --git a/boards/canaryone.json b/boards/canaryone.json new file mode 100644 index 0000000000..d8f966a475 --- /dev/null +++ b/boards/canaryone.json @@ -0,0 +1,49 @@ +{ + "build": { + "arduino": { + "ldscript": "nrf52840_s140_v6.ld" + }, + "core": "nRF5", + "cpu": "cortex-m4", + "extra_flags": "-DARDUINO_NRF52840_CANARY -DNRF52840_XXAA", + "f_cpu": "64000000L", + "hwids": [["0x239A", "0x4405"]], + "usb_product": "CanaryOne", + "mcu": "nrf52840", + "variant": "canaryone", + "variants_dir": "variants", + "bsp": { + "name": "adafruit" + }, + "softdevice": { + "sd_flags": "-DS140", + "sd_name": "s140", + "sd_version": "6.1.1", + "sd_fwid": "0x00B6" + }, + "bootloader": { + "settings_addr": "0xFF000" + } + }, + "connectivity": ["bluetooth"], + "debug": { + "jlink_device": "nRF52840_xxAA", + "onboard_tools": ["jlink"], + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" + }, + "frameworks": ["arduino"], + "name": "Canary (Adafruit BSP)", + "upload": { + "maximum_ram_size": 248832, + "maximum_size": 815104, + "speed": 115200, + "protocol": "nrfutil", + "protocols": ["jlink", "nrfjprog", "nrfutil", "stlink"], + "use_1200bps_touch": true, + "require_upload_port": true, + "wait_for_upload_port": true + }, + "url": "https://canaryradio.io/", + "vendor": "Canary Radio Company" +} diff --git a/boards/eink0.1.json b/boards/eink0.1.json index 28862c5d4d..cb636ea3f8 100644 --- a/boards/eink0.1.json +++ b/boards/eink0.1.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "TTGO eink (Adafruit BSP)", diff --git a/boards/lora-relay-v1.json b/boards/lora-relay-v1.json index ca4e2f0ab2..b390b84046 100644 --- a/boards/lora-relay-v1.json +++ b/boards/lora-relay-v1.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "Meshtastic Lora Relay V1 (Adafruit BSP)", diff --git a/boards/lora-relay-v2.json b/boards/lora-relay-v2.json index 2cca8ae9ab..52b775e587 100644 --- a/boards/lora-relay-v2.json +++ b/boards/lora-relay-v2.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "Meshtastic Lora Relay V1 (Adafruit BSP)", diff --git a/boards/lora_isp4520.json b/boards/lora_isp4520.json index 971512b281..8125aa666d 100644 --- a/boards/lora_isp4520.json +++ b/boards/lora_isp4520.json @@ -22,7 +22,8 @@ "connectivity": ["bluetooth"], "debug": { "jlink_device": "nRF52832_xxAA", - "svd_path": "nrf52.svd" + "svd_path": "nrf52.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "lora ISP4520", diff --git a/boards/nordic_pca10059.json b/boards/nordic_pca10059.json index 214c2851d8..b99e3c763f 100644 --- a/boards/nordic_pca10059.json +++ b/boards/nordic_pca10059.json @@ -32,7 +32,8 @@ "connectivity": ["bluetooth"], "debug": { "jlink_device": "nRF52840_xxAA", - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "nRF52840 Dongle", diff --git a/boards/nrf52840_dk.json b/boards/nrf52840_dk.json index 8d07575bf6..8a16e854fa 100644 --- a/boards/nrf52840_dk.json +++ b/boards/nrf52840_dk.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "A modified NRF52840-DK devboard (Adafruit BSP)", diff --git a/boards/nrf52840_dk_modified.json b/boards/nrf52840_dk_modified.json index 0462c55f8e..2932cb4b90 100644 --- a/boards/nrf52840_dk_modified.json +++ b/boards/nrf52840_dk_modified.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "A modified NRF52840-DK devboard (Adafruit BSP)", diff --git a/boards/ppr.json b/boards/ppr.json index 5283fdc4e8..15e3025c0d 100644 --- a/boards/ppr.json +++ b/boards/ppr.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "Meshtastic PPR (Adafruit BSP)", diff --git a/boards/ppr1.json b/boards/ppr1.json index 4c05282456..35bf7d1e42 100644 --- a/boards/ppr1.json +++ b/boards/ppr1.json @@ -29,7 +29,8 @@ "debug": { "jlink_device": "nRF52833_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52833.svd" + "svd_path": "nrf52833.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "Meshtastic PPR1 (Adafruit BSP)", diff --git a/boards/t-echo.json b/boards/t-echo.json index c53132fdab..fcfc8c50b1 100644 --- a/boards/t-echo.json +++ b/boards/t-echo.json @@ -33,7 +33,8 @@ "debug": { "jlink_device": "nRF52840_xxAA", "onboard_tools": ["jlink"], - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "TTGO eink (Adafruit BSP)", diff --git a/boards/wiscore_rak4600.json b/boards/wiscore_rak4600.json index 9969ef26ea..0dec90a79e 100644 --- a/boards/wiscore_rak4600.json +++ b/boards/wiscore_rak4600.json @@ -32,7 +32,8 @@ "connectivity": ["bluetooth"], "debug": { "jlink_device": "nRF52832_xxAA", - "svd_path": "nrf52.svd" + "svd_path": "nrf52.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino", "zephyr"], "name": "Adafruit Bluefruit nRF52832 Feather", diff --git a/boards/wiscore_rak4631.json b/boards/wiscore_rak4631.json index 149492688d..6dec3f7cb4 100644 --- a/boards/wiscore_rak4631.json +++ b/boards/wiscore_rak4631.json @@ -32,7 +32,8 @@ "connectivity": ["bluetooth"], "debug": { "jlink_device": "nRF52840_xxAA", - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "WisCore RAK4631 Board", diff --git a/boards/xiao_ble_sense.json b/boards/xiao_ble_sense.json index 09a28c25df..8e0212b3ef 100644 --- a/boards/xiao_ble_sense.json +++ b/boards/xiao_ble_sense.json @@ -31,7 +31,8 @@ "connectivity": ["bluetooth"], "debug": { "jlink_device": "nRF52840_xxAA", - "svd_path": "nrf52840.svd" + "svd_path": "nrf52840.svd", + "openocd_target": "nrf52840-mdk-rs" }, "frameworks": ["arduino"], "name": "Seeed Xiao BLE Sense", diff --git a/platformio.ini b/platformio.ini index 51106cdacb..0033b6e469 100644 --- a/platformio.ini +++ b/platformio.ini @@ -19,6 +19,7 @@ default_envs = tbeam ;default_envs = tlora-t3s3-v1 ;default_envs = lora-relay-v1 # nrf board ;default_envs = t-echo +;default_envs = canaryone ;default_envs = nrf52840dk-geeksville ;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here ;default_envs = nano-g1 @@ -57,6 +58,7 @@ build_flags = -Wno-missing-field-initializers -DRADIOLIB_EXCLUDE_SI443X -DRADIOLIB_EXCLUDE_RFM2X -DRADIOLIB_EXCLUDE_AFSK + -DRADIOLIB_EXCLUDE_BELL -DRADIOLIB_EXCLUDE_HELLSCHREIBER -DRADIOLIB_EXCLUDE_MORSE -DRADIOLIB_EXCLUDE_RTTY diff --git a/protobufs b/protobufs index 99bd42baf8..6cb18782b1 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 99bd42baf8dd2e8ca0eec70f05e1cf7f1a40a283 +Subproject commit 6cb18782b1c446a4ca4797dcf5bb2da765b6e5a0 diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index 59ce043bcb..f0686b811f 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -28,7 +28,7 @@ #define DEBUG_PORT (*console) // Serial debug port #ifdef USE_SEGGER -#define DEBUG_PORT +// #undef DEBUG_PORT #define LOG_DEBUG(...) SEGGER_RTT_printf(0, __VA_ARGS__) #define LOG_INFO(...) SEGGER_RTT_printf(0, __VA_ARGS__) #define LOG_WARN(...) SEGGER_RTT_printf(0, __VA_ARGS__) diff --git a/src/configuration.h b/src/configuration.h index cb7ee218be..d8b0dba5f4 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -142,8 +142,9 @@ along with this program. If not, see . // ----------------------------------------------------------------------------- // GPS // ----------------------------------------------------------------------------- - +#ifndef GPS_BAUDRATE #define GPS_BAUDRATE 9600 +#endif #ifndef GPS_THREAD_INTERVAL #define GPS_THREAD_INTERVAL 200 @@ -161,6 +162,17 @@ along with this program. If not, see . /* Step #3: mop up with disabled values for HAS_ options not handled by the above two */ +// ----------------------------------------------------------------------------- +// GPS +// ----------------------------------------------------------------------------- + +#ifndef GPS_BAUDRATE +#define GPS_BAUDRATE 9600 +#endif +#ifndef GPS_THREAD_INTERVAL +#define GPS_THREAD_INTERVAL 100 +#endif + #ifndef HAS_WIFI #define HAS_WIFI 0 #endif diff --git a/src/mesh/generated/meshtastic/mesh.pb.h b/src/mesh/generated/meshtastic/mesh.pb.h index 998b64faa4..a6b36a8754 100644 --- a/src/mesh/generated/meshtastic/mesh.pb.h +++ b/src/mesh/generated/meshtastic/mesh.pb.h @@ -73,6 +73,8 @@ typedef enum _meshtastic_HardwareModel { meshtastic_HardwareModel_SENSELORA_S3 = 28, /* Canary Radio Company - CanaryOne: https://canaryradio.io/products/canaryone */ meshtastic_HardwareModel_CANARYONE = 29, + /* Waveshare RP2040 LoRa - https://www.waveshare.com/rp2040-lora.htm */ + meshtastic_HardwareModel_RP2040_LORA = 30, /* --------------------------------------------------------------------------- Less common/prototype boards listed here (needs one more byte over the air) --------------------------------------------------------------------------- */ diff --git a/src/mesh/generated/meshtastic/storeforward.pb.h b/src/mesh/generated/meshtastic/storeforward.pb.h index e6cb51f618..151f6211b8 100644 --- a/src/mesh/generated/meshtastic/storeforward.pb.h +++ b/src/mesh/generated/meshtastic/storeforward.pb.h @@ -62,9 +62,9 @@ typedef struct _meshtastic_StoreAndForward_Statistics { uint32_t requests_history; /* Is the heartbeat enabled on the server? */ bool heartbeat; - /* Is the heartbeat enabled on the server? */ + /* Maximum number of messages the server will return. */ uint32_t return_max; - /* Is the heartbeat enabled on the server? */ + /* Maximum history window in minutes the server will return messages from. */ uint32_t return_window; } meshtastic_StoreAndForward_Statistics; @@ -74,18 +74,20 @@ typedef struct _meshtastic_StoreAndForward_History { uint32_t history_messages; /* The window of messages that was used to filter the history client requested */ uint32_t window; - /* The window of messages that was used to filter the history client requested */ + /* Index in the packet history of the last message sent in a previous request to the server. + Will be sent to the client before sending the history and can be set in a subsequent request to avoid getting packets the server already sent to the client. */ uint32_t last_request; } meshtastic_StoreAndForward_History; /* TODO: REPLACE */ typedef struct _meshtastic_StoreAndForward_Heartbeat { - /* Number of that will be sent to the client */ + /* Period in seconds that the heartbeat is sent out that will be sent to the client */ uint32_t period; /* If set, this is not the primary Store & Forward router on the mesh */ uint32_t secondary; } meshtastic_StoreAndForward_Heartbeat; +typedef PB_BYTES_ARRAY_T(237) meshtastic_StoreAndForward_text_t; /* TODO: REPLACE */ typedef struct _meshtastic_StoreAndForward { /* TODO: REPLACE */ @@ -98,8 +100,8 @@ typedef struct _meshtastic_StoreAndForward { meshtastic_StoreAndForward_History history; /* TODO: REPLACE */ meshtastic_StoreAndForward_Heartbeat heartbeat; - /* Empty Payload */ - bool empty; + /* Text from history message. */ + meshtastic_StoreAndForward_text_t text; } variant; } meshtastic_StoreAndForward; @@ -148,7 +150,7 @@ extern "C" { #define meshtastic_StoreAndForward_stats_tag 2 #define meshtastic_StoreAndForward_history_tag 3 #define meshtastic_StoreAndForward_heartbeat_tag 4 -#define meshtastic_StoreAndForward_empty_tag 5 +#define meshtastic_StoreAndForward_text_tag 5 /* Struct field encoding specification for nanopb */ #define meshtastic_StoreAndForward_FIELDLIST(X, a) \ @@ -156,7 +158,7 @@ X(a, STATIC, SINGULAR, UENUM, rr, 1) \ X(a, STATIC, ONEOF, MESSAGE, (variant,stats,variant.stats), 2) \ X(a, STATIC, ONEOF, MESSAGE, (variant,history,variant.history), 3) \ X(a, STATIC, ONEOF, MESSAGE, (variant,heartbeat,variant.heartbeat), 4) \ -X(a, STATIC, ONEOF, BOOL, (variant,empty,variant.empty), 5) +X(a, STATIC, ONEOF, BYTES, (variant,text,variant.text), 5) #define meshtastic_StoreAndForward_CALLBACK NULL #define meshtastic_StoreAndForward_DEFAULT NULL #define meshtastic_StoreAndForward_variant_stats_MSGTYPE meshtastic_StoreAndForward_Statistics @@ -204,7 +206,7 @@ extern const pb_msgdesc_t meshtastic_StoreAndForward_Heartbeat_msg; #define meshtastic_StoreAndForward_Heartbeat_size 12 #define meshtastic_StoreAndForward_History_size 18 #define meshtastic_StoreAndForward_Statistics_size 50 -#define meshtastic_StoreAndForward_size 54 +#define meshtastic_StoreAndForward_size 242 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp index 42b1090506..820e1fb62b 100644 --- a/src/modules/SerialModule.cpp +++ b/src/modules/SerialModule.cpp @@ -58,7 +58,7 @@ SerialModule *serialModule; SerialModuleRadio *serialModuleRadio; -#ifdef TTGO_T_ECHO +#if defined(TTGO_T_ECHO) || defined(CANARYONE) SerialModule::SerialModule() : StreamAPI(&Serial), concurrency::OSThread("SerialModule") {} static Print *serialPrint = &Serial; #else @@ -140,7 +140,7 @@ int32_t SerialModule::runOnce() Serial.begin(baud); Serial.setTimeout(moduleConfig.serial.timeout > 0 ? moduleConfig.serial.timeout : TIMEOUT); } -#elif !defined(TTGO_T_ECHO) +#elif !defined(TTGO_T_ECHO) && !defined(CANARYONE) if (moduleConfig.serial.rxd && moduleConfig.serial.txd) { #ifdef ARCH_RP2040 Serial2.setFIFOSize(RX_BUFFER); @@ -188,7 +188,7 @@ int32_t SerialModule::runOnce() } } } -#if !defined(TTGO_T_ECHO) +#if !defined(TTGO_T_ECHO) && !defined(CANARYONE) else { while (Serial2.available()) { serialPayloadSize = Serial2.readBytes(serialBytes, meshtastic_Constants_DATA_PAYLOAD_LEN); diff --git a/src/platform/nrf52/architecture.h b/src/platform/nrf52/architecture.h index e6eebc45b9..35cd4fd84b 100644 --- a/src/platform/nrf52/architecture.h +++ b/src/platform/nrf52/architecture.h @@ -48,6 +48,8 @@ #define HW_VENDOR meshtastic_HardwareModel_T_ECHO #elif defined(NANO_G2_ULTRA) #define HW_VENDOR meshtastic_HardwareModel_NANO_G2_ULTRA +#elif defined(CANARYONE) +#define HW_VENDOR meshtastic_HardwareModel_CANARYONE #elif defined(NORDIC_PCA10059) #define HW_VENDOR meshtastic_HardwareModel_NRF52840_PCA10059 #elif defined(PRIVATE_HW) || defined(FEATHER_DIY) diff --git a/src/platform/rp2040/architecture.h b/src/platform/rp2040/architecture.h index 61eb1bbe89..d7d7214c0d 100644 --- a/src/platform/rp2040/architecture.h +++ b/src/platform/rp2040/architecture.h @@ -27,4 +27,6 @@ #define HW_VENDOR meshtastic_HardwareModel_RAK11310 #elif defined(SENSELORA_RP2040) #define HW_VENDOR meshtastic_HardwareModel_SENSELORA_RP2040 +#elif defined(RP2040_LORA) +#define HW_VENDOR meshtastic_HardwareModel_RP2040_LORA #endif \ No newline at end of file diff --git a/variants/canaryone/platformio.ini b/variants/canaryone/platformio.ini new file mode 100644 index 0000000000..d52bbb24a7 --- /dev/null +++ b/variants/canaryone/platformio.ini @@ -0,0 +1,15 @@ +; Public Beta oled/nrf52840/sx1262 device +[env:canaryone] +extends = nrf52840_base +board = canaryone +debug_tool = jlink + +# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling. +build_flags = ${nrf52840_base.build_flags} -Ivariants/canaryone + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m4/fpv4-sp-d16-hard" +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/canaryone> +lib_deps = + ${nrf52840_base.lib_deps} + adafruit/Adafruit BusIO@^1.13.2 + lewisxhe/PCF8563_Library@^1.0.1 +;upload_protocol = fs diff --git a/variants/canaryone/variant.cpp b/variants/canaryone/variant.cpp new file mode 100644 index 0000000000..5967a2a96a --- /dev/null +++ b/variants/canaryone/variant.cpp @@ -0,0 +1,56 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + // P0 - pins 0 and 1 are hardwired for xtal and should never be enabled + 0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LEDs + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); + + pinMode(PIN_LED3, OUTPUT); + ledOff(PIN_LED3); + + // Turn on power to the GPS and LoRa + pinMode(PIN_PWR_EN, OUTPUT); + digitalWrite(PIN_PWR_EN, HIGH); + + // Pull the GPS out of reset + pinMode(GPS_RESET_PIN, OUTPUT); + digitalWrite(GPS_RESET_PIN, HIGH); + + // Pull the LoRa out of reset + pinMode(LORA_RF_PWR, OUTPUT); + digitalWrite(LORA_RF_PWR, HIGH); +} diff --git a/variants/canaryone/variant.h b/variants/canaryone/variant.h new file mode 100644 index 0000000000..e31ba3c58f --- /dev/null +++ b/variants/canaryone/variant.h @@ -0,0 +1,188 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _VARIANT_CANARYONE +#define _VARIANT_CANARYONE + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +#define CANARYONE + +#define GPIO_PORT0 0 +#define GPIO_PORT1 32 + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (1) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (GPIO_PORT1 + 1) // blue P1.01 +#define PIN_LED2 (GPIO_PORT0 + 14) // yellow P0.14 +#define PIN_LED3 (GPIO_PORT1 + 3) // green P1.03 + +#define LED_BLUE PIN_LED1 + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED3 + +#define LED_STATE_ON 0 // State when LED is lit +#define LED_INVERTED 1 + +/* + * Buttons + */ +#define PIN_BUTTON1 (GPIO_PORT0 + 15) // BTN0 on schematic +#define PIN_BUTTON2 (GPIO_PORT0 + 16) // BTN1 on schematic + +/* + * Analog pins + */ +#define PIN_A0 (4) // Battery ADC P0.04 + +#define BATTERY_PIN PIN_A0 + +static const uint8_t A0 = PIN_A0; + +#define ADC_RESOLUTION 14 + +/** + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (GPIO_PORT0 + 26) +// #define I2C_SDA (GPIO_PORT0 + 26) +#define PIN_WIRE_SCL (GPIO_PORT0 + 27) +// #define I2C_SCL (GPIO_PORT0 + 27) + +#define PIN_LCD_RESET (GPIO_PORT0 + 2) + +/* + * External serial flash WP25R1635FZUIL0 + */ + +// QSPI Pins +#define PIN_QSPI_SCK (GPIO_PORT1 + 14) +#define PIN_QSPI_CS (GPIO_PORT1 + 15) +#define PIN_QSPI_IO0 (GPIO_PORT1 + 12) // MOSI if using two bit interface +#define PIN_QSPI_IO1 (GPIO_PORT1 + 13) // MISO if using two bit interface +#define PIN_QSPI_IO2 (GPIO_PORT0 + 7) // WP if using two bit interface (i.e. not used) +#define PIN_QSPI_IO3 (GPIO_PORT0 + 5) // HOLD if using two bit interface (i.e. not used) + +// On-board QSPI Flash +#define EXTERNAL_FLASH_DEVICES MX25R1635F +#define EXTERNAL_FLASH_USE_QSPI + +/* + * Lora radio + */ +#define RADIOLIB_DEBUG 1 +#define USE_SX1262 +#define SX126X_CS (GPIO_PORT0 + 24) +#define SX126X_DIO1 (GPIO_PORT1 + 11) +// #define SX126X_DIO3 (GPIO_PORT0 + 21) +// #define SX126X_DIO2 () // LORA_BUSY // LoRa RX/TX +#define SX126X_BUSY (GPIO_PORT0 + 17) +#define SX126X_RESET (GPIO_PORT0 + 25) +#define LORA_RF_PWR (GPIO_PORT0 + 28) // LORA_RF_SWITCH + +/* + * GPS pins + */ +#define HAS_GPS 1 +#define GPS_UBLOX +#define GPS_BAUDRATE 38400 + +// #define PIN_GPS_WAKE (GPIO_PORT1 + 2) // An output to wake GPS, low means allow sleep, high means force wake +// Seems to be missing on this new board +#define PIN_GPS_PPS (GPIO_PORT1 + 4) // Pulse per second input from the GPS +#define GPS_TX_PIN (GPIO_PORT1 + 9) // This is for bits going TOWARDS the CPU +#define GPS_RX_PIN (GPIO_PORT1 + 8) // This is for bits going TOWARDS the GPS + +#define GPS_THREAD_INTERVAL 50 + +#define PIN_SERIAL1_RX GPS_TX_PIN +#define PIN_SERIAL1_TX GPS_RX_PIN + +#define GPS_RESET_PIN (GPIO_PORT1 + 5) // GPS reset pin + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +// For LORA, spi 0 +#define PIN_SPI_MISO (GPIO_PORT0 + 23) +#define PIN_SPI_MOSI (GPIO_PORT0 + 22) +#define PIN_SPI_SCK (GPIO_PORT0 + 19) + +// #define PIN_SPI1_MISO (GPIO_PORT1 + 6) // FIXME not really needed, but for now the SPI code requires something to be defined, +// pick an used GPIO #define PIN_SPI1_MOSI (GPIO_PORT1 + 8) #define PIN_SPI1_SCK (GPIO_PORT1 + 9) + +#define PIN_PWR_EN (GPIO_PORT0 + 12) + +// To debug via the segger JLINK console rather than the CDC-ACM serial device +#define USE_SEGGER 1 + +// #define LORA_DISABLE_SENDING 1 +#define SX126X_DIO2_AS_RF_SWITCH 1 + +// Battery +// The battery sense is hooked to pin A0 (4) +// it is defined in the anlaolgue pin section of this file +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 100K + 100K voltage divider on VBAT = (100K / (100K + 100K)) +#define VBAT_DIVIDER (0.5F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (2.0) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif \ No newline at end of file diff --git a/variants/rp2040-lora/platformio.ini b/variants/rp2040-lora/platformio.ini new file mode 100644 index 0000000000..a1d6bea9d4 --- /dev/null +++ b/variants/rp2040-lora/platformio.ini @@ -0,0 +1,16 @@ +[env:rp2040-lora] +extends = rp2040_base +board = rpipico +upload_protocol = picotool + +# add our variants files to the include and src paths +build_flags = ${rp2040_base.build_flags} + -DRP2040_LORA + -Ivariants/rp2040-lora + -DDEBUG_RP2040_PORT=Serial + -DHW_SPI1_DEVICE + -L "${platformio.libdeps_dir}/${this.__env__}/BSEC2 Software Library/src/cortex-m0plus" +lib_deps = + ${rp2040_base.lib_deps} +debug_build_flags = ${rp2040_base.build_flags} +debug_tool = cmsis-dap ; for e.g. Picotool \ No newline at end of file diff --git a/variants/rp2040-lora/variant.h b/variants/rp2040-lora/variant.h new file mode 100644 index 0000000000..1f42c4db74 --- /dev/null +++ b/variants/rp2040-lora/variant.h @@ -0,0 +1,54 @@ +// #define RADIOLIB_CUSTOM_ARDUINO 1 +// #define RADIOLIB_TONE_UNSUPPORTED 1 +// #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED 1 + +#define ARDUINO_ARCH_AVR + +// #define USE_SH1106 1 + +// default I2C pins: +// SDA = 4 +// SCL = 5 + +// Recommended pins for SerialModule: +// txd = 8 +// rxd = 9 + +#define EXT_NOTIFY_OUT 22 +#define BUTTON_PIN 17 + +#define LED_PIN PIN_LED + +// #define BATTERY_PIN 26 +// ratio of voltage divider = 3.0 (R17=200k, R18=100k) +// #define ADC_MULTIPLIER 3.1 // 3.0 + a bit for being optimistic + +#define USE_SX1262 + +#undef LORA_SCK +#undef LORA_MISO +#undef LORA_MOSI +#undef LORA_CS + +// https://www.waveshare.com/rp2040-lora.htm +// https://www.waveshare.com/img/devkit/RP2040-LoRa-HF/RP2040-LoRa-HF-details-11.jpg +#define LORA_SCK 14 // 10 +#define LORA_MISO 24 // 12 +#define LORA_MOSI 15 // 11 +#define LORA_CS 13 // 3 + +#define LORA_DIO0 RADIOLIB_NC +#define LORA_RESET 23 // 15 +#define LORA_DIO1 16 // 20 +#define LORA_DIO2 18 // 2 +#define LORA_DIO3 RADIOLIB_NC +#define LORA_DIO4 17 + +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY LORA_DIO2 +#define SX126X_RESET LORA_RESET +#define SX126X_DIO2_AS_RF_SWITCH +// #define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#endif \ No newline at end of file diff --git a/version.properties b/version.properties index 841be3b279..4d1f50ad6b 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 2 -build = 22 +build = 23