diff --git a/platformio.ini b/platformio.ini index bf50b7646..3129decaa 100644 --- a/platformio.ini +++ b/platformio.ini @@ -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 @@ -164,4 +165,4 @@ lib_deps = robtillaart/INA226@0.6.0 ; Health Sensor Libraries - sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@1.1.2 \ No newline at end of file + sparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library@1.1.2 diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 3b4d716f5..08ecb7ce8 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -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); @@ -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]; diff --git a/variants/rak11310/pins_arduino.h b/variants/rak11310/pins_arduino.h index 626bed1da..0e2808b19 100644 --- a/variants/rak11310/pins_arduino.h +++ b/variants/rak11310/pins_arduino.h @@ -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) @@ -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; \ No newline at end of file +static const uint8_t SCL = PIN_WIRE0_SCL; diff --git a/variants/rak11310/platformio.ini b/variants/rak11310/platformio.ini index 923cedaa3..0cc60bc7c 100644 --- a/variants/rak11310/platformio.ini +++ b/variants/rak11310/platformio.ini @@ -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> + + + 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 \ No newline at end of file +debug_tool = cmsis-dap ; for e.g. Picotool diff --git a/variants/rak11310/variant.h b/variants/rak11310/variant.h index 54e403ee7..bc8d2d71b 100644 --- a/variants/rak11310/variant.h +++ b/variants/rak11310/variant.h @@ -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 @@ -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