From fe00b478bc808599d5eef301ba929ddabf67c1b8 Mon Sep 17 00:00:00 2001 From: jgillick Date: Thu, 26 Mar 2020 00:10:53 -0700 Subject: [PATCH 1/7] Add new Thunderpack board: STM32F411 --- boards.txt | 20 +- variants/THUNDERPACK_F411/PeripheralPins.c | 157 +++++++++++++++ variants/THUNDERPACK_F411/PinNamesVar.h | 31 +++ .../readme.txt => THUNDERPACK_F411/README.md} | 0 variants/THUNDERPACK_F411/ldscript.ld | 185 ++++++++++++++++++ variants/THUNDERPACK_F411/variant.cpp | 117 +++++++++++ variants/THUNDERPACK_F411/variant.h | 120 ++++++++++++ .../PeripheralPins.c | 0 .../PinNamesVar.h | 0 .../ldscript.ld | 0 variants/THUNDERPACK_L072/readme.txt | 4 + .../variant.cpp | 0 .../variant.h | 0 13 files changed, 628 insertions(+), 6 deletions(-) create mode 100644 variants/THUNDERPACK_F411/PeripheralPins.c create mode 100644 variants/THUNDERPACK_F411/PinNamesVar.h rename variants/{THUNDER_PACK/readme.txt => THUNDERPACK_F411/README.md} (100%) create mode 100644 variants/THUNDERPACK_F411/ldscript.ld create mode 100644 variants/THUNDERPACK_F411/variant.cpp create mode 100644 variants/THUNDERPACK_F411/variant.h rename variants/{THUNDER_PACK => THUNDERPACK_L072}/PeripheralPins.c (100%) rename variants/{THUNDER_PACK => THUNDERPACK_L072}/PinNamesVar.h (100%) rename variants/{THUNDER_PACK => THUNDERPACK_L072}/ldscript.ld (100%) create mode 100644 variants/THUNDERPACK_L072/readme.txt rename variants/{THUNDER_PACK => THUNDERPACK_L072}/variant.cpp (100%) rename variants/{THUNDER_PACK => THUNDERPACK_L072}/variant.h (100%) diff --git a/boards.txt b/boards.txt index 290aaae90e..f649354fd4 100644 --- a/boards.txt +++ b/boards.txt @@ -1128,6 +1128,14 @@ GenF4.menu.pnum.FEATHER_F405.build.board=FEATHER_F405 GenF4.menu.pnum.FEATHER_F405.build.product_line=STM32F405xx GenF4.menu.pnum.FEATHER_F405.build.variant=FEATHER_F405 +# ThunderPack F411xxE +GenF4.menu.pnum.THUNDERPACK_F411=ThunderPack v1.1+ +GenF4.menu.pnum.THUNDERPACK_F411.upload.maximum_size=524288 +GenF4.menu.pnum.THUNDERPACK_F411.upload.maximum_data_size=131072 +GenF4.menu.pnum.THUNDERPACK_F411.build.board=THUNDERPACK_F411 +GenF4.menu.pnum.THUNDERPACK_F411.build.product_line=STM32F411xE +GenF4.menu.pnum.THUNDERPACK_F411.build.variant=THUNDERPACK_F411 + # Generic F446RE GenF4.menu.pnum.Generic_F446RE=Generic F446RE GenF4.menu.pnum.Generic_F446RE.upload.maximum_size=524288 @@ -1438,12 +1446,12 @@ GenL0.build.series=STM32L0xx GenL0.build.cmsis_lib_gcc=arm_cortexM0l_math # ThunderPack -GenL0.menu.pnum.THUNDER_PACK=ThunderPack -GenL0.menu.pnum.THUNDER_PACK.upload.maximum_size=196608 -GenL0.menu.pnum.THUNDER_PACK.upload.maximum_data_size=20480 -GenL0.menu.pnum.THUNDER_PACK.build.board=THUNDER_PACK -GenL0.menu.pnum.THUNDER_PACK.build.product_line=STM32L072xx -GenL0.menu.pnum.THUNDER_PACK.build.variant=THUNDER_PACK +GenL0.menu.pnum.THUNDERPACK_L072=ThunderPack v1.0 +GenL0.menu.pnum.THUNDERPACK_L072.upload.maximum_size=196608 +GenL0.menu.pnum.THUNDERPACK_L072.upload.maximum_data_size=20480 +GenL0.menu.pnum.THUNDERPACK_L072.build.board=THUNDERPACK_L072 +GenL0.menu.pnum.THUNDERPACK_L072.build.product_line=STM32L072xx +GenL0.menu.pnum.THUNDERPACK_L072.build.variant=THUNDERPACK_L072 # Piconomix PX-HER0 board GenL0.menu.pnum.PX_HER0=PX-HER0 diff --git a/variants/THUNDERPACK_F411/PeripheralPins.c b/variants/THUNDERPACK_F411/PeripheralPins.c new file mode 100644 index 0000000000..b33c4c4049 --- /dev/null +++ b/variants/THUNDERPACK_F411/PeripheralPins.c @@ -0,0 +1,157 @@ +/* + ******************************************************************************* + * Copyright (c) 2019, 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 + * + ******************************************************************************* + * Automatically generated from STM32L072K(B-Z)Tx.xml + */ +#include "Arduino.h" +#include "PeripheralPins.h" + +/* ===== + * Note: Commented lines are alternative possibilities which are not used per default. + * If you change them, you will have to know what you do + * ===== + */ + +//*** ADC *** + +#ifdef HAL_ADC_MODULE_ENABLED +WEAK const PinMap PinMap_ADC[] = { + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC_IN7 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; + +WEAK const PinMap PinMap_I2C_SCL[] = { + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +WEAK const PinMap PinMap_PWM[] = { + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + // {PA_2, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 1, 0)}, // TIM21_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + // {PA_3, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 2, 0)}, // TIM21_CH2 + // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PA_6, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 1, 0)}, // TIM22_CH1 + {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + // {PA_7, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 2, 0)}, // TIM22_CH2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_TX[] = { + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RX[] = { + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_RTS[] = { + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +WEAK const PinMap PinMap_UART_CTS[] = { + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MOSI[] = { + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_10, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI5)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +WEAK const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, + {NC, NP, 0} +}; +#endif + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif + +//*** No USB_OTG_HS *** + +//*** No SD *** \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/PinNamesVar.h b/variants/THUNDERPACK_F411/PinNamesVar.h new file mode 100644 index 0000000000..bff3338fdc --- /dev/null +++ b/variants/THUNDERPACK_F411/PinNamesVar.h @@ -0,0 +1,31 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 +SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 +SYS_WKUP2 = NC, +#endif +#ifdef PWR_WAKEUP_PIN3 +SYS_WKUP3 = NC, +#endif +#ifdef PWR_WAKEUP_PIN4 +SYS_WKUP4 = NC, +#endif +#ifdef PWR_WAKEUP_PIN5 +SYS_WKUP5 = NC, +#endif +#ifdef PWR_WAKEUP_PIN6 +SYS_WKUP6 = NC, +#endif +#ifdef PWR_WAKEUP_PIN7 +SYS_WKUP7 = NC, +#endif +#ifdef PWR_WAKEUP_PIN8 +SYS_WKUP8 = NC, +#endif +/* USB */ +#ifdef USBCON +USB_DM = PA_11, +USB_DP = PA_12, +USB_NOE = PA_13, +#endif \ No newline at end of file diff --git a/variants/THUNDER_PACK/readme.txt b/variants/THUNDERPACK_F411/README.md similarity index 100% rename from variants/THUNDER_PACK/readme.txt rename to variants/THUNDERPACK_F411/README.md diff --git a/variants/THUNDERPACK_F411/ldscript.ld b/variants/THUNDERPACK_F411/ldscript.ld new file mode 100644 index 0000000000..d21c384b23 --- /dev/null +++ b/variants/THUNDERPACK_F411/ldscript.ld @@ -0,0 +1,185 @@ +/* +***************************************************************************** +** + +** File : LinkerScript.ld +** +** Abstract : Linker script for STM32F411Cx +** +** Set heap size, stack size and stack location according +** to application requirements. +** +** Set memory bank area and size if external memory is used. +** +** Target : STMicroelectronics STM32 +** +** +** Distribution: The file is distributed as is, without any warranty +** of any kind. +** +***************************************************************************** +** @attention +** +**

© COPYRIGHT(c) 2014 Ac6

+** +** Redistribution and use in source and binary forms, with or without modification, +** are permitted provided that the following conditions are met: +** 1. Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** 3. Neither the name of Ac6 nor the names of its contributors +** may be used to endorse or promote products derived from this software +** without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +** +***************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ +RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE +FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Define output sections */ +SECTIONS +{ + /* The startup code goes first into FLASH */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data goes into FLASH */ + .text ALIGN(4): + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data goes into FLASH */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH + .ARM : { + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + } >FLASH + + .preinit_array : + { + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + } >FLASH + .init_array : + { + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + } >FLASH + .fini_array : + { + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + } >FLASH + + /* used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections goes into RAM, load LMA copy after code */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + } >RAM AT> FLASH + + + /* Uninitialized data section */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss secion */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/variant.cpp b/variants/THUNDERPACK_F411/variant.cpp new file mode 100644 index 0000000000..2e1c0a2c91 --- /dev/null +++ b/variants/THUNDERPACK_F411/variant.cpp @@ -0,0 +1,117 @@ +/* + Copyright (c) 2011 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "pins_arduino.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 / A0 + PA_5, //D5 / A1 + PA_6, //D6 / A2 + PA_7, //D7 / A3 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PB_6, //D11 + PB_7, //D12 + PB_8, //D13 + PB_4, //D14 - User button + NC, //D15 + NC, //D16 + PA_11, //D17 - USB_D- + PA_12, //D18 - USB_D+ + PA_13, //D19 - SWD + PA_14, //D20 - SWD + + PH_0, // Digital pin 34, used by the external oscillator if present + PH_1 // Digital pin 35, used by the external oscillator if present +}; + +// Analog (Ax) pin number array +const uint32_t analogInputPin[] = { + 4, // A4, PA4 + 5, // A5, PA5 + 6, // A6, PA6 + 7, // A7, PA7 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * @brief Configures the System clock source, PLL Multiplier and Divider factors, + * AHB/APBx prescalers and Flash settings + * @note This function should be called only once the RCC clock configuration + * is reset to the default reset state (done in SystemInit() function). + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* The voltage scaling allows optimizing the power consumption when the device is + clocked below the maximum system frequency, to update the voltage scaling value + regarding system frequency refer to product datasheet. */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + // Enable HSE oscillator and activate PLL with HSE as source + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 24; + RCC_OscInitStruct.PLL.PLLN = 384; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 8; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } + + // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { + _Error_Handler(__FILE__, __LINE__); + } +} + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/variant.h b/variants/THUNDERPACK_F411/variant.h new file mode 100644 index 0000000000..3b0c7359ad --- /dev/null +++ b/variants/THUNDERPACK_F411/variant.h @@ -0,0 +1,120 @@ +/* + ******************************************************************************* + * Copyright (c) 2017, STMicroelectronics + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************* + */ + +#ifndef _VARIANT_ARDUINO_STM32_ +#define _VARIANT_ARDUINO_STM32_ + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ + +#define PA0 0 // LED 1 +#define PA1 1 // LED 2 +#define PA2 2 // LED 3 +#define PA3 3 // LED 4 +#define PA4 4 // A0 +#define PA5 5 // A1 +#define PA6 6 // A2 +#define PA7 7 // A3 +#define PA8 8 +#define PA9 9 +#define PA10 10 +#define PB6 11 // TX +#define PB7 12 // RX +#define PB8 13 +#define PB4 14 // User button + +#define PA11 17 // USB_D- +#define PA12 18 // USB_D+ +#define PA13 19 // SWD +#define PA14 20 // SWD + +// This must be a literal +#define NUM_DIGITAL_PINS 21 + +// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 4 +#define NUM_ANALOG_FIRST 4 + +// On-board LED pin number +#define LED_BUILTIN PA0 +#define LED_GREEN LED_BUILTIN +#define LED_1 PA0 +#define LED_2 PA1 +#define LED_3 PA2 +#define LED_4 PA3 + +// On-board user button +#define USER_BTN PB4 + +// Timer Definitions +#define TIMER_TONE TIM10 +#define TIMER_SERVO TIM11 + +// UART Definitions +#define SERIAL_UART_INSTANCE 1 //ex: 2 for Serial2 (USART2) + +// Default pin used for 'Serial' instance (ex: ST-Link) +// Mandatory for Firmata +#define PIN_SERIAL_RX PB7 +#define PIN_SERIAL_TX PB6 + +#ifdef __cplusplus +} // extern "C" +#endif +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#ifdef __cplusplus +// These serial port names are intended to allow libraries and architecture-neutral +// sketches to automatically default to the correct port name for a particular type +// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, +// the first hardware serial port whose RX/TX pins are not dedicated to another use. +// +// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor +// +// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial +// +// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library +// +// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. +// +// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX +// pins are NOT connected to anything by default. +#define SERIAL_PORT_MONITOR Serial +#define SERIAL_PORT_HARDWARE Serial +#endif + +#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/THUNDER_PACK/PeripheralPins.c b/variants/THUNDERPACK_L072/PeripheralPins.c similarity index 100% rename from variants/THUNDER_PACK/PeripheralPins.c rename to variants/THUNDERPACK_L072/PeripheralPins.c diff --git a/variants/THUNDER_PACK/PinNamesVar.h b/variants/THUNDERPACK_L072/PinNamesVar.h similarity index 100% rename from variants/THUNDER_PACK/PinNamesVar.h rename to variants/THUNDERPACK_L072/PinNamesVar.h diff --git a/variants/THUNDER_PACK/ldscript.ld b/variants/THUNDERPACK_L072/ldscript.ld similarity index 100% rename from variants/THUNDER_PACK/ldscript.ld rename to variants/THUNDERPACK_L072/ldscript.ld diff --git a/variants/THUNDERPACK_L072/readme.txt b/variants/THUNDERPACK_L072/readme.txt new file mode 100644 index 0000000000..a45af9d07d --- /dev/null +++ b/variants/THUNDERPACK_L072/readme.txt @@ -0,0 +1,4 @@ +# ThunderPack +A self-contained microcontroller, battery and power management system that fits in your pocket. + +More info: https://github.com/jgillick/ThunderPack \ No newline at end of file diff --git a/variants/THUNDER_PACK/variant.cpp b/variants/THUNDERPACK_L072/variant.cpp similarity index 100% rename from variants/THUNDER_PACK/variant.cpp rename to variants/THUNDERPACK_L072/variant.cpp diff --git a/variants/THUNDER_PACK/variant.h b/variants/THUNDERPACK_L072/variant.h similarity index 100% rename from variants/THUNDER_PACK/variant.h rename to variants/THUNDERPACK_L072/variant.h From 600ce0fda7db465bf8178c67b5cd6c95410a0be7 Mon Sep 17 00:00:00 2001 From: jgillick Date: Thu, 26 Mar 2020 01:05:35 -0700 Subject: [PATCH 2/7] PR feedback. --- CI/build/conf/cores_config.json | 8 +++++--- variants/THUNDERPACK_F411/variant.cpp | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CI/build/conf/cores_config.json b/CI/build/conf/cores_config.json index 8e152b82eb..cf2e815813 100644 --- a/CI/build/conf/cores_config.json +++ b/CI/build/conf/cores_config.json @@ -210,7 +210,8 @@ "RAK811_TRACKERA", "REMRAM_V1", "STEVAL_MKSBOX1V1", - "THUNDER_PACK", + "THUNDERPACK_F411", + "THUNDERPACK_L072", "Wraith32_V1" ] }, @@ -225,7 +226,8 @@ "RAK811_TRACKERA", "REMRAM_V1", "STEVAL_MKSBOX1V1", - "THUNDER_PACK" + "THUNDERPACK_F411", + "THUNDERPACK_L072" ] }, { @@ -277,7 +279,7 @@ "applicable": false, "boards": [ "GENERIC_F401RB", "GENERIC_F401RC", "GENERIC_F401RD", "GENERIC_F401RE", - "HY_TinySTM103TB", "THUNDER_PACK" + "HY_TinySTM103TB", "THUNDERPACK_F411", "THUNDERPACK_L072" ] }, { diff --git a/variants/THUNDERPACK_F411/variant.cpp b/variants/THUNDERPACK_F411/variant.cpp index 2e1c0a2c91..7ea64d83bb 100644 --- a/variants/THUNDERPACK_F411/variant.cpp +++ b/variants/THUNDERPACK_F411/variant.cpp @@ -101,8 +101,8 @@ WEAK void SystemClock_Config(void) } // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; From 6e0a6aa41cdba3ab2f425df9ac3939dcc608ddc3 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 26 Mar 2020 18:02:44 +0100 Subject: [PATCH 3/7] Remove useless analogInputPin[] array Since NUM_ANALOG_FIRST is defined and analog pins are contiguous Signed-off-by: Frederic Pillon --- variants/THUNDERPACK_F411/variant.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/variants/THUNDERPACK_F411/variant.cpp b/variants/THUNDERPACK_F411/variant.cpp index 7ea64d83bb..9a068ee223 100644 --- a/variants/THUNDERPACK_F411/variant.cpp +++ b/variants/THUNDERPACK_F411/variant.cpp @@ -50,14 +50,6 @@ const PinName digitalPin[] = { PH_1 // Digital pin 35, used by the external oscillator if present }; -// Analog (Ax) pin number array -const uint32_t analogInputPin[] = { - 4, // A4, PA4 - 5, // A5, PA5 - 6, // A6, PA6 - 7, // A7, PA7 -}; - #ifdef __cplusplus } #endif From 206858a3256996858682ae0cd2a4352a6037e55f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 26 Mar 2020 18:03:19 +0100 Subject: [PATCH 4/7] Set the readme as a markdown file Signed-off-by: Frederic Pillon --- variants/THUNDERPACK_L072/{readme.txt => README.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename variants/THUNDERPACK_L072/{readme.txt => README.md} (100%) diff --git a/variants/THUNDERPACK_L072/readme.txt b/variants/THUNDERPACK_L072/README.md similarity index 100% rename from variants/THUNDERPACK_L072/readme.txt rename to variants/THUNDERPACK_L072/README.md From 290d7dd437e3d19b9f40776222f86d8cff7a7023 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Fri, 27 Mar 2020 08:55:12 +0100 Subject: [PATCH 5/7] Merge ThunderPack variants in one Signed-off-by: Frederic Pillon --- README.md | 3 +- boards.txt | 4 +- .../PeripheralPins.c | 107 ++++++++-- .../PinNamesVar.h | 12 ++ .../README.md | 3 + variants/THUNDERPACK/ldscript.ld | 179 +++++++++++++++++ .../variant.cpp | 63 ++++-- .../variant.h | 14 +- variants/THUNDERPACK_F411/PeripheralPins.c | 157 --------------- variants/THUNDERPACK_F411/PinNamesVar.h | 31 --- variants/THUNDERPACK_F411/README.md | 4 - variants/THUNDERPACK_F411/ldscript.ld | 185 ----------------- variants/THUNDERPACK_F411/variant.cpp | 109 ---------- variants/THUNDERPACK_F411/variant.h | 120 ----------- variants/THUNDERPACK_L072/ldscript.ld | 189 ------------------ 15 files changed, 348 insertions(+), 832 deletions(-) rename variants/{THUNDERPACK_L072 => THUNDERPACK}/PeripheralPins.c (50%) rename variants/{THUNDERPACK_L072 => THUNDERPACK}/PinNamesVar.h (62%) rename variants/{THUNDERPACK_L072 => THUNDERPACK}/README.md (65%) create mode 100644 variants/THUNDERPACK/ldscript.ld rename variants/{THUNDERPACK_L072 => THUNDERPACK}/variant.cpp (69%) rename variants/{THUNDERPACK_L072 => THUNDERPACK}/variant.h (93%) delete mode 100644 variants/THUNDERPACK_F411/PeripheralPins.c delete mode 100644 variants/THUNDERPACK_F411/PinNamesVar.h delete mode 100644 variants/THUNDERPACK_F411/README.md delete mode 100644 variants/THUNDERPACK_F411/ldscript.ld delete mode 100644 variants/THUNDERPACK_F411/variant.cpp delete mode 100644 variants/THUNDERPACK_F411/variant.h delete mode 100644 variants/THUNDERPACK_L072/ldscript.ld diff --git a/README.md b/README.md index bd8e3858e1..02de4844ae 100644 --- a/README.md +++ b/README.md @@ -152,11 +152,12 @@ User can add a STM32 based board following this [wiki](https://github.com/stm32d | :yellow_heart: | Generic F423CH | **1.9.0** | | | :yellow_heart: | Generic F423RH | **1.9.0** | | | :yellow_heart: | Generic F446R(C-E) | **1.9.0** | | +| :yellow_heart: | [ThunderPack v1.1+](https://github.com/jgillick/ThunderPack) | **1.9.0** | Based on STM32F411CEUx | | Status | Generic STM32L0xx | Release | Comment | | :---: | --- | :---: | :--- | | :green_heart: | [PX-HER0](https://piconomix.com/fwlib/_p_i_c_o_n_o_m_i_x__s_t_m32__h_e_r_o__b_o_a_r_d.html) | *1.8.0* | | -| :green_heart: | [ThunderPack](https://github.com/jgillick/ThunderPack) | *1.8.0* | | +| :green_heart: | [ThunderPack v1.0](https://github.com/jgillick/ThunderPack) | *1.8.0* | Based on STM32L072KZTx | | Status | 3D printer boards | Release | Comment | | :---: | --- | :---: | :--- | diff --git a/boards.txt b/boards.txt index f649354fd4..6bab9a1a0c 100644 --- a/boards.txt +++ b/boards.txt @@ -1134,7 +1134,7 @@ GenF4.menu.pnum.THUNDERPACK_F411.upload.maximum_size=524288 GenF4.menu.pnum.THUNDERPACK_F411.upload.maximum_data_size=131072 GenF4.menu.pnum.THUNDERPACK_F411.build.board=THUNDERPACK_F411 GenF4.menu.pnum.THUNDERPACK_F411.build.product_line=STM32F411xE -GenF4.menu.pnum.THUNDERPACK_F411.build.variant=THUNDERPACK_F411 +GenF4.menu.pnum.THUNDERPACK_F411.build.variant=THUNDERPACK # Generic F446RE GenF4.menu.pnum.Generic_F446RE=Generic F446RE @@ -1451,7 +1451,7 @@ GenL0.menu.pnum.THUNDERPACK_L072.upload.maximum_size=196608 GenL0.menu.pnum.THUNDERPACK_L072.upload.maximum_data_size=20480 GenL0.menu.pnum.THUNDERPACK_L072.build.board=THUNDERPACK_L072 GenL0.menu.pnum.THUNDERPACK_L072.build.product_line=STM32L072xx -GenL0.menu.pnum.THUNDERPACK_L072.build.variant=THUNDERPACK_L072 +GenL0.menu.pnum.THUNDERPACK_L072.build.variant=THUNDERPACK # Piconomix PX-HER0 board GenL0.menu.pnum.PX_HER0=PX-HER0 diff --git a/variants/THUNDERPACK_L072/PeripheralPins.c b/variants/THUNDERPACK/PeripheralPins.c similarity index 50% rename from variants/THUNDERPACK_L072/PeripheralPins.c rename to variants/THUNDERPACK/PeripheralPins.c index fdfc6b0b2f..87163b6cae 100644 --- a/variants/THUNDERPACK_L072/PeripheralPins.c +++ b/variants/THUNDERPACK/PeripheralPins.c @@ -1,6 +1,6 @@ /* ******************************************************************************* - * Copyright (c) 2019, STMicroelectronics + * Copyright (c) 2020, STMicroelectronics * All rights reserved. * * This software component is licensed by ST under BSD 3-Clause license, @@ -9,7 +9,9 @@ * opensource.org/licenses/BSD-3-Clause * ******************************************************************************* - * Automatically generated from STM32L072K(B-Z)Tx.xml + * Automatically generated from STM32F411C(C-E)Ux.xml + * and merged manually with the STM32L072K(B-Z)Tx.xml + * to fit ThunderPack requirements */ #include "Arduino.h" #include "PeripheralPins.h" @@ -24,17 +26,17 @@ #ifdef HAL_ADC_MODULE_ENABLED WEAK const PinMap PinMap_ADC[] = { - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC_IN4 - {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC_IN5 - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC_IN6 - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC_IN7 + {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC1_IN4 + {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC1_IN5 + {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC1_IN6 + {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC1_IN7 {NC, NP, 0} }; #endif //*** DAC *** -#ifdef HAL_DAC_MODULE_ENABLED +#if defined(HAL_DAC_MODULE_ENABLED) && defined(ARDUINO_THUNDERPACK_L072) WEAK const PinMap PinMap_DAC[] = { {PA_4, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // DAC_OUT1 {PA_5, DAC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // DAC_OUT2 @@ -46,17 +48,26 @@ WEAK const PinMap PinMap_DAC[] = { #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SDA[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF1_I2C1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, +#endif {NC, NP, 0} }; #endif #ifdef HAL_I2C_MODULE_ENABLED WEAK const PinMap PinMap_I2C_SCL[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF7_I2C3)}, {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF6_I2C1)}, {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF1_I2C1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, +#endif {NC, NP, 0} }; #endif @@ -65,6 +76,7 @@ WEAK const PinMap PinMap_I2C_SCL[] = { #ifdef HAL_TIM_MODULE_ENABLED WEAK const PinMap PinMap_PWM[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 1, 0)}, // TIM2_CH1 {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 2, 0)}, // TIM2_CH2 {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM2, 3, 0)}, // TIM2_CH3 @@ -78,6 +90,26 @@ WEAK const PinMap PinMap_PWM[] = { // {PA_7, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 2, 0)}, // TIM22_CH2 {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM3, 2, 0)}, // TIM3_CH2 // {PB_5, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM22, 2, 0)}, // TIM22_CH2 +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 + {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 + // {PA_2, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 3, 0)}, // TIM5_CH3 + // {PA_2, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 1, 0)}, // TIM9_CH1 + {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 + // {PA_3, TIM5, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM5, 4, 0)}, // TIM5_CH4 + // {PA_3, TIM9, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_TIM9, 2, 0)}, // TIM9_CH2 + // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 + // {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 + {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 +#endif {NC, NP, 0} }; #endif @@ -86,19 +118,29 @@ WEAK const PinMap PinMap_PWM[] = { #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_TX[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, // {PA_14, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, {PA_14, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART2)}, {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, +#endif {NC, NP, 0} }; #endif #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_RX[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_USART1)}, {PA_13, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_LPUART1)}, {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, +#endif {NC, NP, 0} }; #endif @@ -111,8 +153,6 @@ WEAK const PinMap PinMap_UART_RTS[] = { #ifdef HAL_UART_MODULE_ENABLED WEAK const PinMap PinMap_UART_CTS[] = { - {PA_6, LPUART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_LPUART1)}, - {PB_7, USART4, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_USART4)}, {NC, NP, 0} }; #endif @@ -121,29 +161,49 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PA_10, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI5)}, + // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, +#endif {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MISO[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, +#endif {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SCLK[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, +#endif {NC, NP, 0} }; #endif #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_SSEL[] = { +#ifdef ARDUINO_THUNDERPACK_L072 {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, +#else /* ARDUINO_THUNDERPACK_F411 */ + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, + // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, +#endif {NC, NP, 0} }; #endif @@ -156,7 +216,7 @@ WEAK const PinMap PinMap_SPI_SSEL[] = { //*** USB *** -#ifdef HAL_PCD_MODULE_ENABLED +#if defined(HAL_PCD_MODULE_ENABLED) && defined(ARDUINO_THUNDERPACK_L072) WEAK const PinMap PinMap_USB[] = { {PA_11, USB, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DM {PA_12, USB, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF_NONE)}, // USB_DP @@ -165,8 +225,31 @@ WEAK const PinMap PinMap_USB[] = { }; #endif -//*** No USB_OTG_FS *** +#if defined(HAL_PCD_MODULE_ENABLED) && defined(ARDUINO_THUNDERPACK_F411) +WEAK const PinMap PinMap_USB_OTG_FS[] = { + {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM + {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP + {NC, NP, 0} +}; +#endif //*** No USB_OTG_HS *** -//*** No SD *** \ No newline at end of file +//*** SD *** + +#if defined(HAL_SD_MODULE_ENABLED) && defined(ARDUINO_THUNDERPACK_F411) +WEAK const PinMap PinMap_SD[] = { + {PA_6, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CMD + {PA_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D1 + {PA_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D2 + {PB_4, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PB_5, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D3 + {PB_7, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D0 + {PB_8, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D4 + {PB_9, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D5 + {PB_10, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D7 + {PB_14, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF12_SDIO)}, // SDIO_D6 + {PB_15, SDIO, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF12_SDIO)}, // SDIO_CK + {NC, NP, 0} +}; +#endif diff --git a/variants/THUNDERPACK_L072/PinNamesVar.h b/variants/THUNDERPACK/PinNamesVar.h similarity index 62% rename from variants/THUNDERPACK_L072/PinNamesVar.h rename to variants/THUNDERPACK/PinNamesVar.h index b030548b3f..f013c66a7c 100644 --- a/variants/THUNDERPACK_L072/PinNamesVar.h +++ b/variants/THUNDERPACK/PinNamesVar.h @@ -3,7 +3,11 @@ SYS_WKUP1 = PA_0, #endif #ifdef PWR_WAKEUP_PIN2 +#ifdef ARDUINO_THUNDERPACK_L072 SYS_WKUP2 = PC_13, +#else /* ARDUINO_THUNDERPACK_F411 */ +SYS_WKUP2 = NC, +#endif #endif #ifdef PWR_WAKEUP_PIN3 SYS_WKUP3 = NC, @@ -25,7 +29,15 @@ SYS_WKUP8 = NC, #endif /* USB */ #ifdef USBCON +#ifdef ARDUINO_THUNDERPACK_L072 USB_DM = PA_11, USB_DP = PA_12, USB_NOE = PA_13, +#else /* ARDUINO_THUNDERPACK_F411 */ +USB_OTG_FS_SOF = PA_8, +USB_OTG_FS_VBUS = PA_9, +USB_OTG_FS_ID = PA_10, +USB_OTG_FS_DM = PA_11, +USB_OTG_FS_DP = PA_12, +#endif #endif \ No newline at end of file diff --git a/variants/THUNDERPACK_L072/README.md b/variants/THUNDERPACK/README.md similarity index 65% rename from variants/THUNDERPACK_L072/README.md rename to variants/THUNDERPACK/README.md index a45af9d07d..33914051f0 100644 --- a/variants/THUNDERPACK_L072/README.md +++ b/variants/THUNDERPACK/README.md @@ -1,4 +1,7 @@ # ThunderPack A self-contained microcontroller, battery and power management system that fits in your pocket. +* ThunderPack v1.0 based on STM32L072KZTx +* ThunderPack v1.1+ based on STM32F411CEUx + More info: https://github.com/jgillick/ThunderPack \ No newline at end of file diff --git a/variants/THUNDERPACK/ldscript.ld b/variants/THUNDERPACK/ldscript.ld new file mode 100644 index 0000000000..cc0d1c092a --- /dev/null +++ b/variants/THUNDERPACK/ldscript.ld @@ -0,0 +1,179 @@ +/** + ****************************************************************************** + * @file LinkerScript.ld + * @author Auto-generated by STM32CubeIDE + * @brief Linker script for ThunderPack + * - STM32F411CEUx Device from STM32F4 series + * 512Kbytes FLASH + * 128Kbytes RAM + * - STM32L072KZTx Device from STM32L0 series + * 192Kbytes FLASH + * 20Kbytes RAM + * + * Set heap size, stack size and stack location according + * to application requirements. + * + * Set memory bank area and size if external memory is used + ****************************************************************************** + * @attention + * + *

© Copyright (c) 2020 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 + * + ****************************************************************************** + */ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = ORIGIN(RAM) + LENGTH(RAM); /* end of "RAM" Ram type memory */ + +_Min_Heap_Size = 0x200; /* required amount of heap */ +_Min_Stack_Size = 0x400; /* required amount of stack */ + +/* Memories definition */ +MEMORY +{ + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE + FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET +} + +/* Sections */ +SECTIONS +{ + /* The startup code into "FLASH" Rom type memory */ + .isr_vector : + { + . = ALIGN(4); + KEEP(*(.isr_vector)) /* Startup code */ + . = ALIGN(4); + } >FLASH + + /* The program code and other data into "FLASH" Rom type memory */ + .text : + { + . = ALIGN(4); + *(.text) /* .text sections (code) */ + *(.text*) /* .text* sections (code) */ + *(.glue_7) /* glue arm to thumb code */ + *(.glue_7t) /* glue thumb to arm code */ + *(.eh_frame) + + KEEP (*(.init)) + KEEP (*(.fini)) + + . = ALIGN(4); + _etext = .; /* define a global symbols at end of code */ + } >FLASH + + /* Constant data into "FLASH" Rom type memory */ + .rodata : + { + . = ALIGN(4); + *(.rodata) /* .rodata sections (constants, strings, etc.) */ + *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ + . = ALIGN(4); + } >FLASH + + .ARM.extab : { + . = ALIGN(4); + *(.ARM.extab* .gnu.linkonce.armextab.*) + . = ALIGN(4); + } >FLASH + + .ARM : { + . = ALIGN(4); + __exidx_start = .; + *(.ARM.exidx*) + __exidx_end = .; + . = ALIGN(4); + } >FLASH + + .preinit_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP (*(.preinit_array*)) + PROVIDE_HIDDEN (__preinit_array_end = .); + . = ALIGN(4); + } >FLASH + + .init_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__init_array_start = .); + KEEP (*(SORT(.init_array.*))) + KEEP (*(.init_array*)) + PROVIDE_HIDDEN (__init_array_end = .); + . = ALIGN(4); + } >FLASH + + .fini_array : + { + . = ALIGN(4); + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP (*(SORT(.fini_array.*))) + KEEP (*(.fini_array*)) + PROVIDE_HIDDEN (__fini_array_end = .); + . = ALIGN(4); + } >FLASH + + /* Used by the startup to initialize data */ + _sidata = LOADADDR(.data); + + /* Initialized data sections into "RAM" Ram type memory */ + .data : + { + . = ALIGN(4); + _sdata = .; /* create a global symbol at data start */ + *(.data) /* .data sections */ + *(.data*) /* .data* sections */ + + . = ALIGN(4); + _edata = .; /* define a global symbol at data end */ + + } >RAM AT> FLASH + + /* Uninitialized data section into "RAM" Ram type memory */ + . = ALIGN(4); + .bss : + { + /* This is used by the startup in order to initialize the .bss section */ + _sbss = .; /* define a global symbol at bss start */ + __bss_start__ = _sbss; + *(.bss) + *(.bss*) + *(COMMON) + + . = ALIGN(4); + _ebss = .; /* define a global symbol at bss end */ + __bss_end__ = _ebss; + } >RAM + + /* User_heap_stack section, used to check that there is enough "RAM" Ram type memory left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >RAM + + /* Remove information from the compiler libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/variants/THUNDERPACK_L072/variant.cpp b/variants/THUNDERPACK/variant.cpp similarity index 69% rename from variants/THUNDERPACK_L072/variant.cpp rename to variants/THUNDERPACK/variant.cpp index 154d046cac..62603d45cf 100644 --- a/variants/THUNDERPACK_L072/variant.cpp +++ b/variants/THUNDERPACK/variant.cpp @@ -69,22 +69,22 @@ const PinName digitalPin[] = { extern "C" { #endif -/** - * @brief System Clock Configuration - * @param None - * @retval None - */ +/* + * @brief System Clock Configuration + * @param None + * @retval None + */ WEAK void SystemClock_Config(void) { RCC_OscInitTypeDef RCC_OscInitStruct = {}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; + +#ifdef ARDUINO_THUNDERPACK_L072 RCC_PeriphCLKInitTypeDef PeriphClkInit = {}; - /** Configure the main internal regulator output voltage - */ + /* Configure the main internal regulator output voltage */ __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Initializes the CPU, AHB and APB busses clocks - */ + /* Initializes the CPU, AHB and APB busses clocks */ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; @@ -94,10 +94,9 @@ WEAK void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4; RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2; if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - _Error_Handler(__FILE__, __LINE__); + Error_Handler(); } - /** Initializes the CPU, AHB and APB busses clocks - */ + /* Initializes the CPU, AHB and APB busses clocks */ RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; @@ -106,18 +105,44 @@ WEAK void SystemClock_Config(void) RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { - _Error_Handler(__FILE__, __LINE__); + Error_Handler(); } - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 - | RCC_PERIPHCLK_USB; - PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; - PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { - _Error_Handler(__FILE__, __LINE__); + Error_Handler(); } +#else /* ARDUINO_THUNDERPACK_F411 */ + /* Configure the main internal regulator output voltage */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /* Initializes the CPU, AHB and APB busses clocks */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 24; + RCC_OscInitStruct.PLL.PLLN = 384; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; + RCC_OscInitStruct.PLL.PLLQ = 8; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { + Error_Handler(); + } + /* Initializes the CPU, AHB and APB busses clocks */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK + | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { + Error_Handler(); + } +#endif } #ifdef __cplusplus } -#endif +#endif \ No newline at end of file diff --git a/variants/THUNDERPACK_L072/variant.h b/variants/THUNDERPACK/variant.h similarity index 93% rename from variants/THUNDERPACK_L072/variant.h rename to variants/THUNDERPACK/variant.h index f07a1a0f83..df0fd3ae0f 100644 --- a/variants/THUNDERPACK_L072/variant.h +++ b/variants/THUNDERPACK/variant.h @@ -79,20 +79,28 @@ extern "C" { #define USER_BTN PB4 // Timer Definitions -// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#ifdef ARDUINO_THUNDERPACK_L072 #define TIMER_TONE TIM6 #define TIMER_SERVO TIM7 +#else /* ARDUINO_THUNDERPACK_F411 */ +#define TIMER_TONE TIM10 +#define TIMER_SERVO TIM11 +#endif // UART Definitions -#define SERIAL_UART_INSTANCE 1 //ex: 2 for Serial2 (USART2) +#define SERIAL_UART_INSTANCE 1 -// Default pin used for 'Serial' instance (ex: ST-Link) +// Default pin used for 'Serial' instance // Mandatory for Firmata #define PIN_SERIAL_RX PB7 #define PIN_SERIAL_TX PB6 +#ifdef ARDUINO_THUNDERPACK_L072 /* Extra HAL modules */ #define HAL_DAC_MODULE_ENABLED +#else +#define HSE_VALUE 24000000U +#endif #ifdef __cplusplus } // extern "C" diff --git a/variants/THUNDERPACK_F411/PeripheralPins.c b/variants/THUNDERPACK_F411/PeripheralPins.c deleted file mode 100644 index b33c4c4049..0000000000 --- a/variants/THUNDERPACK_F411/PeripheralPins.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2019, 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 - * - ******************************************************************************* - * Automatically generated from STM32L072K(B-Z)Tx.xml - */ -#include "Arduino.h" -#include "PeripheralPins.h" - -/* ===== - * Note: Commented lines are alternative possibilities which are not used per default. - * If you change them, you will have to know what you do - * ===== - */ - -//*** ADC *** - -#ifdef HAL_ADC_MODULE_ENABLED -WEAK const PinMap PinMap_ADC[] = { - {PA_4, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 4, 0)}, // ADC_IN4 - {PA_5, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 5, 0)}, // ADC_IN5 - {PA_6, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 6, 0)}, // ADC_IN6 - {PA_7, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 7, 0)}, // ADC_IN7 - {NC, NP, 0} -}; -#endif - -//*** I2C *** - -#ifdef HAL_I2C_MODULE_ENABLED -WEAK const PinMap PinMap_I2C_SDA[] = { - {PB_7, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - {NC, NP, 0} -}; - -WEAK const PinMap PinMap_I2C_SCL[] = { - {PA_8, I2C3, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C3)}, - {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, - {NC, NP, 0} -}; -#endif - -//*** PWM *** - -#ifdef HAL_TIM_MODULE_ENABLED -WEAK const PinMap PinMap_PWM[] = { - {PA_0, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 1, 0)}, // TIM2_CH1 - {PA_1, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 2, 0)}, // TIM2_CH2 - {PA_2, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 3, 0)}, // TIM2_CH3 - // {PA_2, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 1, 0)}, // TIM21_CH1 - {PA_3, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM2, 4, 0)}, // TIM2_CH4 - // {PA_3, TIM21, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM21, 2, 0)}, // TIM21_CH2 - // {PA_5, TIM2, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM2, 1, 0)}, // TIM2_CH1 - {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 1, 0)}, // TIM3_CH1 - // {PA_6, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 1, 0)}, // TIM22_CH1 - {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - // {PA_7, TIM22, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM22, 2, 0)}, // TIM22_CH2 - {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 1, 0)}, // TIM1_CH1 - {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 2, 0)}, // TIM1_CH2 - {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM1, 3, 0)}, // TIM1_CH3 - {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM3, 2, 0)}, // TIM3_CH2 - {PB_6, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 1, 0)}, // TIM4_CH1 - {PB_7, TIM4, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM4, 2, 0)}, // TIM4_CH2 - {NC, NP, 0} -}; -#endif - -//*** SERIAL *** - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_TX[] = { - {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {NC, NP, 0} -}; -#endif - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_RX[] = { - {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)}, - {NC, NP, 0} -}; -#endif - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_RTS[] = { - {NC, NP, 0} -}; -#endif - -#ifdef HAL_UART_MODULE_ENABLED -WEAK const PinMap PinMap_UART_CTS[] = { - {NC, NP, 0} -}; -#endif - -//*** SPI *** - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_MOSI[] = { - {PA_7, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {PA_10, SPI5, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI5)}, - // {PB_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {PB_5, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {NC, NP, 0} -}; -#endif - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_MISO[] = { - {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {NC, NP, 0} -}; -#endif - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_SCLK[] = { - {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - {NC, NP, 0} -}; -#endif - -#ifdef HAL_SPI_MODULE_ENABLED -WEAK const PinMap PinMap_SPI_SSEL[] = { - {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_SPI1)}, - // {PA_4, SPI3, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF6_SPI3)}, - {NC, NP, 0} -}; -#endif - -//*** No CAN *** - -//*** No ETHERNET *** - -//*** No QUADSPI *** - -//*** USB *** - -#ifdef HAL_PCD_MODULE_ENABLED -WEAK const PinMap PinMap_USB_OTG_FS[] = { - {PA_11, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DM - {PA_12, USB_OTG_FS, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_OTG_FS)}, // USB_OTG_FS_DP - {NC, NP, 0} -}; -#endif - -//*** No USB_OTG_HS *** - -//*** No SD *** \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/PinNamesVar.h b/variants/THUNDERPACK_F411/PinNamesVar.h deleted file mode 100644 index bff3338fdc..0000000000 --- a/variants/THUNDERPACK_F411/PinNamesVar.h +++ /dev/null @@ -1,31 +0,0 @@ -/* SYS_WKUP */ -#ifdef PWR_WAKEUP_PIN1 -SYS_WKUP1 = PA_0, -#endif -#ifdef PWR_WAKEUP_PIN2 -SYS_WKUP2 = NC, -#endif -#ifdef PWR_WAKEUP_PIN3 -SYS_WKUP3 = NC, -#endif -#ifdef PWR_WAKEUP_PIN4 -SYS_WKUP4 = NC, -#endif -#ifdef PWR_WAKEUP_PIN5 -SYS_WKUP5 = NC, -#endif -#ifdef PWR_WAKEUP_PIN6 -SYS_WKUP6 = NC, -#endif -#ifdef PWR_WAKEUP_PIN7 -SYS_WKUP7 = NC, -#endif -#ifdef PWR_WAKEUP_PIN8 -SYS_WKUP8 = NC, -#endif -/* USB */ -#ifdef USBCON -USB_DM = PA_11, -USB_DP = PA_12, -USB_NOE = PA_13, -#endif \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/README.md b/variants/THUNDERPACK_F411/README.md deleted file mode 100644 index a45af9d07d..0000000000 --- a/variants/THUNDERPACK_F411/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# ThunderPack -A self-contained microcontroller, battery and power management system that fits in your pocket. - -More info: https://github.com/jgillick/ThunderPack \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/ldscript.ld b/variants/THUNDERPACK_F411/ldscript.ld deleted file mode 100644 index d21c384b23..0000000000 --- a/variants/THUNDERPACK_F411/ldscript.ld +++ /dev/null @@ -1,185 +0,0 @@ -/* -***************************************************************************** -** - -** File : LinkerScript.ld -** -** Abstract : Linker script for STM32F411Cx -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** -** Distribution: The file is distributed as is, without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2014 Ac6

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of Ac6 nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20000000 + LD_MAX_DATA_SIZE; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = LD_MAX_DATA_SIZE -FLASH (rx) : ORIGIN = 0x8000000 + LD_FLASH_OFFSET, LENGTH = LD_MAX_SIZE - LD_FLASH_OFFSET -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text ALIGN(4): - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/variant.cpp b/variants/THUNDERPACK_F411/variant.cpp deleted file mode 100644 index 9a068ee223..0000000000 --- a/variants/THUNDERPACK_F411/variant.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (c) 2011 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "pins_arduino.h" - -#ifdef __cplusplus -extern "C" { -#endif - -// Pin number -const PinName digitalPin[] = { - PA_0, //D0 - PA_1, //D1 - PA_2, //D2 - PA_3, //D3 - PA_4, //D4 / A0 - PA_5, //D5 / A1 - PA_6, //D6 / A2 - PA_7, //D7 / A3 - PA_8, //D8 - PA_9, //D9 - PA_10, //D10 - PB_6, //D11 - PB_7, //D12 - PB_8, //D13 - PB_4, //D14 - User button - NC, //D15 - NC, //D16 - PA_11, //D17 - USB_D- - PA_12, //D18 - USB_D+ - PA_13, //D19 - SWD - PA_14, //D20 - SWD - - PH_0, // Digital pin 34, used by the external oscillator if present - PH_1 // Digital pin 35, used by the external oscillator if present -}; - -#ifdef __cplusplus -} -#endif - -// ---------------------------------------------------------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * @brief Configures the System clock source, PLL Multiplier and Divider factors, - * AHB/APBx prescalers and Flash settings - * @note This function should be called only once the RCC clock configuration - * is reset to the default reset state (done in SystemInit() function). - * @param None - * @retval None - */ -WEAK void SystemClock_Config(void) -{ - RCC_OscInitTypeDef RCC_OscInitStruct; - RCC_ClkInitTypeDef RCC_ClkInitStruct; - - /* The voltage scaling allows optimizing the power consumption when the device is - clocked below the maximum system frequency, to update the voltage scaling value - regarding system frequency refer to product datasheet. */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - - // Enable HSE oscillator and activate PLL with HSE as source - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 24; - RCC_OscInitStruct.PLL.PLLN = 384; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4; - RCC_OscInitStruct.PLL.PLLQ = 8; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - _Error_Handler(__FILE__, __LINE__); - } - - // Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2 clocks dividers - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK - | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK) { - _Error_Handler(__FILE__, __LINE__); - } -} - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/variants/THUNDERPACK_F411/variant.h b/variants/THUNDERPACK_F411/variant.h deleted file mode 100644 index 3b0c7359ad..0000000000 --- a/variants/THUNDERPACK_F411/variant.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - ******************************************************************************* - * Copyright (c) 2017, STMicroelectronics - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ******************************************************************************* - */ - -#ifndef _VARIANT_ARDUINO_STM32_ -#define _VARIANT_ARDUINO_STM32_ - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -/*---------------------------------------------------------------------------- - * Pins - *----------------------------------------------------------------------------*/ - -#define PA0 0 // LED 1 -#define PA1 1 // LED 2 -#define PA2 2 // LED 3 -#define PA3 3 // LED 4 -#define PA4 4 // A0 -#define PA5 5 // A1 -#define PA6 6 // A2 -#define PA7 7 // A3 -#define PA8 8 -#define PA9 9 -#define PA10 10 -#define PB6 11 // TX -#define PB7 12 // RX -#define PB8 13 -#define PB4 14 // User button - -#define PA11 17 // USB_D- -#define PA12 18 // USB_D+ -#define PA13 19 // SWD -#define PA14 20 // SWD - -// This must be a literal -#define NUM_DIGITAL_PINS 21 - -// This must be a literal with a value less than or equal to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 4 -#define NUM_ANALOG_FIRST 4 - -// On-board LED pin number -#define LED_BUILTIN PA0 -#define LED_GREEN LED_BUILTIN -#define LED_1 PA0 -#define LED_2 PA1 -#define LED_3 PA2 -#define LED_4 PA3 - -// On-board user button -#define USER_BTN PB4 - -// Timer Definitions -#define TIMER_TONE TIM10 -#define TIMER_SERVO TIM11 - -// UART Definitions -#define SERIAL_UART_INSTANCE 1 //ex: 2 for Serial2 (USART2) - -// Default pin used for 'Serial' instance (ex: ST-Link) -// Mandatory for Firmata -#define PIN_SERIAL_RX PB7 -#define PIN_SERIAL_TX PB6 - -#ifdef __cplusplus -} // extern "C" -#endif -/*---------------------------------------------------------------------------- - * Arduino objects - C++ only - *----------------------------------------------------------------------------*/ - -#ifdef __cplusplus -// These serial port names are intended to allow libraries and architecture-neutral -// sketches to automatically default to the correct port name for a particular type -// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, -// the first hardware serial port whose RX/TX pins are not dedicated to another use. -// -// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor -// -// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial -// -// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library -// -// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. -// -// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX -// pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_HARDWARE Serial -#endif - -#endif /* _VARIANT_ARDUINO_STM32_ */ diff --git a/variants/THUNDERPACK_L072/ldscript.ld b/variants/THUNDERPACK_L072/ldscript.ld deleted file mode 100644 index af2c4cc1bc..0000000000 --- a/variants/THUNDERPACK_L072/ldscript.ld +++ /dev/null @@ -1,189 +0,0 @@ -/* -****************************************************************************** -** - -** File : LinkerScript.ld -** -** Author : Auto-generated by Ac6 System Workbench -** -** Abstract : Linker script for STM32L072KZTx series -** 192Kbytes FLASH and 20Kbytes RAM -** -** Set heap size, stack size and stack location according -** to application requirements. -** -** Set memory bank area and size if external memory is used. -** -** Target : STMicroelectronics STM32 -** -** Distribution: The file is distributed “as is,” without any warranty -** of any kind. -** -***************************************************************************** -** @attention -** -**

© COPYRIGHT(c) 2014 Ac6

-** -** Redistribution and use in source and binary forms, with or without modification, -** are permitted provided that the following conditions are met: -** 1. Redistributions of source code must retain the above copyright notice, -** this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright notice, -** this list of conditions and the following disclaimer in the documentation -** and/or other materials provided with the distribution. -** 3. Neither the name of Ac6 nor the names of its contributors -** may be used to endorse or promote products derived from this software -** without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -** SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -** CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -** OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -** -***************************************************************************** -*/ - -/* Entry Point */ -ENTRY(Reset_Handler) - -/* Highest address of the user mode stack */ -_estack = 0x20005000; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0x200; /* required amount of heap */ -_Min_Stack_Size = 0x400; /* required amount of stack */ - -/* Specify the memory areas */ -MEMORY -{ -RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K -FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 192K -} - -/* Define output sections */ -SECTIONS -{ - /* The startup code goes first into FLASH */ - .isr_vector : - { - . = ALIGN(4); - KEEP(*(.isr_vector)) /* Startup code */ - . = ALIGN(4); - } >FLASH - - /* The program code and other data goes into FLASH */ - .text : - { - . = ALIGN(4); - *(.text) /* .text sections (code) */ - *(.text*) /* .text* sections (code) */ - *(.glue_7) /* glue arm to thumb code */ - *(.glue_7t) /* glue thumb to arm code */ - *(.eh_frame) - - KEEP (*(.init)) - KEEP (*(.fini)) - - . = ALIGN(4); - _etext = .; /* define a global symbols at end of code */ - } >FLASH - - /* Constant data goes into FLASH */ - .rodata : - { - . = ALIGN(4); - *(.rodata) /* .rodata sections (constants, strings, etc.) */ - *(.rodata*) /* .rodata* sections (constants, strings, etc.) */ - . = ALIGN(4); - } >FLASH - - .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH - .ARM : { - __exidx_start = .; - *(.ARM.exidx*) - __exidx_end = .; - } >FLASH - - .preinit_array : - { - PROVIDE_HIDDEN (__preinit_array_start = .); - KEEP (*(.preinit_array*)) - PROVIDE_HIDDEN (__preinit_array_end = .); - } >FLASH - .init_array : - { - PROVIDE_HIDDEN (__init_array_start = .); - KEEP (*(SORT(.init_array.*))) - KEEP (*(.init_array*)) - PROVIDE_HIDDEN (__init_array_end = .); - } >FLASH - .fini_array : - { - PROVIDE_HIDDEN (__fini_array_start = .); - KEEP (*(SORT(.fini_array.*))) - KEEP (*(.fini_array*)) - PROVIDE_HIDDEN (__fini_array_end = .); - } >FLASH - - /* used by the startup to initialize data */ - _sidata = LOADADDR(.data); - - /* Initialized data sections goes into RAM, load LMA copy after code */ - .data : - { - . = ALIGN(4); - _sdata = .; /* create a global symbol at data start */ - *(.data) /* .data sections */ - *(.data*) /* .data* sections */ - - . = ALIGN(4); - _edata = .; /* define a global symbol at data end */ - } >RAM AT> FLASH - - - /* Uninitialized data section */ - . = ALIGN(4); - .bss : - { - /* This is used by the startup in order to initialize the .bss secion */ - _sbss = .; /* define a global symbol at bss start */ - __bss_start__ = _sbss; - *(.bss) - *(.bss*) - *(COMMON) - - . = ALIGN(4); - _ebss = .; /* define a global symbol at bss end */ - __bss_end__ = _ebss; - } >RAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >RAM - - - - /* Remove information from the standard libraries */ - /DISCARD/ : - { - libc.a ( * ) - libm.a ( * ) - libgcc.a ( * ) - } - - .ARM.attributes 0 : { *(.ARM.attributes) } -} - - From 12f3360256a20c2bc56cda625ad863b4e55f0ecf Mon Sep 17 00:00:00 2001 From: jgillick Date: Sat, 28 Mar 2020 00:45:20 -0700 Subject: [PATCH 6/7] Remove unused value. --- variants/THUNDERPACK/variant.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/variants/THUNDERPACK/variant.h b/variants/THUNDERPACK/variant.h index df0fd3ae0f..287be53565 100644 --- a/variants/THUNDERPACK/variant.h +++ b/variants/THUNDERPACK/variant.h @@ -98,8 +98,6 @@ extern "C" { #ifdef ARDUINO_THUNDERPACK_L072 /* Extra HAL modules */ #define HAL_DAC_MODULE_ENABLED -#else -#define HSE_VALUE 24000000U #endif #ifdef __cplusplus From 0d9ad9f862bf71d20b37096caa398ee73eb8c080 Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 30 Mar 2020 00:22:21 -0700 Subject: [PATCH 7/7] Revert "Remove unused value." This reverts commit 12f3360256a20c2bc56cda625ad863b4e55f0ecf. --- variants/THUNDERPACK/variant.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/variants/THUNDERPACK/variant.h b/variants/THUNDERPACK/variant.h index 287be53565..df0fd3ae0f 100644 --- a/variants/THUNDERPACK/variant.h +++ b/variants/THUNDERPACK/variant.h @@ -98,6 +98,8 @@ extern "C" { #ifdef ARDUINO_THUNDERPACK_L072 /* Extra HAL modules */ #define HAL_DAC_MODULE_ENABLED +#else +#define HSE_VALUE 24000000U #endif #ifdef __cplusplus