Code Monkey home page Code Monkey logo

Comments (12)

tcpipchip avatar tcpipchip commented on July 28, 2024 1

Good morning

image

WISOL LOM204 LoRaWAN + W5500 working together :)

image

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024 1

thank you!
https://lom204-cli-wisol.blogspot.com/2022/05/importante-opcao-nao-oficial-da-wisol.html

from ethernet_generic.

khoih-prog avatar khoih-prog commented on July 28, 2024

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

  1. Define the new and extra SPI, such as SPI3 as you did in 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
  1. Modify STM32 SPI library, or add somewhere in your code, to create an instance of SPI3 for STM32L072
// 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);
  1. Modify the file w5100_Impl.h to add STM32L072-related code

#if (ETHERNET_GENERIC_USING_SPI2)
#if(_ETG_LOGLEVEL_> 2)
#warning ETHERNET_GENERIC_USING_SPI2 in w5100_Impl.h
#endif
#if defined(ESP32)
SPIClass SPI2(HSPI);
SPIClass* pCUR_SPI = &SPI2;
#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
#endif
#else
#if(_ETG_LOGLEVEL_> 2)
#warning ETHERNET_GENERIC_USING_SPI in w5100_Impl.h
#endif
SPIClass* pCUR_SPI = &SPI;
#endif

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  
  1. In you code, select
#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

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024

#define USING_SPI2 true OR the correct is
#define USING_SPI3 true

?

because in main() I see

#if (USING_SPI2)
#if defined(CUR_PIN_MISO)
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);

from ethernet_generic.

khoih-prog avatar khoih-prog commented on July 28, 2024

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.


WebClientRepeating on NUCLEO_F767ZI, using W5x00 using Ethernet_Generic Library on SPI2

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


           `:;;;,`                      .:;;:.           
        .;;;;;;;;;;;`                :;;;;;;;;;;:     TM 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

WebClientRepeating on NUCLEO_L552ZE_Q, using W5x00 using Ethernet_Generic Library on SPI2

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 
      `;;;;;;;;;;;;;;;`            :;;;;;;;;;;;;;;;      
     :;;;;;;;;;;;;;;;;;;         `;;;;;;;;;;;;;;;;;;     
    ;;;;;;;;;;;;;;;;;;;;;       .;;;;;;;;;;;;;;;;;;;;    
   ;;;;;;;;:`   `;;;;;;;;;     ,;;;;;;;;.`   .;;;;;;;;   
  .;;;;;;,         :;;;;;;;   .;;;;;;;          ;;;;;;;  
  ;;;;;;             ;;;;;;;  ;;;;;;,            ;;;;;;. 
 ,;;;;;               ;;;;;;.;;;;;;`              ;;;;;; 
 ;;;;;.                ;;;;;;;;;;;`      ```       ;;;;;`
 ;;;;;                  ;;;;;;;;;,       ;;;       .;;;;;
`;;;;:                  `;;;;;;;;        ;;;        ;;;;;
,;;;;`    `,,,,,,,,      ;;;;;;;      .,,;;;,,,     ;;;;;
:;;;;`    .;;;;;;;;       ;;;;;,      :;;;;;;;;     ;;;;;
:;;;;`    .;;;;;;;;      `;;;;;;      :;;;;;;;;     ;;;;;
.;;;;.                   ;;;;;;;.        ;;;        ;;;;;
 ;;;;;                  ;;;;;;;;;        ;;;        ;;;;;
 ;;;;;                 .;;;;;;;;;;       ;;;       ;;;;;,
 ;;;;;;               `;;;;;;;;;;;;                ;;;;; 
 `;;;;;,             .;;;;;; ;;;;;;;              ;;;;;; 
  ;;;;;;:           :;;;;;;.  ;;;;;;;            ;;;;;;  
   ;;;;;;;`       .;;;;;;;,    ;;;;;;;;        ;;;;;;;:  
    ;;;;;;;;;:,:;;;;;;;;;:      ;;;;;;;;;;:,;;;;;;;;;;   
    `;;;;;;;;;;;;;;;;;;;.        ;;;;;;;;;;;;;;;;;;;;    
      ;;;;;;;;;;;;;;;;;           :;;;;;;;;;;;;;;;;:     
       ,;;;;;;;;;;;;;,              ;;;;;;;;;;;;;;       
         .;;;;;;;;;`                  ,;;;;;;;;:         
                                                         
                                                         
                                                         
                                                         
    ;;;   ;;;;;`  ;;;;:  .;;  ;; ,;;;;;, ;;. `;,  ;;;;   
    ;;;   ;;:;;;  ;;;;;; .;;  ;; ,;;;;;: ;;; `;, ;;;:;;  
   ,;:;   ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;,`;, ;;  ;;  
   ;; ;:  ;;  ;;  ;;  ;; .;;  ;;   ,;,   ;;;;`;, ;;  ;;. 
   ;: ;;  ;;;;;:  ;;  ;; .;;  ;;   ,;,   ;;`;;;, ;;  ;;` 
  ,;;;;;  ;;`;;   ;;  ;; .;;  ;;   ,;,   ;; ;;;, ;;  ;;  
  ;;  ,;, ;; .;;  ;;;;;:  ;;;;;: ,;;;;;: ;;  ;;, ;;;;;;  
  ;;   ;; ;;  ;;` ;;;;.   `;;;:  ,;;;;;, ;;  ;;,  ;;;;   

from ethernet_generic.

khoih-prog avatar khoih-prog commented on July 28, 2024

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

// For boards supporting multiple hardware / software SPI buses, such as STM32
// Tested OK with Nucleo144 F767ZI and L552ZE_Q so far
#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) || defined(STM32L5) )
// 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
#if (USING_SPI2)
//#include <SPI.h>
// 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
#endif
#endif


Releases v2.2.0

  1. Add support to STM32 boards using Arduino_Core_STM32
  2. Add support to any board with core supporting custom hardware / software SPI, for example STM32.

from ethernet_generic.

khoih-prog avatar khoih-prog commented on July 28, 2024

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

https://github.com/khoih-prog/EthernetWebServer_STM32/blob/0f96707eff5d79ff252a97026b28a927d511cef9/examples/AdvancedWebServer/defines.h#L87-L135

#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

Releases v1.5.0

  1. Add support to any custom hardware / software SPI for W5x00 using Ethernet_Generic Library
  2. Add support to STM32L5 boards, such as Nucleo-L552ZE-Q

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024

Nice! I will test it this afternoon :)
LoRaWAN and Ethernet together πŸ˜€

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024

i will test more then we update the Github :)

from ethernet_generic.

tcpipchip avatar tcpipchip commented on July 28, 2024

Tests ok

Wich software terminal do you use to show aligment arduino text (splash)?

image

from ethernet_generic.

khoih-prog avatar khoih-prog commented on July 28, 2024

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.

from ethernet_generic.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.