Skip to content

Commit

Permalink
Add Ethernet RAK13800 support to RAK11310 (#5707)
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo authored Dec 31, 2024
1 parent 58ebd5b commit 9af8c58
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
3 changes: 2 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ default_envs = tbeam
;default_envs = rak4631
;default_envs = rak4631_eth_gw
;default_envs = rak2560
;default_envs = rak11310
;default_envs = rak_wismeshtap
;default_envs = wio-e5
;default_envs = radiomaster_900_bandit_nano
Expand Down Expand Up @@ -164,4 +165,4 @@ lib_deps =
robtillaart/[email protected]

; Health Sensor Libraries
sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor [email protected]
sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor [email protected]
11 changes: 11 additions & 0 deletions src/mesh/eth/ethClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ static int32_t reconnectETH()
bool initEthernet()
{
if (config.network.eth_enabled) {
#ifdef PIN_ETH_POWER_EN
pinMode(PIN_ETH_POWER_EN, OUTPUT);
digitalWrite(PIN_ETH_POWER_EN, HIGH); // Power up.
delay(100);
#endif

#ifdef PIN_ETHERNET_RESET
pinMode(PIN_ETHERNET_RESET, OUTPUT);
Expand All @@ -115,6 +120,12 @@ bool initEthernet()
digitalWrite(PIN_ETHERNET_RESET, HIGH); // Reset Time.
#endif

#ifdef RAK11310 // Initialize the SPI port
ETH_SPI_PORT.setSCK(PIN_SPI0_SCK);
ETH_SPI_PORT.setTX(PIN_SPI0_MOSI);
ETH_SPI_PORT.setRX(PIN_SPI0_MISO);
ETH_SPI_PORT.begin();
#endif
Ethernet.init(ETH_SPI_PORT, PIN_ETHERNET_SS);

uint8_t mac[6];
Expand Down
18 changes: 9 additions & 9 deletions variants/rak11310/pins_arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ static const uint8_t A3 = PIN_A3;
#define PIN_SERIAL2_RX (5ul)

// SPI
#define PIN_SPI0_MISO (12u)
#define PIN_SPI0_MOSI (11u)
#define PIN_SPI0_SCK (10u)
#define PIN_SPI0_SS (13u)
#define PIN_SPI1_MISO (12u)
#define PIN_SPI1_MOSI (11u)
#define PIN_SPI1_SCK (10u)
#define PIN_SPI1_SS (13u)

#define PIN_SPI1_MISO (16u)
#define PIN_SPI1_MOSI (19u)
#define PIN_SPI1_SCK (18u)
#define PIN_SPI1_SS (17u)
#define PIN_SPI0_MISO (16u)
#define PIN_SPI0_MOSI (19u)
#define PIN_SPI0_SCK (18u)
#define PIN_SPI0_SS (17u)

// Wire
#define PIN_WIRE0_SDA (2u)
Expand All @@ -65,4 +65,4 @@ static const uint8_t MISO = PIN_SPI0_MISO;
static const uint8_t SCK = PIN_SPI0_SCK;

static const uint8_t SDA = PIN_WIRE0_SDA;
static const uint8_t SCL = PIN_WIRE0_SCL;
static const uint8_t SCL = PIN_WIRE0_SCL;
5 changes: 4 additions & 1 deletion variants/rak11310/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ build_flags = ${rp2040_base.build_flags}
-Ivariants/rak11310
-DDEBUG_RP2040_PORT=Serial
-L "${platformio.libdeps_dir}/${this.__env__}/bsec2/src/cortex-m0plus"
build_src_filter = ${rp2040_base.build_src_filter} +<../variants/rak11310> +<mesh/eth/> +<mesh/api/> +<mqtt/>
lib_deps =
${rp2040_base.lib_deps}
${networking_base.lib_deps}
https://github.com/RAKWireless/RAK13800-W5100S.git#1.0.2
debug_build_flags = ${rp2040_base.build_flags}, -g
debug_tool = cmsis-dap ; for e.g. Picotool
debug_tool = cmsis-dap ; for e.g. Picotool
15 changes: 11 additions & 4 deletions variants/rak11310/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

// RAK BSP somehow uses SPI1 instead of SPI0
#define HW_SPI1_DEVICE
#define LORA_SCK PIN_SPI0_SCK
#define LORA_MOSI PIN_SPI0_MOSI
#define LORA_MISO PIN_SPI0_MISO
#define LORA_CS PIN_SPI0_SS
#define LORA_SCK (10u)
#define LORA_MOSI (11u)
#define LORA_MISO (12u)
#define LORA_CS (13u)

#define LORA_DIO0 RADIOLIB_NC
#define LORA_RESET 14
Expand All @@ -49,3 +49,10 @@
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
#endif

#define HAS_ETHERNET 1
#define PIN_ETHERNET_RESET 7 // IO3
#define PIN_ETHERNET_SS 17
#define ETH_SPI_PORT SPI

#define PIN_ETH_POWER_EN 22

0 comments on commit 9af8c58

Please sign in to comment.