From d51de8fbd02b1c4e9b237400257e8424c325ad5c Mon Sep 17 00:00:00 2001 From: arcayi Date: Tue, 18 Aug 2020 20:18:55 +0800 Subject: [PATCH 1/2] nothing but .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index bec8ade2e..48c875d1b 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ doxygen.log TAGS tags .DS_Store +.vscode/ +.clang-format From 4f7a96b614acf9abd930a21f71ba162995d82790 Mon Sep 17 00:00:00 2001 From: arcayi Date: Tue, 14 Jul 2020 11:50:54 +0800 Subject: [PATCH 2/2] add support of stm32duino/Arduino_Core_STM32 --- .../configuration-stm32duino-stm32f1c8t6.png | Bin 0 -> 18305 bytes MySensors.h | 7 +- README.stm32duino.md | 25 +++ core/MyCapabilities.h | 4 +- .../SecurityPersonalizer.ino | 2 + hal/architecture/STM32/MyHwSTM32.cpp | 184 ++++++++++++++++++ hal/architecture/STM32/MyHwSTM32.h | 98 ++++++++++ hal/architecture/STM32/MyMainSTM32.cpp | 64 ++++++ .../STM32/drivers/hal_conf_custom.h | 66 +++++++ .../drivers/stm32_ADC_internal_channels.h | 95 +++++++++ hal/transport/RF24/driver/RF24.h | 2 + hal/transport/RFM69/driver/new/RFM69_new.h | 2 + hal/transport/RFM69/driver/old/RFM69_old.h | 3 + hal/transport/RFM95/driver/RFM95.h | 2 + 14 files changed, 552 insertions(+), 2 deletions(-) create mode 100644 Documentation/img/configuration-stm32duino-stm32f1c8t6.png create mode 100644 README.stm32duino.md create mode 100644 hal/architecture/STM32/MyHwSTM32.cpp create mode 100644 hal/architecture/STM32/MyHwSTM32.h create mode 100644 hal/architecture/STM32/MyMainSTM32.cpp create mode 100644 hal/architecture/STM32/drivers/hal_conf_custom.h create mode 100644 hal/architecture/STM32/drivers/stm32_ADC_internal_channels.h diff --git a/Documentation/img/configuration-stm32duino-stm32f1c8t6.png b/Documentation/img/configuration-stm32duino-stm32f1c8t6.png new file mode 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mGNDG;gEyj(5#6tgqFHJ_M8-f+ z-s4iM*O|k2QSYIm^&Ta-KH6_PM(@>%j#sGf!2s6X20IHK1HOH9WF@d^sI>RO@PuKN zBZ~OssIK-_Ygtan4nT4x-JG!jYyfq(C6m-*>fhL<&Ga_0df5e#JJ&N)FH}f>8w9 z<_!4*umIdUA2=C653mw=5d=eOuE))Ta;Eot^^@^7>!Rf{hj*fEtbKX61`#>VASZ<{ zhZfKo953oKTID;Ne z<}i(_1q}CLwx)+NX|(+nF|C9E7?S$x?_+qhJhk7y&=0L@LL5KWi&QNXnk@$&qF@yaUATd&rzb@+9~Dn zFOft?hb!Q$_;xw7}M$~&}Bh#cImr6P}ohy>!2M=noadrBi)MH#D1hsztHk4UNSZK z>|!Hw$f+7Kr8lOd(529Wf&np>R=N}X)7|Z@*<#4Hhk*(nM<%e8~y#XbukywyWy_7JR^ML+I)3` z@r{t97J^q;{|foeuP)SfNu9Qj)qkx#r& z`G%}C%w@akgJZD17#0Qm6?1hyPjo=NOrq!iII;w<+rRx(*mrjCGM;{ z!2>C*jHscM!!!G)Kk$(Jz#_p5ROG?Jgt7*9HFS2b(+voa@$?0ko&m{7fF^Y=)rj8T z={oZ0qokkkqQG4Mkh;J|v7!_wlgdXa!^S!Pl6ns~MGLuB<<^*#Fhl(Ol7c)Ld}q@rd{==WLLa xf+qeN$c+5gqT7FQ&;O+qgXn&|A#to+4vWjodOC;(zcz9{}=09W4HhS literal 0 HcmV?d00001 diff --git a/MySensors.h b/MySensors.h index 36aee1702..64b7a45e0 100644 --- a/MySensors.h +++ b/MySensors.h @@ -70,6 +70,9 @@ #elif defined(ARDUINO_ARCH_STM32F1) #include "hal/architecture/STM32F1/MyHwSTM32F1.cpp" #include "hal/crypto/generic/MyCryptoGeneric.cpp" +#elif defined(ARDUINO_ARCH_STM32) +#include "hal/architecture/STM32/MyHwSTM32.cpp" +#include "hal/crypto/generic/MyCryptoGeneric.cpp" #elif defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_NRF52) #include "hal/architecture/NRF5/MyHwNRF5.cpp" #include "hal/crypto/generic/MyCryptoGeneric.cpp" @@ -321,7 +324,7 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs #define MY_RAM_ROUTING_TABLE_ENABLED #elif defined(MY_RAM_ROUTING_TABLE_FEATURE) && defined(MY_REPEATER_FEATURE) // activate feature based on architecture -#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(TEENSYDUINO) || defined(__linux__) +#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_ARCH_NRF5) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32) || defined(TEENSYDUINO) || defined(__linux__) #define MY_RAM_ROUTING_TABLE_ENABLED #elif defined(ARDUINO_ARCH_AVR) #if defined(__avr_atmega1280__) || defined(__avr_atmega1284__) || defined(__avr_atmega2560__) @@ -446,6 +449,8 @@ MY_DEFAULT_RX_LED_PIN in your sketch instead to enable LEDs #include "hal/architecture/Linux/MyMainLinuxGeneric.cpp" #elif defined(ARDUINO_ARCH_STM32F1) #include "hal/architecture/STM32F1/MyMainSTM32F1.cpp" +#elif defined(ARDUINO_ARCH_STM32) +#include "hal/architecture/STM32/MyMainSTM32.cpp" #elif defined(__arm__) && defined(TEENSYDUINO) #include "hal/architecture/Teensy3/MyMainTeensy3.cpp" #endif diff --git a/README.stm32duino.md b/README.stm32duino.md new file mode 100644 index 000000000..6316c9996 --- /dev/null +++ b/README.stm32duino.md @@ -0,0 +1,25 @@ +# MySensors Library readme for [stm32duino](https://github.com/stm32duino/Arduino_Core_STM32) + +## Why start this since there is STM32 support of [rogerclarkmelbourne/Arduino_STM32](https://github.com/rogerclarkmelbourne/Arduino_STM32) +- It lacks low power support, which is important for battery powered nodes. +- Rich features of STM32 are limited, such as STM32 has more interrupt than AVR. + +## Task status +- [x] STM32F1 basic support +- [ ] Low Power support +- [ ] Extra Interrupt support + +## Development Memo +Tested on: +- Hardware: STM32F103C8T6 Bluepill 128KB + - configuration + + configuration of stm32f1c8t6 bluepill + +- STM32 Cores by STMicroelectronics Version 1.9.0 + +# Thanks +- [#Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) for the rich support of STM32 series. +- [Arduino_STM32](https://github.com/rogerclarkmelbourne/Arduino_STM32) for the first STM32 support on STM32. +- [NodeManager](https://github.com/mysensors/NodeManager) for the fast development on mysensors gateways/nodes. +- [MySensors](https://github.com/mysensors/MySensors) for building the base. diff --git a/core/MyCapabilities.h b/core/MyCapabilities.h index 3beba0770..9e4e0ddab 100644 --- a/core/MyCapabilities.h +++ b/core/MyCapabilities.h @@ -166,7 +166,9 @@ #elif defined(ARDUINO_ARCH_AVR) #define MY_CAP_ARCH "A" #elif defined(ARDUINO_ARCH_STM32F1) -#define MY_CAP_ARCH "M" +#define MY_CAP_ARCH "F" +#elif defined(ARDUINO_ARCH_STM32) +#define MY_CAP_ARCH "f" #elif defined(__arm__) && defined(TEENSYDUINO) #define MY_CAP_ARCH "T" #elif defined(__linux__) diff --git a/examples/SecurityPersonalizer/SecurityPersonalizer.ino b/examples/SecurityPersonalizer/SecurityPersonalizer.ino index 70e754ef6..d6e595639 100644 --- a/examples/SecurityPersonalizer/SecurityPersonalizer.ino +++ b/examples/SecurityPersonalizer/SecurityPersonalizer.ino @@ -1349,6 +1349,8 @@ static void probe_and_print_peripherals(void) Serial.print(F("| SAMD | DETECTED | N/A | ")); #elif defined(ARDUINO_ARCH_STM32F1) Serial.print(F("| STM32F1 | DETECTED | N/A | ")); +#elif defined(ARDUINO_ARCH_STM32) + Serial.print(F("| STM32 | DETECTED | N/A | ")); #elif defined(__linux__) Serial.print(F("| Linux | DETECTED | N/A | ")); #else diff --git a/hal/architecture/STM32/MyHwSTM32.cpp b/hal/architecture/STM32/MyHwSTM32.cpp new file mode 100644 index 000000000..e4c834e4c --- /dev/null +++ b/hal/architecture/STM32/MyHwSTM32.cpp @@ -0,0 +1,184 @@ +/* + * The MySensors Arduino library handles the wireless radio link and protocol + * between your home built sensors/actuators and HA controller of choice. + * The sensors forms a self healing radio network with optional repeaters. Each + * repeater and gateway builds a routing tables in EEPROM which keeps track of + * the network topology allowing messages to be routed to nodes. + * + * Created by Henrik Ekblad + * Copyright (C) 2013-2019 Sensnology AB + * Full contributor list: + * https://github.com/mysensors/MySensors/graphs/contributors + * + * Documentation: http://www.mysensors.org + * Support Forum: http://forum.mysensors.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#include "MyHwSTM32.h" +#include "drivers/hal_conf_custom.h" +#include "drivers/stm32_ADC_internal_channels.h" + +/* + * Pinout STM32F103C8 dev board: + * http://wiki.stm32duino.com/images/a/ae/Bluepillpinout.gif + * + * Wiring RFM69 radio / SPI1 + * -------------------------------------------------- + * CLK PA5 + * MISO PA6 + * MOSI PA7 + * CSN PA4 + * CE NA + * IRQ PA3 (default) + * + * Wiring RF24 radio / SPI1 + * -------------------------------------------------- + * CLK PA5 + * MISO PA6 + * MOSI PA7 + * CSN PA4 + * CE PB0 (default) + * IRQ NA + * + */ +bool hwInit(void) { +#if !defined(MY_DISABLED_SERIAL) + MY_SERIALDEVICE.begin(MY_BAUD_RATE); +#if defined(MY_GATEWAY_SERIAL) + while (!MY_SERIALDEVICE) { + } +#endif +#endif + return true; + // return EEPROM.begin(); + + // if (EEPROM.init() == EEPROM_OK) { + // uint16 cnt; + // EEPROM.count(&cnt); + // if(cnt>=EEPROM.maxcount()) { + // // tmp, WIP: format eeprom if full + // EEPROM.format(); + // } + // return true; + // } + // return false; +} + +void hwReadConfigBlock(void *buf, void *addr, size_t length) { + uint8_t *dst = static_cast(buf); + int pos = reinterpret_cast(addr); + eeprom_buffer_fill(); + // return eeprom_buffered_read_byte(pos); + + // while (length-- > 0) { + // *dst++ = EEPROM.read(pos++); + // } + while (length-- > 0) { + *dst++ = eeprom_buffered_read_byte(pos++); + } +} + +void hwWriteConfigBlock(void *buf, void *addr, size_t length) { + uint8_t *src = static_cast(buf); + int pos = reinterpret_cast(addr); + // while (length-- > 0) { + // EEPROM.write(pos++, *src++); + // } + while (length-- > 0) { + // EEPROM.write(pos++, *src++); + eeprom_buffered_write_byte(pos++, *src++); + } + eeprom_buffer_flush(); +} + +// void hwReadConfigBlock(void *buf, void *addr, size_t length) { +// uint8_t *dst = static_cast(buf); +// int pos = reinterpret_cast(addr); +// while (length-- > 0) { +// *dst++ = EEPROM.read(pos++); +// } +// } + +// void hwWriteConfigBlock(void *buf, void *addr, size_t length) { +// uint8_t *src = static_cast(buf); +// int pos = reinterpret_cast(addr); +// while (length-- > 0) { +// EEPROM.write(pos++, *src++); +// } +// } + +// uint8_t hwReadConfig(const int addr) { +// uint8_t value; +// hwReadConfigBlock(&value, reinterpret_cast(addr), 1); +// return value; +// } + +// void hwWriteConfig(const int addr, uint8_t value) { +// hwWriteConfigBlock(&value, reinterpret_cast(addr), 1); +// } + +int8_t hwSleep(uint32_t ms) { + // TODO: Not supported! + (void)ms; + return MY_SLEEP_NOT_POSSIBLE; +} + +int8_t hwSleep(const uint8_t interrupt, const uint8_t mode, uint32_t ms) { + // TODO: Not supported! + (void)interrupt; + (void)mode; + (void)ms; + return MY_SLEEP_NOT_POSSIBLE; +} + +int8_t hwSleep(const uint8_t interrupt1, const uint8_t mode1, + const uint8_t interrupt2, const uint8_t mode2, uint32_t ms) { + // TODO: Not supported! + (void)interrupt1; + (void)mode1; + (void)interrupt2; + (void)mode2; + (void)ms; + return MY_SLEEP_NOT_POSSIBLE; +} + +void hwRandomNumberInit(void) { + // use internal temperature sensor as noise source + uint32_t seed = 0; + uint16_t currentValue = 0; + uint16_t newValue = 0; + + for (uint8_t i = 0; i < 32; i++) { + const uint32_t timeout = hwMillis() + 20; + while (timeout >= hwMillis()) { + newValue = analogRead(ATEMP); + if (newValue != currentValue) { + currentValue = newValue; + break; + } + } + seed ^= ((newValue + hwMillis()) & 7) << i; + } + randomSeed(seed); +} + +bool hwUniqueID(unique_id_t *uniqueID) { + (void)memcpy((uint8_t *)uniqueID, (uint32_t *)0x1FFFF7E0, + 16); // FlashID + ChipID + return true; +} + +uint16_t hwCPUVoltage(void) { return (uint16_t)readVref(); } + +uint16_t hwCPUFrequency(void) { return F_CPU / 100000UL; } + +int8_t hwCPUTemperature(void) { return (int8_t)readTempSensor(readVref()); } + +uint16_t hwFreeMem(void) { + // Not yet implemented + return FUNCTION_NOT_SUPPORTED; +} diff --git a/hal/architecture/STM32/MyHwSTM32.h b/hal/architecture/STM32/MyHwSTM32.h new file mode 100644 index 000000000..98c7c1c21 --- /dev/null +++ b/hal/architecture/STM32/MyHwSTM32.h @@ -0,0 +1,98 @@ +/* + * The MySensors Arduino library handles the wireless radio link and protocol + * between your home built sensors/actuators and HA controller of choice. + * The sensors forms a self healing radio network with optional repeaters. Each + * repeater and gateway builds a routing tables in EEPROM which keeps track of the + * network topology allowing messages to be routed to nodes. + * + * Created by Henrik Ekblad + * Copyright (C) 2013-2019 Sensnology AB + * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors + * + * Documentation: http://www.mysensors.org + * Support Forum: http://forum.mysensors.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#ifndef MyHwSTM32_h +#define MyHwSTM32_h + +// #include +#include +// #include +#include +#include +#include + +#ifdef __cplusplus +#include +#endif + +#define CRYPTO_LITTLE_ENDIAN + +#ifndef MY_SERIALDEVICE +#define MY_SERIALDEVICE Serial +#endif + +#ifndef MY_DEBUGDEVICE +#define MY_DEBUGDEVICE MY_SERIALDEVICE +#endif + +#ifndef MY_STM32F1_TEMPERATURE_OFFSET +#define MY_STM32F1_TEMPERATURE_OFFSET (0.0f) +#endif + +#ifndef MY_STM32F1_TEMPERATURE_GAIN +#define MY_STM32F1_TEMPERATURE_GAIN (1.0f) +#endif + +// SS default +#ifndef SS +#define SS PA4 +#endif + +// mapping +#define snprintf_P snprintf +#define vsnprintf_P vsnprintf +#define strncpy_P strncpy +#define printf_P printf +#define yield() // not defined + +#ifndef digitalPinToInterrupt +#define digitalPinToInterrupt(__pin) (__pin) +#endif + +#define hwDigitalWrite(__pin, __value) digitalWrite(__pin, __value) +#define hwDigitalRead(__pin) digitalRead(__pin) +#define hwPinMode(__pin, __value) pinMode(__pin, __value) +#define hwWatchdogReset() IWatchdog.reload() // iwdg_feed() +// #define hwReboot() nvic_sys_reset() +#define hwReboot() HAL_NVIC_SystemReset() +#define hwMillis() millis() +#define hwGetSleepRemaining() (0ul) + +extern void serialEventRun(void) __attribute__((weak)); +bool hwInit(void); +void hwRandomNumberInit(void); +void hwReadConfigBlock(void *buf, void *addr, size_t length); +void hwWriteConfigBlock(void *buf, void *addr, size_t length); +// void hwWriteConfig(const int addr, uint8_t value); +// uint8_t hwReadConfig(const int addr); +#define hwReadConfig(__pos) eeprom_read_byte((const uint32_t)__pos) +#define hwWriteConfig(__pos, __val) eeprom_write_byte((const uint32_t)__pos, (uint8_t)__val) + +// SOFTSPI +#ifdef MY_SOFTSPI +#error Soft SPI is not available on this architecture! +#endif +#define hwSPI SPI //!< hwSPI + + +#ifndef DOXYGEN +#define MY_CRITICAL_SECTION +#endif /* DOXYGEN */ + +#endif diff --git a/hal/architecture/STM32/MyMainSTM32.cpp b/hal/architecture/STM32/MyMainSTM32.cpp new file mode 100644 index 000000000..01283dde7 --- /dev/null +++ b/hal/architecture/STM32/MyMainSTM32.cpp @@ -0,0 +1,64 @@ +/* + * The MySensors Arduino library handles the wireless radio link and protocol + * between your home built sensors/actuators and HA controller of choice. + * The sensors forms a self healing radio network with optional repeaters. Each + * repeater and gateway builds a routing tables in EEPROM which keeps track of + * the network topology allowing messages to be routed to nodes. + * + * Created by Henrik Ekblad + * Copyright (C) 2013-2019 Sensnology AB + * Full contributor list: + * https://github.com/mysensors/MySensors/graphs/contributors + * + * Documentation: http://www.mysensors.org + * Support Forum: http://forum.mysensors.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +#define ARDUINO_MAIN +#include "Arduino.h" + +// Force init to be called *first*, i.e. before static object allocation. +// Otherwise, statically allocated objects that need HAL may fail. +__attribute__((constructor(101))) void premain() { + + // Required by FreeRTOS, see http://www.freertos.org/RTOS-Cortex-M3-M4.html +#ifdef NVIC_PRIORITYGROUP_4 + HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); +#endif +#if (__CORTEX_M == 0x07U) + // Defined in CMSIS core_cm7.h +#ifndef I_CACHE_DISABLED + SCB_EnableICache(); +#endif +#ifndef D_CACHE_DISABLED + SCB_EnableDCache(); +#endif +#endif + + init(); +} + +/* + * \brief Main entry point of Arduino application + */ +int main(void) { + initVariant(); + + // setup(); + _begin(); // Startup MySensors library + for (;;) { + _process(); // Process incoming data + if (loop) { // Call sketch loop + loop(); + } + if (serialEventRun) { + serialEventRun(); + } + } + + return 0; +} diff --git a/hal/architecture/STM32/drivers/hal_conf_custom.h b/hal/architecture/STM32/drivers/hal_conf_custom.h new file mode 100644 index 000000000..ab1535b07 --- /dev/null +++ b/hal/architecture/STM32/drivers/hal_conf_custom.h @@ -0,0 +1,66 @@ +/** + ****************************************************************************** + * @file stm32f1xx_hal_conf_default.h + * @brief HAL default configuration file. + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2017 STMicroelectronics. + * All rights reserved.

+ * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef _HAL_CONF_CUSTOM_H +#define _HAL_CONF_CUSTOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +// #define HAL_MODULE_ENABLED +// #define HAL_ADC_MODULE_ENABLED +// #define HAL_CAN_MODULE_ENABLED +/*#define HAL_CAN_LEGACY_MODULE_ENABLED*/ +// #define HAL_CEC_MODULE_ENABLED +// #define HAL_CORTEX_MODULE_ENABLED +// #define HAL_CRC_MODULE_ENABLED +// #define HAL_DAC_MODULE_ENABLED +// #define HAL_DMA_MODULE_ENABLED +// #define HAL_ETH_MODULE_ENABLED +// #define HAL_EXTI_MODULE_ENABLED +// #define HAL_FLASH_MODULE_ENABLED +// #define HAL_GPIO_MODULE_ENABLED +// #define HAL_HCD_MODULE_ENABLED +// #define HAL_I2C_MODULE_ENABLED +// #define HAL_I2S_MODULE_ENABLED +// #define HAL_IRDA_MODULE_ENABLED +// #define HAL_IWDG_MODULE_ENABLED +// #define HAL_NAND_MODULE_ENABLED +// #define HAL_NOR_MODULE_ENABLED +// #define HAL_PCCARD_MODULE_ENABLED +// #define HAL_PCD_MODULE_ENABLED +// #define HAL_PWR_MODULE_ENABLED +// #define HAL_RCC_MODULE_ENABLED +// #define HAL_RTC_MODULE_ENABLED +// #define HAL_SD_MODULE_ENABLED +// #define HAL_SMARTCARD_MODULE_ENABLED +// #define HAL_SPI_MODULE_ENABLED +// #define HAL_SRAM_MODULE_ENABLED +// #define HAL_TIM_MODULE_ENABLED +#define HAL_UART_MODULE_ENABLED +// #define HAL_USART_MODULE_ENABLED +// #define HAL_WWDG_MODULE_ENABLED +// #define HAL_MMC_MODULE_ENABLED + +#ifdef __cplusplus +} +#endif + +#endif /* _HAL_CONF_CUSTOM_H */ diff --git a/hal/architecture/STM32/drivers/stm32_ADC_internal_channels.h b/hal/architecture/STM32/drivers/stm32_ADC_internal_channels.h new file mode 100644 index 000000000..fd32c860b --- /dev/null +++ b/hal/architecture/STM32/drivers/stm32_ADC_internal_channels.h @@ -0,0 +1,95 @@ +/* +Examples: + +// the setup routine runs once when you press reset: +void setup() { + // initialize serial communication at 9600 bits per second: + Serial.begin(9600); + analogReadResolution(ADC_RESOLUTION); +} + +// the loop routine runs over and over again forever: +void loop() { + // print out the value you read: + Serial.print("VRef(mv)= "); + int32_t VRef = readVref(); + Serial.print(VRef); + +#ifdef ATEMP + Serial.print("\tTemp(°C)= "); + Serial.print(readTempSensor(VRef)); +#endif +#ifdef AVBAT + Serial.print("\tVbat(mv)= "); + Serial.print(readVoltage(VRef, AVBAT)); +#endif + + Serial.print("\tA0(mv)= "); + Serial.println(readVoltage(VRef, A0)); + delay(200); +} +*/ + +#ifndef _STM32_ADC_INTERNAL_CHANNELS_H_ +#define _STM32_ADC_INTERNAL_CHANNELS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "stm32yyxx_ll_adc.h" + +/* Values available in datasheet */ +#define CALX_TEMP 25 +#if defined(STM32F1xx) +#define V25 1430 +#define AVG_SLOPE 4300 +#define VREFINT 1200 +#elif defined(STM32F2xx) +#define V25 760 +#define AVG_SLOPE 2500 +#define VREFINT 1210 +#endif + +/* Analog read resolution */ +#if ADC_RESOLUTION == 10 +#define LL_ADC_RESOLUTION LL_ADC_RESOLUTION_10B +#define ADC_RANGE 1024 +#else +#define LL_ADC_RESOLUTION LL_ADC_RESOLUTION_12B +#define ADC_RANGE 4096 +#endif + +static int32_t readVref() { +#ifdef __LL_ADC_CALC_VREFANALOG_VOLTAGE + return ( + __LL_ADC_CALC_VREFANALOG_VOLTAGE(analogRead(AVREF), LL_ADC_RESOLUTION)); +#else + return (VREFINT * ADC_RANGE / analogRead(AVREF)); // ADC sample to mV +#endif +} + +#ifdef ATEMP +static int32_t readTempSensor(int32_t VRef) { +#ifdef __LL_ADC_CALC_TEMPERATURE + return ( + __LL_ADC_CALC_TEMPERATURE(VRef, analogRead(ATEMP), LL_ADC_RESOLUTION)); +#elif defined(__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS) + return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS( + AVG_SLOPE, V25, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION)); +#else + return 0; +#endif +} +#endif + +static int32_t readVoltage(int32_t VRef, uint32_t pin) { + return ( + __LL_ADC_CALC_DATA_TO_VOLTAGE(VRef, analogRead(pin), LL_ADC_RESOLUTION)); +} + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/hal/transport/RF24/driver/RF24.h b/hal/transport/RF24/driver/RF24.h index e578e6b9f..92f4462ff 100644 --- a/hal/transport/RF24/driver/RF24.h +++ b/hal/transport/RF24/driver/RF24.h @@ -78,6 +78,8 @@ //#define DEFAULT_RF24_CS_PIN (24) //!< DEFAULT_RF24_CS_PIN #elif defined(ARDUINO_ARCH_STM32F1) #define DEFAULT_RF24_CE_PIN (PB0) //!< DEFAULT_RF24_CE_PIN +#elif defined(ARDUINO_ARCH_STM32) +#define DEFAULT_RF24_CE_PIN (PB0) //!< DEFAULT_RF24_CE_PIN #elif defined(TEENSYDUINO) #define DEFAULT_RF24_CE_PIN (9) //!< DEFAULT_RF24_CE_PIN #else diff --git a/hal/transport/RFM69/driver/new/RFM69_new.h b/hal/transport/RFM69/driver/new/RFM69_new.h index 8e2613466..5c6506886 100644 --- a/hal/transport/RFM69/driver/new/RFM69_new.h +++ b/hal/transport/RFM69/driver/new/RFM69_new.h @@ -92,6 +92,8 @@ #define DEFAULT_RFM69_IRQ_PIN (22) //!< DEFAULT_RFM69_IRQ_PIN #elif defined(ARDUINO_ARCH_STM32F1) #define DEFAULT_RFM69_IRQ_PIN (PA3) //!< DEFAULT_RFM69_IRQ_PIN +#elif defined(ARDUINO_ARCH_STM32) +#define DEFAULT_RFM69_IRQ_PIN (PA3) //!< DEFAULT_RFM69_IRQ_PIN #elif defined(TEENSYDUINO) #define DEFAULT_RFM69_IRQ_PIN (8) //!< DEFAULT_RFM69_IRQ_PIN #else diff --git a/hal/transport/RFM69/driver/old/RFM69_old.h b/hal/transport/RFM69/driver/old/RFM69_old.h index 4b3f95245..ef37e88ba 100644 --- a/hal/transport/RFM69/driver/old/RFM69_old.h +++ b/hal/transport/RFM69/driver/old/RFM69_old.h @@ -59,6 +59,9 @@ #elif defined(ARDUINO_ARCH_STM32F1) #define DEFAULT_RFM69_IRQ_PIN (PA3) //!< DEFAULT_RFM69_IRQ_PIN #define DEFAULT_RFM69_IRQ_NUM DEFAULT_RFM69_IRQ_PIN //!< DEFAULT_RFM69_IRQ_NUM +#elif defined(ARDUINO_ARCH_STM32) +#define DEFAULT_RFM69_IRQ_PIN (PA3) //!< DEFAULT_RFM69_IRQ_PIN +#define DEFAULT_RFM69_IRQ_NUM DEFAULT_RFM69_IRQ_PIN //!< DEFAULT_RFM69_IRQ_NUM #elif defined(TEENSYDUINO) #define DEFAULT_RFM69_IRQ_PIN (8) //!< DEFAULT_RFM69_IRQ_PIN #define DEFAULT_RFM69_IRQ_NUM digitalPinToInterrupt(MY_RFM69_IRQ_PIN) //!< DEFAULT_RFM69_IRQ_NUM diff --git a/hal/transport/RFM95/driver/RFM95.h b/hal/transport/RFM95/driver/RFM95.h index f8159460c..b76aac5af 100644 --- a/hal/transport/RFM95/driver/RFM95.h +++ b/hal/transport/RFM95/driver/RFM95.h @@ -103,6 +103,8 @@ #define DEFAULT_RFM95_IRQ_PIN (22) //!< DEFAULT_RFM95_IRQ_PIN #elif defined(ARDUINO_ARCH_STM32F1) #define DEFAULT_RFM95_IRQ_PIN (PA3) //!< DEFAULT_RFM95_IRQ_PIN +#elif defined(ARDUINO_ARCH_STM32) +#define DEFAULT_RFM95_IRQ_PIN (PA3) //!< DEFAULT_RFM95_IRQ_PIN #elif defined(TEENSYDUINO) #define DEFAULT_RFM95_IRQ_PIN (8) //!< DEFAULT_RFM95_IRQ_PIN #else