updated variant rak3401

This commit is contained in:
chrisdavis2110
2026-01-17 22:54:20 -08:00
parent 5e4b33a1a0
commit ed5d2909fc
7 changed files with 147 additions and 106 deletions

72
boards/rak3401.json Normal file
View File

@@ -0,0 +1,72 @@
{
"build": {
"arduino": {
"ldscript": "nrf52840_s140_v6.ld"
},
"core": "nRF5",
"cpu": "cortex-m4",
"extra_flags": "-DARDUINO_NRF52840_FEATHER -DNRF52840_XXAA",
"f_cpu": "64000000L",
"hwids": [
[
"0x239A",
"0x8029"
],
[
"0x239A",
"0x0029"
],
[
"0x239A",
"0x002A"
],
[
"0x239A",
"0x802A"
]
],
"usb_product": "WisCore RAK3401 Board",
"mcu": "nrf52840",
"variant": "WisCore_RAK3401_Board",
"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",
"svd_path": "nrf52840.svd"
},
"frameworks": [
"arduino"
],
"name": "WisCore RAK3401 Board",
"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://www.rakwireless.com",
"vendor": "RAKwireless"
}

View File

@@ -20,18 +20,13 @@ void RAK3401Board::begin() {
Wire.begin();
// Enable 3.3V periphery power rail (GPS, IO Module, etc.)
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);
pinMode(SX126X_POWER_EN, OUTPUT);
digitalWrite(SX126X_POWER_EN, HIGH);
delay(10); // give sx1262 some time to power up
#ifdef P_LORA_PA_EN
// Initialize RAK13302 1W LoRa transceiver module PA control pin
pinMode(P_LORA_PA_EN, OUTPUT);
digitalWrite(P_LORA_PA_EN, LOW); // Start with PA disabled
delay(10); // Allow PA module to initialize
#endif
}
}

View File

@@ -4,45 +4,34 @@
#include <Arduino.h>
#include <helpers/NRF52Board.h>
// LoRa radio module pins for RAK3401 with RAK13302 (uses SPI1)
#define P_LORA_DIO_1 10
// LoRa radio module pins for RAK13302
#define P_LORA_SCLK 3
#define P_LORA_MISO 29
#define P_LORA_MOSI 30
#define P_LORA_NSS 26
#define P_LORA_RESET 4
#define P_LORA_DIO_1 10
#define P_LORA_BUSY 9
#define P_LORA_SCLK 3 // SPI1_SCK
#define P_LORA_MISO 29 // SPI1_MISO
#define P_LORA_MOSI 30 // SPI1_MOSI
#define SX126X_POWER_EN 21
#define P_LORA_RESET 4
#ifndef P_LORA_PA_EN
#define P_LORA_PA_EN 31
#endif
//#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
//#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
//#define PIN_GPS_TX 16 //GPS TX pin
//#define PIN_GPS_RX 15 //GPS RX pin
// #define PIN_GPS_TX 16 //GPS TX pin
// #define PIN_GPS_RX 15 //GPS RX pin
#define PIN_GPS_1PPS 17 //GPS PPS pin
#define GPS_BAUD_RATE 9600
#define GPS_ADDRESS 0x42 //i2c address for GPS
// RAK13302 1W LoRa transceiver module PA control (WisBlock IO slot)
// The RAK13302 mounts to the IO slot and has an ANT_SW (antenna switch) pin that controls the PA
// This pin must be controlled during transmission to enable the 1W power amplifier
//
// According to RAK13302 datasheet: ANT_SW connects to IO3 on the IO slot
// RAK19007 base board pin mapping: IO3 = pin 31 (also available as AIN1/A1 for analog input)
//
// Default: Pin 31 (IO3) - ANT_SW pin from RAK13302 datasheet
// Override by defining P_LORA_PA_EN in platformio.ini if needed
#ifndef P_LORA_PA_EN
#define P_LORA_PA_EN 31 // ANT_SW pin from RAK13302 datasheet (IO3, pin 31 on RAK19007)
#endif
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// built-ins
#define PIN_VBAT_READ 5
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
// 3.3V periphery enable (GPS, IO Module, etc.)
#define PIN_3V3_EN (34)
#define WB_IO2 PIN_3V3_EN

View File

@@ -1,20 +1,12 @@
[rak3401]
extends = nrf52_base
board = rak4631
board = rak3401
board_check = true
build_flags = ${nrf52_base.build_flags}
${sensor_base.build_flags}
-I variants/rak3401
-D RAK_4631
-D RAK_3401
-D RAK13302
-D RAK_BOARD
-D PIN_BOARD_SCL=14
-D PIN_BOARD_SDA=13
-D PIN_GPS_TX=PIN_SERIAL1_RX
-D PIN_GPS_RX=PIN_SERIAL1_TX
-D PIN_GPS_EN=-1
-D PIN_OLED_RESET=-1
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D LORA_TX_POWER=22

View File

@@ -17,8 +17,6 @@ RAK3401Board board;
#endif
#endif
// RAK3401 uses SPI1 for the RAK13302 LoRa module
// Note: nRF52 doesn't have a separate SPI1 object, so we use SPI but configure it with SPI1 pins
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);
@@ -36,12 +34,6 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
bool radio_init() {
rtc_clock.begin(Wire);
// Configure SPI with SPI1 pins for RAK13302
// nRF52 uses the same SPI peripheral but with different pin assignments
SPI.setPins(P_LORA_MISO, P_LORA_SCLK, P_LORA_MOSI);
SPI.begin();
return radio.std_init(&SPI);
}

View File

@@ -7,37 +7,46 @@
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"
#include "nrf.h"
const uint32_t g_ADigitalPinMap[] = {
// P0
0, 1, 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,
const uint32_t g_ADigitalPinMap[] =
{
// P0
0 , 1 , 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
};
// P1
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
void initVariant()
{
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
// LED1 & LED2
pinMode(PIN_LED1, OUTPUT);
ledOff(PIN_LED1);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
pinMode(PIN_LED2, OUTPUT);
ledOff(PIN_LED2);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);
// 3V3 Power Rail
pinMode(PIN_3V3_EN, OUTPUT);
digitalWrite(PIN_3V3_EN, HIGH);
}

View File

@@ -34,7 +34,8 @@
#include "WVariant.h"
#ifdef __cplusplus
extern "C" {
extern "C"
{
#endif // __cplusplus
// Number of pins defined in PinDescription array
@@ -58,8 +59,8 @@ extern "C" {
/*
* Analog pins
*/
#define PIN_A0 (5)
#define PIN_A1 (31)
#define PIN_A0 (5) //(3)
#define PIN_A1 (31) //(4)
#define PIN_A2 (28)
#define PIN_A3 (29)
#define PIN_A4 (30)
@@ -67,14 +68,14 @@ extern "C" {
#define PIN_A6 (0xff)
#define PIN_A7 (0xff)
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
static const uint8_t A0 = PIN_A0;
static const uint8_t A1 = PIN_A1;
static const uint8_t A2 = PIN_A2;
static const uint8_t A3 = PIN_A3;
static const uint8_t A4 = PIN_A4;
static const uint8_t A5 = PIN_A5;
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
#define ADC_RESOLUTION 14
// Other pins
@@ -92,6 +93,7 @@ static const uint8_t AREF = PIN_AREF;
/*
* Serial interfaces
*/
// TXD1 RXD1 on Base Board
#define PIN_SERIAL1_RX (15)
#define PIN_SERIAL1_TX (16)
@@ -108,15 +110,14 @@ static const uint8_t AREF = PIN_AREF;
#define PIN_SPI_MOSI (44)
#define PIN_SPI_SCK (43)
// SPI1 pins for RAK13302 1W LoRa module
#define PIN_SPI1_MISO (29) // (0 + 29)
#define PIN_SPI1_MOSI (30) // (0 + 30)
#define PIN_SPI1_SCK (3) // (0 + 3)
#define PIN_SPI1_MISO (29)
#define PIN_SPI1_MOSI (30)
#define PIN_SPI1_SCK (3)
static const uint8_t SS = 42;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
static const uint8_t SS = 42;
static const uint8_t MOSI = PIN_SPI_MOSI;
static const uint8_t MISO = PIN_SPI_MISO;
static const uint8_t SCK = PIN_SPI_SCK;
/*
* Wire Interfaces
@@ -127,6 +128,7 @@ static const uint8_t SCK = PIN_SPI_SCK;
#define PIN_WIRE_SCL (WB_I2C1_SCL)
// QSPI Pins
// QSPI occupied by GPIO's
#define PIN_QSPI_SCK 3
#define PIN_QSPI_CS 26
#define PIN_QSPI_IO0 30
@@ -135,35 +137,25 @@ static const uint8_t SCK = PIN_SPI_SCK;
#define PIN_QSPI_IO3 2
// On-board QSPI Flash
// No onboard flash
#define EXTERNAL_FLASH_DEVICES IS25LP080D
#define EXTERNAL_FLASH_USE_QSPI
// RAK13302 1W LoRa transceiver module (uses SPI1)
// LoRa radio module pins for RAK3401 with RAK13302
#define P_LORA_DIO_1 10
#define P_LORA_NSS 26
#define P_LORA_RESET 4
#define P_LORA_BUSY 9
#define P_LORA_SCLK PIN_SPI1_SCK // 3
#define P_LORA_MISO PIN_SPI1_MISO // 29
#define P_LORA_MOSI PIN_SPI1_MOSI // 30
#define SX126X_POWER_EN 21
#define P_LORA_SCK PIN_SPI1_SCK
#define P_LORA_MISO PIN_SPI1_MISO
#define P_LORA_MOSI PIN_SPI1_MOSI
#define P_LORA_CS 26
// RAK13302 1W LoRa transceiver module PA control (WisBlock IO slot)
// The RAK13302 mounts to the IO slot and has an ANT_SW (antenna switch) pin that controls the PA
// This pin must be controlled during transmission to enable the 1W power amplifier
//
// According to RAK13302 datasheet: ANT_SW connects to IO3 on the IO slot
// RAK19007 base board pin mapping: IO3 = pin 31 (also available as AIN1/A1 for analog input)
//
// Default: Pin 31 (IO3) - ANT_SW pin from RAK13302 datasheet
// Override by defining P_LORA_PA_EN in platformio.ini if needed
#ifndef P_LORA_PA_EN
#define P_LORA_PA_EN 31 // ANT_SW pin from RAK13302 datasheet (IO3, pin 31 on RAK19007)
#endif
#define USE_SX1262
#define SX126X_CS (26)
#define SX126X_DIO1 (10)
#define SX126X_BUSY (9)
#define SX126X_RESET (4)
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#define SX126X_POWER_EN (21)
// DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
// enables 3.3V periphery like GPS or IO Module
// Do not toggle this for GPS power savings
@@ -178,8 +170,8 @@ static const uint8_t SCK = PIN_SPI_SCK;
// Power is on the controllable 3V3_S rail
#define PIN_GPS_PPS (17) // Pulse per second input from the GPS
#define GPS_RX_PIN PIN_SERIAL1_RX
#define GPS_TX_PIN PIN_SERIAL1_TX
#define PIN_GPS_RX PIN_SERIAL1_RX
#define PIN_GPS_TX PIN_SERIAL1_TX
// Battery
// The battery sense is hooked to pin A0 (5)