From 40de708552eb0746d46f03c52c85266d27670504 Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 9 Sep 2019 00:48:16 -0700 Subject: [PATCH 01/11] Added ThunderPack board (STM32L0xx) - Add dfu-util as a upload option to platform.txt. - https://github.com/jgillick/ThunderPack --- boards.txt | 32 +++++ platform.txt | 11 ++ variants/THUNDER_PACK/PeripheralPins.c | 168 ++++++++++++++++++++++ variants/THUNDER_PACK/PinNamesVar.h | 31 ++++ variants/THUNDER_PACK/ldscript.ld | 189 +++++++++++++++++++++++++ variants/THUNDER_PACK/readme.txt | 4 + variants/THUNDER_PACK/variant.cpp | 126 +++++++++++++++++ variants/THUNDER_PACK/variant.h | 124 ++++++++++++++++ 8 files changed, 685 insertions(+) create mode 100644 variants/THUNDER_PACK/PeripheralPins.c create mode 100644 variants/THUNDER_PACK/PinNamesVar.h create mode 100644 variants/THUNDER_PACK/ldscript.ld create mode 100644 variants/THUNDER_PACK/readme.txt create mode 100644 variants/THUNDER_PACK/variant.cpp create mode 100644 variants/THUNDER_PACK/variant.h diff --git a/boards.txt b/boards.txt index ac54023acf..240563fcdf 100644 --- a/boards.txt +++ b/boards.txt @@ -1991,3 +1991,35 @@ Midatronics.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf Midatronics.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float Midatronics.menu.rtlib.full=Newlib Standard Midatronics.menu.rtlib.full.build.flags.ldspecs= + +############################### +# ThunderPack +ThunderPack.name=ThunderPack +ThunderPack.build.core=arduino +ThunderPack.build.product_line=STM32L072xx +ThunderPack.build.board=ThunderPack +ThunderPack.build.variant=THUNDER_PACK +ThunderPack.build.mcu=cortex-m0plus +ThunderPack.build.series=STM32L0xx +ThunderPack.build.cmsis_lib_gcc=arm_cortexM0l_math +ThunderPack.build.vid=0x0483 +ThunderPack.build.extra_flags={build.usb_flags} -DUSBD_USE_CDC -D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 + +ThunderPack.upload.maximum_size=196608 +ThunderPack.upload.maximum_data_size=20480 + +ThunderPack.menu.upload_method.dfuUtil=DFU Util +ThunderPack.menu.upload_method.dfuUtil.upload.tool=dfu_util +ThunderPack.menu.upload_method.dfuUtil.upload.protocol= +ThunderPack.menu.upload_method.dfuUtil.upload.usbID=0483:df11 +ThunderPack.menu.upload_method.dfuUtil.upload.address=0x08000000:leave + +ThunderPack.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD) +ThunderPack.menu.upload_method.swdMethod.upload.protocol=0 +ThunderPack.menu.upload_method.swdMethod.upload.options=-g +ThunderPack.menu.upload_method.swdMethod.upload.tool=stm32CubeProg + +ThunderPack.menu.upload_method.dfuMethod=STM32CubeProgrammer (DFU) +ThunderPack.menu.upload_method.dfuMethod.upload.protocol=2 +ThunderPack.menu.upload_method.dfuMethod.upload.options=-g +ThunderPack.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg \ No newline at end of file diff --git a/platform.txt b/platform.txt index 389b304bc5..927b53bd9b 100644 --- a/platform.txt +++ b/platform.txt @@ -200,3 +200,14 @@ tools.maple_upload.path.linux={runtime.tools.STM32Tools.path}/tools/linux tools.maple_upload.upload.params.verbose=-d tools.maple_upload.upload.params.quiet=n tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" + +# Upload using dfu-util +tools.dfu_util.cmd=dfu-util +tools.dfu_util.cmd.windows=dfu-util.exe +tools.dfu_util.path={runtime.tools.STM32Tools.path}/tools/win/dfu-util +tools.dfu_util.path.macosx={runtime.tools.STM32Tools.path}/tools/macosx/dfu-util +tools.dfu_util.path.linux={runtime.tools.STM32Tools.path}/tools/linux/dfu-util +tools.dfu_util.path.linux64={runtime.tools.STM32Tools.path}/tools/linux64/dfu-util +tools.dfu_util.upload.params.verbose=-v +tools.dfu_util.upload.params.quiet= +tools.dfu_util.upload.pattern="{path}/{cmd}" --device {upload.usbID} -a 0 --dfuse-address {upload.address} -D "{build.path}/{build.project_name}.bin" diff --git a/variants/THUNDER_PACK/PeripheralPins.c b/variants/THUNDER_PACK/PeripheralPins.c new file mode 100644 index 0000000000..e120e4e3c1 --- /dev/null +++ b/variants/THUNDER_PACK/PeripheralPins.c @@ -0,0 +1,168 @@ +/* + ******************************************************************************* + * 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 STM32L072C(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 + +//*** DAC *** + +#ifdef HAL_DAC_MODULE_ENABLED +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 + {NC, NP, 0} +}; +#endif + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SDA[] = { + {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)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_I2C_MODULE_ENABLED +WEAK const PinMap PinMap_I2C_SCL[] = { + {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)}, + {PB_8, 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_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 + // {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_AF2_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 + {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_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)}, + {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_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)}, + {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[] = { + {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 + +//*** 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_AF0_SPI1)}, + {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_AF0_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_AF0_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_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** No CAN *** + +//*** No ETHERNET *** + +//*** No QUADSPI *** + +//*** USB *** + +#ifdef HAL_PCD_MODULE_ENABLED +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 + {PA_13, USB, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_USB)}, // USB_NOE + {NC, NP, 0} +}; +#endif + +//*** No USB_OTG_FS *** + +//*** No USB_OTG_HS *** \ No newline at end of file diff --git a/variants/THUNDER_PACK/PinNamesVar.h b/variants/THUNDER_PACK/PinNamesVar.h new file mode 100644 index 0000000000..b030548b3f --- /dev/null +++ b/variants/THUNDER_PACK/PinNamesVar.h @@ -0,0 +1,31 @@ +/* SYS_WKUP */ +#ifdef PWR_WAKEUP_PIN1 +SYS_WKUP1 = PA_0, +#endif +#ifdef PWR_WAKEUP_PIN2 +SYS_WKUP2 = PC_13, +#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/ldscript.ld b/variants/THUNDER_PACK/ldscript.ld new file mode 100644 index 0000000000..bb039841cc --- /dev/null +++ b/variants/THUNDER_PACK/ldscript.ld @@ -0,0 +1,189 @@ +/* +****************************************************************************** +** + +** 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) } +} + + diff --git a/variants/THUNDER_PACK/readme.txt b/variants/THUNDER_PACK/readme.txt new file mode 100644 index 0000000000..ff14f22211 --- /dev/null +++ b/variants/THUNDER_PACK/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/THUNDER_PACK/variant.cpp new file mode 100644 index 0000000000..725705f769 --- /dev/null +++ b/variants/THUNDER_PACK/variant.cpp @@ -0,0 +1,126 @@ +/* + ******************************************************************************* + * 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. + ******************************************************************************* + */ + +#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 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + + /** Configure the main internal regulator output voltage + */ + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + /** 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; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + 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__); + } + /** 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_DIV1; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) + { + _Error_Handler(__FILE__, __LINE__); + } + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1 + |RCC_PERIPHCLK_USB; + PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; + PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) + { + _Error_Handler(__FILE__, __LINE__); + } +} + +#ifdef __cplusplus +} +#endif diff --git a/variants/THUNDER_PACK/variant.h b/variants/THUNDER_PACK/variant.h new file mode 100644 index 0000000000..d4b62b1adf --- /dev/null +++ b/variants/THUNDER_PACK/variant.h @@ -0,0 +1,124 @@ +/* + ******************************************************************************* + * 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 +#define PA1 1 +#define PA2 2 +#define PA3 3 +#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 19 + +// 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 0 +#define LED_GREEN LED_BUILTIN +#define LED_1 0 +#define LED_2 1 +#define LED_3 2 +#define LED_4 3 + +// On-board user button +#define USER_BTN PB4 + +// Timer Definitions +// Use TIM6/TIM7 when possible as servo and tone don't need GPIO output pin +#define TIMER_TONE TIM6 +#define TIMER_SERVO TIM7 + +// 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 12 +#define PIN_SERIAL_TX 11 + +/* Extra HAL modules */ +#define HAL_DAC_MODULE_ENABLED + +#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_ */ From 78423a64de83a500a1a07fc10857d73439d6c696 Mon Sep 17 00:00:00 2001 From: jgillick Date: Fri, 18 Oct 2019 06:57:51 -0700 Subject: [PATCH 02/11] Move ThunderPack to GenericL0 group. Remove dfu-util upload method (will be put in another PR) --- boards.txt | 72 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/boards.txt b/boards.txt index 240563fcdf..a0d272f1fb 100644 --- a/boards.txt +++ b/boards.txt @@ -1009,6 +1009,46 @@ GenF4.menu.upload_method.hidMethod.upload.tool=hid_upload GenF4.menu.upload_method.hidMethod.build.flash_offset=0x4000 GenF4.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OFFSET={build.flash_offset} +################################################################################ +# Generic L0 +GenL0.name=Generic STM32L0 series +GenL0.build.vid=0x0483 +GenL0.build.core=arduino +GenL0.build.board=GenL0 +GenL0.build.extra_flags={build.usb_flags} -DUSBD_USE_CDC -D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 +GenL0.build.mcu=cortex-m0plus +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 + +# Upload menu +GenL0.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD) +GenL0.menu.upload_method.swdMethod.upload.protocol=0 +GenL0.menu.upload_method.swdMethod.upload.options=-g +GenL0.menu.upload_method.swdMethod.upload.tool=stm32CubeProg + +GenL0.menu.upload_method.serialMethod=STM32CubeProgrammer (Serial) +GenL0.menu.upload_method.serialMethod.upload.protocol=1 +GenL0.menu.upload_method.serialMethod.upload.options={serial.port.file} -s +GenL0.menu.upload_method.serialMethod.upload.tool=stm32CubeProg + +GenL0.menu.upload_method.dfuMethod=STM32CubeProgrammer (DFU) +GenL0.menu.upload_method.dfuMethod.upload.protocol=2 +GenL0.menu.upload_method.dfuMethod.upload.options=-g +GenL0.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg + +GenL0.menu.upload_method.bmpMethod=BMP (Black Magic Probe) +GenL0.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp +GenL0.menu.upload_method.bmpMethod.upload.tool=bmp_upload + + ############################### # Sparky Flight Controllers @@ -1991,35 +2031,3 @@ Midatronics.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf Midatronics.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float Midatronics.menu.rtlib.full=Newlib Standard Midatronics.menu.rtlib.full.build.flags.ldspecs= - -############################### -# ThunderPack -ThunderPack.name=ThunderPack -ThunderPack.build.core=arduino -ThunderPack.build.product_line=STM32L072xx -ThunderPack.build.board=ThunderPack -ThunderPack.build.variant=THUNDER_PACK -ThunderPack.build.mcu=cortex-m0plus -ThunderPack.build.series=STM32L0xx -ThunderPack.build.cmsis_lib_gcc=arm_cortexM0l_math -ThunderPack.build.vid=0x0483 -ThunderPack.build.extra_flags={build.usb_flags} -DUSBD_USE_CDC -D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 - -ThunderPack.upload.maximum_size=196608 -ThunderPack.upload.maximum_data_size=20480 - -ThunderPack.menu.upload_method.dfuUtil=DFU Util -ThunderPack.menu.upload_method.dfuUtil.upload.tool=dfu_util -ThunderPack.menu.upload_method.dfuUtil.upload.protocol= -ThunderPack.menu.upload_method.dfuUtil.upload.usbID=0483:df11 -ThunderPack.menu.upload_method.dfuUtil.upload.address=0x08000000:leave - -ThunderPack.menu.upload_method.swdMethod=STM32CubeProgrammer (SWD) -ThunderPack.menu.upload_method.swdMethod.upload.protocol=0 -ThunderPack.menu.upload_method.swdMethod.upload.options=-g -ThunderPack.menu.upload_method.swdMethod.upload.tool=stm32CubeProg - -ThunderPack.menu.upload_method.dfuMethod=STM32CubeProgrammer (DFU) -ThunderPack.menu.upload_method.dfuMethod.upload.protocol=2 -ThunderPack.menu.upload_method.dfuMethod.upload.options=-g -ThunderPack.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg \ No newline at end of file From 3dde4d53daf2ef3afc0fb8b6b44c50164359949c Mon Sep 17 00:00:00 2001 From: jgillick Date: Fri, 18 Oct 2019 07:01:03 -0700 Subject: [PATCH 03/11] Fix the number of digital pins for ThunderPack. --- variants/THUNDER_PACK/variant.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variants/THUNDER_PACK/variant.h b/variants/THUNDER_PACK/variant.h index d4b62b1adf..25b0b17a4e 100644 --- a/variants/THUNDER_PACK/variant.h +++ b/variants/THUNDER_PACK/variant.h @@ -61,7 +61,7 @@ extern "C" { #define PA14 20 // SWD // This must be a literal -#define NUM_DIGITAL_PINS 19 +#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 From 6bc5aef43eaf63e206171c4f6def3dc9b129ced3 Mon Sep 17 00:00:00 2001 From: jgillick Date: Fri, 18 Oct 2019 07:09:35 -0700 Subject: [PATCH 04/11] Remove dfu-util --- platform.txt | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/platform.txt b/platform.txt index 927b53bd9b..389b304bc5 100644 --- a/platform.txt +++ b/platform.txt @@ -200,14 +200,3 @@ tools.maple_upload.path.linux={runtime.tools.STM32Tools.path}/tools/linux tools.maple_upload.upload.params.verbose=-d tools.maple_upload.upload.params.quiet=n tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" - -# Upload using dfu-util -tools.dfu_util.cmd=dfu-util -tools.dfu_util.cmd.windows=dfu-util.exe -tools.dfu_util.path={runtime.tools.STM32Tools.path}/tools/win/dfu-util -tools.dfu_util.path.macosx={runtime.tools.STM32Tools.path}/tools/macosx/dfu-util -tools.dfu_util.path.linux={runtime.tools.STM32Tools.path}/tools/linux/dfu-util -tools.dfu_util.path.linux64={runtime.tools.STM32Tools.path}/tools/linux64/dfu-util -tools.dfu_util.upload.params.verbose=-v -tools.dfu_util.upload.params.quiet= -tools.dfu_util.upload.pattern="{path}/{cmd}" --device {upload.usbID} -a 0 --dfuse-address {upload.address} -D "{build.path}/{build.project_name}.bin" From 0d99d98e952ad468e51f27ba41e5776dd451cb07 Mon Sep 17 00:00:00 2001 From: jgillick Date: Fri, 18 Oct 2019 19:33:18 -0700 Subject: [PATCH 05/11] Add missing options to GenL0 (copied from GenF0) --- boards.txt | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/boards.txt b/boards.txt index a0d272f1fb..7534c523b6 100644 --- a/boards.txt +++ b/boards.txt @@ -718,6 +718,10 @@ GenF0.menu.upload_method.dfuMethod.upload.protocol=2 GenF0.menu.upload_method.dfuMethod.upload.options=-g GenF0.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg +GenL0.menu.upload_method.bmpMethod=BMP (Black Magic Probe) +GenL0.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp +GenL0.menu.upload_method.bmpMethod.upload.tool=bmp_upload + ################################################################################ # Generic F1 GenF1.name=Generic STM32F1 series @@ -1012,6 +1016,7 @@ GenF4.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OF ################################################################################ # Generic L0 GenL0.name=Generic STM32L0 series + GenL0.build.vid=0x0483 GenL0.build.core=arduino GenL0.build.board=GenL0 @@ -1044,11 +1049,6 @@ GenL0.menu.upload_method.dfuMethod.upload.protocol=2 GenL0.menu.upload_method.dfuMethod.upload.options=-g GenL0.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg -GenL0.menu.upload_method.bmpMethod=BMP (Black Magic Probe) -GenL0.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp -GenL0.menu.upload_method.bmpMethod.upload.tool=bmp_upload - - ############################### # Sparky Flight Controllers @@ -1453,6 +1453,12 @@ GenF4.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE GenF4.menu.xserial.disabled=Disabled (no Serial support) GenF4.menu.xserial.disabled.build.xSerial= +GenL0.menu.xserial.generic=Enabled (generic 'Serial') +GenL0.menu.xserial.none=Enabled (no generic 'Serial') +GenL0.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE +GenL0.menu.xserial.disabled=Disabled (no Serial support) +GenL0.menu.xserial.disabled.build.xSerial= + Sparky.menu.xserial.generic=Enabled (generic 'Serial') Sparky.menu.xserial.none=Enabled (no generic 'Serial') Sparky.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE @@ -1801,6 +1807,24 @@ GenF4.menu.opt.o3lto.build.flags.optimize=-O3 -flto GenF4.menu.opt.ogstd=Debug (-g) GenF4.menu.opt.ogstd.build.flags.optimize=-g -Og +GenL0.menu.opt.osstd=Smallest (-Os default) +GenL0.menu.opt.oslto=Smallest (-Os) with LTO +GenL0.menu.opt.oslto.build.flags.optimize=-Os -flto +GenL0.menu.opt.o1std=Fast (-O1) +GenL0.menu.opt.o1std.build.flags.optimize=-O1 +GenL0.menu.opt.o1lto=Fast (-O1) with LTO +GenL0.menu.opt.o1lto.build.flags.optimize=-O1 -flto +GenL0.menu.opt.o2std=Faster (-O2) +GenL0.menu.opt.o2std.build.flags.optimize=-O2 +GenL0.menu.opt.o2lto=Faster (-O2) with LTO +GenL0.menu.opt.o2lto.build.flags.optimize=-O2 -flto +GenL0.menu.opt.o3std=Fastest (-O3) +GenL0.menu.opt.o3std.build.flags.optimize=-O3 +GenL0.menu.opt.o3lto=Fastest (-O3) with LTO +GenL0.menu.opt.o3lto.build.flags.optimize=-O3 -flto +GenL0.menu.opt.ogstd=Debug (-g) +GenL0.menu.opt.ogstd.build.flags.optimize=-g -Og + Sparky.menu.opt.osstd=Smallest (-Os default) Sparky.menu.opt.oslto=Smallest (-Os) with LTO Sparky.menu.opt.oslto.build.flags.optimize=-Os -flto @@ -1982,6 +2006,16 @@ GenF4.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float GenF4.menu.rtlib.full=Newlib Standard GenF4.menu.rtlib.full.build.flags.ldspecs= +GenL0.menu.rtlib.nano=Newlib Nano (default) +GenL0.menu.rtlib.nanofp=Newlib Nano + Float Printf +GenL0.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float +GenL0.menu.rtlib.nanofs=Newlib Nano + Float Scanf +GenL0.menu.rtlib.nanofs.build.flags.ldspecs=--specs=nano.specs -u _scanf_float +GenL0.menu.rtlib.nanofps=Newlib Nano + Float Printf/Scanf +GenL0.menu.rtlib.nanofps.build.flags.ldspecs=--specs=nano.specs -u _printf_float -u _scanf_float +GenL0.menu.rtlib.full=Newlib Standard +GenL0.menu.rtlib.full.build.flags.ldspecs= + Sparky.menu.rtlib.nano=Newlib Nano (default) Sparky.menu.rtlib.nanofp=Newlib Nano + Float Printf Sparky.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float From dad5be460162fd487152b944fc6b4a4f3d4e5df2 Mon Sep 17 00:00:00 2001 From: jgillick Date: Fri, 18 Oct 2019 19:33:59 -0700 Subject: [PATCH 06/11] Fix astyle errors. --- variants/THUNDER_PACK/variant.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/variants/THUNDER_PACK/variant.cpp b/variants/THUNDER_PACK/variant.cpp index 725705f769..8df8c8c55a 100644 --- a/variants/THUNDER_PACK/variant.cpp +++ b/variants/THUNDER_PACK/variant.cpp @@ -80,12 +80,12 @@ WEAK void SystemClock_Config(void) RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - /** 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.OscillatorType = RCC_OSCILLATORTYPE_HSI | RCC_OSCILLATORTYPE_HSI48; RCC_OscInitStruct.HSIState = RCC_HSI_ON; RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; @@ -93,30 +93,27 @@ WEAK void SystemClock_Config(void) RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLMUL = RCC_PLLMUL_4; RCC_OscInitStruct.PLL.PLLDIV = RCC_PLLDIV_2; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) - { + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } - /** 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.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_DIV1; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) - { + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_I2C1 - |RCC_PERIPHCLK_USB; + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_I2C1 + | RCC_PERIPHCLK_USB; PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2; PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) - { + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); } } From ef866e900026b93fa2c4385057a09a670e39fdf5 Mon Sep 17 00:00:00 2001 From: Jeremy Gillick Date: Sun, 20 Oct 2019 14:48:48 -0700 Subject: [PATCH 07/11] Move BMP upload method to the correct section. --- boards.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/boards.txt b/boards.txt index 7534c523b6..9d3039e29b 100644 --- a/boards.txt +++ b/boards.txt @@ -718,10 +718,6 @@ GenF0.menu.upload_method.dfuMethod.upload.protocol=2 GenF0.menu.upload_method.dfuMethod.upload.options=-g GenF0.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg -GenL0.menu.upload_method.bmpMethod=BMP (Black Magic Probe) -GenL0.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp -GenL0.menu.upload_method.bmpMethod.upload.tool=bmp_upload - ################################################################################ # Generic F1 GenF1.name=Generic STM32F1 series @@ -1049,6 +1045,10 @@ GenL0.menu.upload_method.dfuMethod.upload.protocol=2 GenL0.menu.upload_method.dfuMethod.upload.options=-g GenL0.menu.upload_method.dfuMethod.upload.tool=stm32CubeProg +GenL0.menu.upload_method.bmpMethod=BMP (Black Magic Probe) +GenL0.menu.upload_method.bmpMethod.upload.protocol=gdb_bmp +GenL0.menu.upload_method.bmpMethod.upload.tool=bmp_upload + ############################### # Sparky Flight Controllers From 3e35854aae999ceee042706f5a8d408a5e5ea89c Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 21 Oct 2019 08:56:49 -0700 Subject: [PATCH 08/11] Add USB options to GenL0 --- boards.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/boards.txt b/boards.txt index 9d3039e29b..fbc988cd93 100644 --- a/boards.txt +++ b/boards.txt @@ -837,7 +837,7 @@ GenF1.menu.upload_method.hidMethod=HID Bootloader 2.2 GenF1.menu.upload_method.hidMethod.upload.protocol=hid22 GenF1.menu.upload_method.hidMethod.upload.tool=hid_upload GenF1.menu.upload_method.hidMethod.build.flash_offset=0x800 -GenF1.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OFFSET={build.flash_offset} +GenF1.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OFFSET={build.flash_offset} GenF1.menu.upload_method.dfu2Method=Maple DFU Bootloader 2.0 GenF1.menu.upload_method.dfu2Method.upload.protocol=maple @@ -1007,7 +1007,7 @@ GenF4.menu.upload_method.hidMethod=HID Bootloader 2.2 GenF4.menu.upload_method.hidMethod.upload.protocol=hid22 GenF4.menu.upload_method.hidMethod.upload.tool=hid_upload GenF4.menu.upload_method.hidMethod.build.flash_offset=0x4000 -GenF4.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OFFSET={build.flash_offset} +GenF4.menu.upload_method.hidMethod.build.bootloader_flags=-DBL_HID -DVECT_TAB_OFFSET={build.flash_offset} ################################################################################ # Generic L0 @@ -1297,7 +1297,7 @@ Genericflight.build.series=STM32F1xx Genericflight.build.cmsis_lib_gcc=arm_cortexM3l_math Genericflight.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} {build.bootloader_flags} -# AfroFlight Rev5 +# AfroFlight Rev5 Genericflight.menu.pnum.AFROFLIGHT_F103CB=Afro Flight Rev5 (8MHz) Genericflight.menu.pnum.AFROFLIGHT_F103CB.upload.maximum_size=131072 Genericflight.menu.pnum.AFROFLIGHT_F103CB.upload.maximum_data_size=20480 @@ -1594,6 +1594,14 @@ GenF4.menu.xusb.HS.build.usb_speed=-DUSE_USB_HS GenF4.menu.xusb.HSFS=High Speed in Full Speed mode GenF4.menu.xusb.HSFS.build.usb_speed=-DUSE_USB_HS -DUSE_USB_HS_IN_FS +GenL0.menu.usb.none=None +GenL0.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART) +GenL0.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC +GenL0.menu.usb.CDC=CDC (no generic 'Serial') +GenL0.menu.usb.CDC.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC -DDISABLE_GENERIC_SERIALUSB +GenL0.menu.usb.HID=HID (keyboard and mouse) +GenL0.menu.usb.HID.build.enable_usb={build.usb_flags} -DUSBD_USE_HID_COMPOSITE + Sparky.menu.usb.none=None Sparky.menu.usb.CDCgen=CDC (generic 'Serial' supersede U(S)ART) Sparky.menu.usb.CDCgen.build.enable_usb={build.usb_flags} -DUSBD_USE_CDC From 58a1c20d6931095b7cb71d0b30ed8c6ee11044dd Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 21 Oct 2019 08:58:02 -0700 Subject: [PATCH 09/11] Update for STM32L072KZTx chip. Use PYn notation, instead of arduino pin numbers. --- variants/THUNDER_PACK/PeripheralPins.c | 10 +++++++--- variants/THUNDER_PACK/PinNamesVar.h | 4 ++-- variants/THUNDER_PACK/variant.cpp | 6 +++--- variants/THUNDER_PACK/variant.h | 22 +++++++++++----------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/variants/THUNDER_PACK/PeripheralPins.c b/variants/THUNDER_PACK/PeripheralPins.c index e120e4e3c1..fdfc6b0b2f 100644 --- a/variants/THUNDER_PACK/PeripheralPins.c +++ b/variants/THUNDER_PACK/PeripheralPins.c @@ -9,7 +9,7 @@ * opensource.org/licenses/BSD-3-Clause * ******************************************************************************* - * Automatically generated from STM32L072C(B-Z)Tx.xml + * Automatically generated from STM32L072K(B-Z)Tx.xml */ #include "Arduino.h" #include "PeripheralPins.h" @@ -57,7 +57,6 @@ WEAK const PinMap PinMap_I2C_SCL[] = { {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)}, - {PB_8, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, {NC, NP, 0} }; #endif @@ -77,6 +76,8 @@ WEAK const PinMap PinMap_PWM[] = { // {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 + {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 {NC, NP, 0} }; #endif @@ -121,6 +122,7 @@ WEAK const PinMap PinMap_UART_CTS[] = { #ifdef HAL_SPI_MODULE_ENABLED WEAK const PinMap PinMap_SPI_MOSI[] = { {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)}, {NC, NP, 0} }; #endif @@ -165,4 +167,6 @@ WEAK const PinMap PinMap_USB[] = { //*** No USB_OTG_FS *** -//*** No USB_OTG_HS *** \ No newline at end of file +//*** No USB_OTG_HS *** + +//*** No SD *** \ No newline at end of file diff --git a/variants/THUNDER_PACK/PinNamesVar.h b/variants/THUNDER_PACK/PinNamesVar.h index b030548b3f..6b89c927a4 100644 --- a/variants/THUNDER_PACK/PinNamesVar.h +++ b/variants/THUNDER_PACK/PinNamesVar.h @@ -1,9 +1,9 @@ /* SYS_WKUP */ #ifdef PWR_WAKEUP_PIN1 -SYS_WKUP1 = PA_0, +SYS_WKUP1 = NC, #endif #ifdef PWR_WAKEUP_PIN2 -SYS_WKUP2 = PC_13, +SYS_WKUP2 = NC, #endif #ifdef PWR_WAKEUP_PIN3 SYS_WKUP3 = NC, diff --git a/variants/THUNDER_PACK/variant.cpp b/variants/THUNDER_PACK/variant.cpp index 8df8c8c55a..154d046cac 100644 --- a/variants/THUNDER_PACK/variant.cpp +++ b/variants/THUNDER_PACK/variant.cpp @@ -76,9 +76,9 @@ extern "C" { */ WEAK void SystemClock_Config(void) { - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + RCC_OscInitTypeDef RCC_OscInitStruct = {}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {}; /** Configure the main internal regulator output voltage */ diff --git a/variants/THUNDER_PACK/variant.h b/variants/THUNDER_PACK/variant.h index 25b0b17a4e..f07a1a0f83 100644 --- a/variants/THUNDER_PACK/variant.h +++ b/variants/THUNDER_PACK/variant.h @@ -39,10 +39,10 @@ extern "C" { * Pins *----------------------------------------------------------------------------*/ -#define PA0 0 -#define PA1 1 -#define PA2 2 -#define PA3 3 +#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 @@ -68,12 +68,12 @@ extern "C" { #define NUM_ANALOG_FIRST 4 // On-board LED pin number -#define LED_BUILTIN 0 +#define LED_BUILTIN PA0 #define LED_GREEN LED_BUILTIN -#define LED_1 0 -#define LED_2 1 -#define LED_3 2 -#define LED_4 3 +#define LED_1 PA0 +#define LED_2 PA1 +#define LED_3 PA2 +#define LED_4 PA3 // On-board user button #define USER_BTN PB4 @@ -88,8 +88,8 @@ extern "C" { // Default pin used for 'Serial' instance (ex: ST-Link) // Mandatory for Firmata -#define PIN_SERIAL_RX 12 -#define PIN_SERIAL_TX 11 +#define PIN_SERIAL_RX PB7 +#define PIN_SERIAL_TX PB6 /* Extra HAL modules */ #define HAL_DAC_MODULE_ENABLED From fb4c6a0dfd1934224f710b907d42ecffd67931a3 Mon Sep 17 00:00:00 2001 From: Jeremy Gillick Date: Mon, 21 Oct 2019 17:43:11 -0700 Subject: [PATCH 10/11] Update boards.txt with usb in extra_flags Co-Authored-By: Frederic Pillon --- boards.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards.txt b/boards.txt index fbc988cd93..0c69daf299 100644 --- a/boards.txt +++ b/boards.txt @@ -1016,7 +1016,7 @@ GenL0.name=Generic STM32L0 series GenL0.build.vid=0x0483 GenL0.build.core=arduino GenL0.build.board=GenL0 -GenL0.build.extra_flags={build.usb_flags} -DUSBD_USE_CDC -D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 +GenL0.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -D__CORTEX_SC=0 GenL0.build.mcu=cortex-m0plus GenL0.build.series=STM32L0xx GenL0.build.cmsis_lib_gcc=arm_cortexM0l_math From 71a494ce264d1fc9abf3d8cb445ee32598565ab2 Mon Sep 17 00:00:00 2001 From: jgillick Date: Mon, 21 Oct 2019 20:33:04 -0700 Subject: [PATCH 11/11] Prevent "duplicate case value" error. --- variants/THUNDER_PACK/PinNamesVar.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/variants/THUNDER_PACK/PinNamesVar.h b/variants/THUNDER_PACK/PinNamesVar.h index 6b89c927a4..b030548b3f 100644 --- a/variants/THUNDER_PACK/PinNamesVar.h +++ b/variants/THUNDER_PACK/PinNamesVar.h @@ -1,9 +1,9 @@ /* SYS_WKUP */ #ifdef PWR_WAKEUP_PIN1 -SYS_WKUP1 = NC, +SYS_WKUP1 = PA_0, #endif #ifdef PWR_WAKEUP_PIN2 -SYS_WKUP2 = NC, +SYS_WKUP2 = PC_13, #endif #ifdef PWR_WAKEUP_PIN3 SYS_WKUP3 = NC,