From 6123f80e39cbe5b8c8a4b4f5407b1fa04402e998 Mon Sep 17 00:00:00 2001 From: pennam Date: Tue, 20 Sep 2022 10:54:26 +0200 Subject: [PATCH] Add common define for STM32H7 boards --- src/AIoTC_Config.h | 4 ++++ src/ArduinoIoTCloudTCP.cpp | 8 ++++---- src/utility/ota/OTA-portenta-h7.cpp | 8 +++++--- src/utility/ota/OTA.h | 2 +- src/utility/watchdog/Watchdog.cpp | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index c81a298c9..e92d9647e 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -141,6 +141,10 @@ #define HAS_TCP #endif +#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) + #define BOARD_STM32H7 +#endif + /****************************************************************************** * CONSTANTS ******************************************************************************/ diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index f7e0c4ca6..f33f09c5e 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -38,7 +38,7 @@ #include "tls/utility/CryptoUtil.h" #endif -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#ifdef BOARD_STM32H7 # include "tls/utility/SHA256.h" # include # include @@ -56,7 +56,7 @@ * EXTERN ******************************************************************************/ -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#ifdef BOARD_STM32H7 extern RTC_HandleTypeDef RTCHandle; #endif @@ -151,7 +151,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress, #endif /* AVR */ #if OTA_ENABLED && !defined(__AVR__) -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#if defined(BOARD_STM32H7) /* The length of the application can be retrieved the same way it was * communicated to the bootloader, that is by writing to the non-volatile * storage registers of the RTC. @@ -829,7 +829,7 @@ void ArduinoIoTCloudTCP::onOTARequest() _ota_error = rp2040_connect_onOTARequest(_ota_url.c_str()); #endif -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#ifdef BOARD_STM32H7 _ota_error = portenta_h7_onOTARequest(_ota_url.c_str()); #endif } diff --git a/src/utility/ota/OTA-portenta-h7.cpp b/src/utility/ota/OTA-portenta-h7.cpp index cb8358290..4b0c635da 100644 --- a/src/utility/ota/OTA-portenta-h7.cpp +++ b/src/utility/ota/OTA-portenta-h7.cpp @@ -15,12 +15,14 @@ a commercial license, send an email to license@arduino.cc. */ -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) - /****************************************************************************** * INCLUDE ******************************************************************************/ +#include + +#ifdef BOARD_STM32H7 + #include "OTA.h" #include @@ -87,4 +89,4 @@ int portenta_h7_onOTARequest(char const * ota_url) NVIC_SystemReset(); } -#endif /* defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) */ +#endif /* BOARD_STM32H7 */ diff --git a/src/utility/ota/OTA.h b/src/utility/ota/OTA.h index d5364242a..ce47a3ad2 100644 --- a/src/utility/ota/OTA.h +++ b/src/utility/ota/OTA.h @@ -62,7 +62,7 @@ int samd_onOTARequest(char const * ota_url); int rp2040_connect_onOTARequest(char const * ota_url); #endif -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#ifdef BOARD_STM32H7 int portenta_h7_onOTARequest(char const * ota_url); #endif diff --git a/src/utility/watchdog/Watchdog.cpp b/src/utility/watchdog/Watchdog.cpp index 7fdbbd347..d639d30a7 100644 --- a/src/utility/watchdog/Watchdog.cpp +++ b/src/utility/watchdog/Watchdog.cpp @@ -91,7 +91,7 @@ void mkr_nb_feed_watchdog() static void mbed_watchdog_enable() { watchdog_config_t cfg; -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#if defined(BOARD_STM32H7) cfg.timeout_ms = PORTENTA_H7_WATCHDOG_MAX_TIMEOUT_ms; #elif defined(ARDUINO_NANO_RP2040_CONNECT) cfg.timeout_ms = NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms; @@ -117,7 +117,7 @@ static void mbed_watchdog_reset() void mbed_watchdog_trigger_reset() { watchdog_config_t cfg; -#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) +#if defined(BOARD_STM32H7) cfg.timeout_ms = 1; #elif defined(ARDUINO_NANO_RP2040_CONNECT) cfg.timeout_ms = 1;