[nibeheatpump] arduino nibegw: added STM32 nucleo-F429ZI support (#9933)

Signed-off-by: Tobi <real_1988@web.de>
This commit is contained in:
Tobi0610 2021-04-11 20:17:59 +02:00 committed by GitHub
parent df3917a0db
commit 9e4b67ee09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 0 deletions

View File

@ -30,6 +30,9 @@
//#define PRODINO_BOARD //#define PRODINO_BOARD
// Enable if ENC28J60 LAN module is used // Enable if ENC28J60 LAN module is used
//#define TRANSPORT_ETH_ENC28J60 //#define TRANSPORT_ETH_ENC28J60
// Enable if you use STM32 NUCLEO-F429ZI
//#define STM32_F429ZI_BOARD
// Enable debug printouts, listen printouts e.g. via netcat (nc -l -u 50000) // Enable debug printouts, listen printouts e.g. via netcat (nc -l -u 50000)
//#define ENABLE_DEBUG //#define ENABLE_DEBUG
@ -54,6 +57,11 @@
#ifdef PRODINO_BOARD #ifdef PRODINO_BOARD
#define RS485_PORT Serial1 #define RS485_PORT Serial1
#define RS485_DIRECTION_PIN 3 #define RS485_DIRECTION_PIN 3
#elif defined STM32_F429ZI_BOARD
#include <HardwareSerial.h>
HardwareSerial Serial1(PG9,PG14);
#define RS485_PORT Serial1
#define RS485_DIRECTION_PIN PF15
#else #else
#define RS485_PORT Serial #define RS485_PORT Serial
#define RS485_DIRECTION_PIN 2 #define RS485_DIRECTION_PIN 2
@ -70,6 +78,10 @@
#ifdef TRANSPORT_ETH_ENC28J60 #ifdef TRANSPORT_ETH_ENC28J60
#include <UIPEthernet.h> #include <UIPEthernet.h>
#elif defined STM32_F429ZI_BOARD
#include <LwIP.h>
#include <STM32Ethernet.h>
#include <EthernetUdp.h>
#else #else
#include <SPI.h> #include <SPI.h>
#include <Ethernet.h> #include <Ethernet.h>
@ -81,7 +93,11 @@
#include "KMPCommon.h" #include "KMPCommon.h"
#endif #endif
#ifdef STM32_F429ZI_BOARD
#include <IWatchdog.h>
#else
#include <avr/wdt.h> #include <avr/wdt.h>
#endif
#include "NibeGw.h" #include "NibeGw.h"
@ -142,12 +158,24 @@ void debugPrint(char* data)
} }
#endif #endif
// ######### FUNCTION DEFINITION ######################
void nibeCallbackMsgReceived(const byte* const data, int len);
int nibeCallbackTokenReceived(eTokenType token, byte* data);
void sendUdpPacket(const byte * const data, int len);
void initializeEthernet();
// ######### SETUP ####################### // ######### SETUP #######################
void setup() void setup()
{ {
// Start watchdog // Start watchdog
#ifdef STM32_F429ZI_BOARD
IWatchdog.begin(2000000); // 2 sec
#else
wdt_enable (WDTO_2S); wdt_enable (WDTO_2S);
#endif
nibegw.setCallback(nibeCallbackMsgReceived, nibeCallbackTokenReceived); nibegw.setCallback(nibeCallbackMsgReceived, nibeCallbackTokenReceived);
nibegw.setAckModbus40Address(ACK_MODBUS40); nibegw.setAckModbus40Address(ACK_MODBUS40);
@ -174,7 +202,11 @@ void setup()
void loop() void loop()
{ {
#ifdef STM32_F429ZI_BOARD
IWatchdog.reload();
#else
wdt_reset(); wdt_reset();
#endif
long now = millis() / 1000; long now = millis() / 1000;
@ -227,6 +259,7 @@ void initializeEthernet()
{ {
Ethernet.begin(mac, ip, gw, mask); Ethernet.begin(mac, ip, gw, mask);
ethernetInitialized = true; ethernetInitialized = true;
udp.begin(TARGET_PORT);
udp4readCmnds.begin(INCOMING_PORT_READCMDS); udp4readCmnds.begin(INCOMING_PORT_READCMDS);
udp4writeCmnds.begin(INCOMING_PORT_WRITECMDS); udp4writeCmnds.begin(INCOMING_PORT_WRITECMDS);
} }