Closed tcpipchip closed 2 years ago
Hi @tcpipchip
I'm sorry I don't have that kind of hardware to help you, but these are steps you can try, test and adapt
variant_generic.h
#ifndef PIN_SPI3_MOSI
//LOM204
#define PIN_SPI3_MOSI PB15
#endif
#ifndef PIN_SPI3_MISO
//LOM204
#define PIN_SPI3_MISO PB14
#endif
#ifndef PIN_SPI3_SCK
//LOM204
#define PIN_SPI3_SCK PB13
#endif
#ifndef PIN_SPI_SS3
//LOM204
#define PIN_SPI_SS3 PB16 // Or another good pin
#endif
// SPIClass(uint32_t mosi, uint32_t miso, uint32_t sclk, uint32_t ssel = PNUM_NOT_DEFINED);
SPIClass SPI3(PIN_SPI3_MOSI, PIN_SPI3_MISO, PIN_SPI3_SCK, PIN_SPI_SS3);
such as
#elif (ETHERNET_USE_RPIPICO && !defined(ARDUINO_ARCH_MBED))
// For arduino-pico core
// SPIClassRP2040(spi_inst_t *spi, pin_size_t rx, pin_size_t cs, pin_size_t sck, pin_size_t tx);
SPIClass* pCUR_SPI = (SPIClass*) &SPI1;
#define CUR_PIN_MISO PIN_SPI1_MISO
#define CUR_PIN_MOSI PIN_SPI1_MOSI
#define CUR_PIN_SCK PIN_SPI1_SCK
#define CUR_PIN_SS PIN_SPI1_SS
#elif defined(STM32L0)
// For STM32L072 of LOM204
// SPIClass SPI3(PIN_SPI3_MOSI, PIN_SPI3_MISO, PIN_SPI3_SCK, PIN_SPI_SS3);
SPIClass* pCUR_SPI = (SPIClass*) &SPI3;
#endif
#define USING_SPI2 true
before
#include "Ethernet_Generic.h"
These steps are just drafted and not tested, you have to test and adapt according to your hardware and condition.
Good Luck
PS:
Why don't share the same SPI bus for both Ethernet and SX1276 LoRaWAN? Possibly some mods in the code and/or hardware to select the CS/SS pin to avoid SPI-bus monopolization
Thank you so much KHOIH I will make the changes tomorrow
I can not share the sx1276 and Ethernet with the same bus because I don’t have the physical access to the spi gpios connected to sx1276, only access to a second spi bus
Lom204 is a module
?
because in main() I see
ETG_LOGWARN(F("Default SPI pinout:"));
ETG_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI);
ETG_LOGWARN1(F("MISO:"), CUR_PIN_MISO);
ETG_LOGWARN1(F("SCK:"), CUR_PIN_SCK);
ETG_LOGWARN1(F("SS:"), CUR_PIN_SS);
It's not important as each board is using the different notation.
So I just name
#define USING_SPI2 true
for any SPI besides SPI0/SPI1
I've modified the libraries and tested OK on Nucleo144 F767ZI and L552ZE-Q using SPI2. I'll publish new releases of this Ethernet_Generic and EthernetWebServer_STM32 to support SPI2, or any custom hardware SPI
I'm sure you can adapt the code and be OK.
Start WebClientRepeating on NUCLEO_F767ZI, using W5x00 using Ethernet_Generic Library on SPI2
EthernetWebServer_STM32 v1.4.2
[EWS] Default SPI pinout:
[EWS] MOSI: 22
[EWS] MISO: 25
[EWS] SCK: 23
[EWS] SS: 24
[EWS] =========================
Connected! IP address: 192.168.2.123
Connecting...
HTTP/1.1 200 OK
Date: Tue, 03 May 2022 02:21:30 GMT
Content-Type: text/plain
Content-Length: 2263
Connection: close
x-amz-id-2: 3UTJOk8AtRD5jCq+6bBOdAUucpho+KMM4ra+5/evX48oAT9NyZiaJbPNw5DOAr+amoxXbxbowX0=
x-amz-request-id: RB5W2BTZZ19E49PA
Last-Modified: Wed, 23 Feb 2022 14:56:42 GMT
ETag: "667cf48afcc12c38c8c1637947a04224"
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=GhwgztuLVJJhJBZt6cqr%2BYWDLWUzEcRPjVVpSU3Sz9KSRzj4q4DK9bvi1B2BSl7uxytKSSxOFBnKeekqPJw9LvpyYpYvHuOVcxatw924HWhtyK1OCApzLxZRLmobotQ%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 705586061d4354d9-YYZ
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
`:;;;,` .:;;:.
.;;;;;;;;;;;` :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;;;;;: ;; ;; .;; ;; ,;, ;;`;;;, ;; ;;`
,;;;;; ;;`;; ;; ;; .;; ;; ,;, ;; ;;;, ;; ;;
;; ,;, ;; .;; ;;;;;: ;;;;;: ,;;;;;: ;; ;;, ;;;;;;
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
Start WebClientRepeating on NUCLEO_L552ZE_Q, using W5x00 using Ethernet_Generic Library on SPI2
EthernetWebServer_STM32 v1.4.2
[EWS] Default SPI pinout:
[EWS] MOSI: 22
[EWS] MISO: 25
[EWS] SCK: 23
[EWS] SS: 24
[EWS] =========================
Connected! IP address: 192.168.2.123
Connecting...
HTTP/1.1 200 OK
Date: Tue, 03 May 2022 02:40:24 GMT
Content-Type: text/plain
Content-Length: 2263
Connection: close
x-amz-id-2: 46EhWX58C9hyDf7ag/cTxLHtNc/l+uC2facDUqKXDnm4pAdM3721pkdwUwjVF0O7mr1MGAcjQiY=
x-amz-request-id: 04CEE3RJB7W2M05T
Last-Modified: Wed, 23 Feb 2022 14:56:42 GMT
ETag: "667cf48afcc12c38c8c1637947a04224"
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=TYzyXPfNW7yd579FqPTzYEXQnSRcAFeyj74iulNNRmVZEUk6Qz%2F2dgIwFVJxacbwtzdVR9Q2FK2cgryr0GC9k3NfyFAgZpLZIjEwfEhycKWnNE9KxX%2F%2B6dRwTLcV9hY%3D"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 7055a1b9cda84009-YYZ
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
`:;;;,` .:;;:.
.;;;;;;;;;;;` :;;;;;;;;;;: TM
`;;;;;;;;;;;;;;;` :;;;;;;;;;;;;;;;
:;;;;;;;;;;;;;;;;;; `;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;; .;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;;;;: ;; ;;, ;;;;;;
;; ;; ;; ;;` ;;;;. `;;;: ,;;;;;, ;; ;;, ;;;;
The Ethernet_Generic releases v2.2.0 has just been published
You now can use any SPI with STM32, or any future boards.
To adapt to any STM32 board, just simply change in defines.h
, for examples
SPI
, for example STM32.The EthernetWebServer_STM32 releases v1.5.0 has just been published
You now can use any SPI with STM32
To adapt to any STM32 board, just simply change in defines.h
, for examples
#if USE_ETHERNET_GENERIC
#include <SPI.h>
// Be sure to use true only if necessary for your board, or compile error
#define USING_CUSTOM_SPI true
#if ( USING_CUSTOM_SPI )
// Currently test OK for F767ZI and L552ZE_Q
#define USING_SPI2 true
#define SHIELD_TYPE "W5x00 using Ethernet_Generic Library and custom SPI"
#if (USING_SPI2)
// For L552ZE-Q, F767ZI, but you can change the pins for any other boards
// SCK: 23, MOSI: 22, MISO: 25, SS/CS: 24 for SPI1
#define CUR_PIN_MISO 25
#define CUR_PIN_MOSI 22
#define CUR_PIN_SCK 23
#define CUR_PIN_SS 24
#define SPI_NEW_INITIALIZED true
// Don't create the instance with CUR_PIN_SS, or Ethernet not working
// To change for other boards' SPI libraries
SPIClass SPI_New(CUR_PIN_MOSI, CUR_PIN_MISO, CUR_PIN_SCK);
//#warning Using USE_THIS_SS_PIN = CUR_PIN_SS = 24
#if defined(USE_THIS_SS_PIN)
#undef USE_THIS_SS_PIN
#endif
#define USE_THIS_SS_PIN CUR_PIN_SS //24
#endif
#else
#define SHIELD_TYPE "W5x00 using Ethernet_Generic Library"
#endif
#include "Ethernet_Generic.h"
#define ETHERNET_LARGE_BUFFERS
#define _ETG_LOGLEVEL_ 1
#endif
SPI
for W5x00 using Ethernet_Generic LibraryNucleo-L552ZE-Q
Nice! I will test it this afternoon :) LoRaWAN and Ethernet together 😀
Good morning
WISOL LOM204 LoRaWAN + W5500 working together :)
i will test more then we update the Github :)
Tests ok
Wich software terminal do you use to show aligment arduino text (splash)?
Just using Arduino IDE Terminal.
IMO, good and reliable terminal must be dumb and just printing out whatever the output is.
You have to format the output as you'd like before sending any text to the terminal.
Dear Khoih
I am using the STM32L0 + SX1276 (LoRaWAN WISOL LOM204 MODULE).
I ported the STM32 ARDUINO to it and working nice!
The module uses the SPI, not the SPI1 or SPI2
Now i want to add the WIZNET W500 to SPI1 , did you port the defines to use the SPI1 to WIZNET ?
I spent some hours without success!
My idea is to use the SPI (SX1276) and SPI1 (WIZNET) togetther, btw, add ETHERNET to LOM204