From a54d11bc711ada14de71f41a676dd4cf562079d1 Mon Sep 17 00:00:00 2001 From: Claudio Hediger Date: Sun, 5 Aug 2018 15:59:51 +0200 Subject: [PATCH 1/4] Added STM32F030K6 as Generic type --- boards.txt | 69 ++++ variants/GENERIC_F030K6/PeripheralPins.c | 192 ++++++++++++ variants/GENERIC_F030K6/PinNamesVar.h | 25 ++ variants/GENERIC_F030K6/ldscript.ld | 178 +++++++++++ variants/GENERIC_F030K6/readme.txt | 2 + variants/GENERIC_F030K6/stm32f0xx_hal_conf.h | 312 +++++++++++++++++++ variants/GENERIC_F030K6/variant.cpp | 182 +++++++++++ variants/GENERIC_F030K6/variant.h | 192 ++++++++++++ 8 files changed, 1152 insertions(+) create mode 100644 variants/GENERIC_F030K6/PeripheralPins.c create mode 100644 variants/GENERIC_F030K6/PinNamesVar.h create mode 100644 variants/GENERIC_F030K6/ldscript.ld create mode 100644 variants/GENERIC_F030K6/readme.txt create mode 100644 variants/GENERIC_F030K6/stm32f0xx_hal_conf.h create mode 100644 variants/GENERIC_F030K6/variant.cpp create mode 100644 variants/GENERIC_F030K6/variant.h diff --git a/boards.txt b/boards.txt index feb2709823..28b6f7aaeb 100644 --- a/boards.txt +++ b/boards.txt @@ -439,6 +439,41 @@ Disco.menu.upload_method.STLink.upload.tool=stlink_upload ################################################################################ # Other boards +############################### +# Generic F030 +GenF030.name=Generic STM32F030 series + +GenF030.build.vid=0x1EAF +GenF030.build.pid=0x0004 +GenF030.vid.0=0x1EAF +GenF030.pid.0=0x0004 + +GenF030.build.core=arduino +GenF030.build.board=GenF030 +GenF030.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} + +# Generic F030 board +# Support: Serial1 (USART1 on PA10, PA9) +GenF030.menu.pnum.GENERIC_F030K6=Generic F030K6 +GenF030.menu.pnum.GENERIC_F030K6.node="No_mass_storage_for_this_board_Use_STLink_upload_method" +GenF030.menu.pnum.GENERIC_F030K6.upload.maximum_data_size=4096 +GenF030.menu.pnum.GENERIC_F030K6.build.mcu=cortex-m0 +GenF030.menu.pnum.GENERIC_F030K6.build.board=GENERIC_F030K6 +GenF030.menu.pnum.GENERIC_F030K6.build.series=STM32F0xx +GenF030.menu.pnum.GENERIC_F030K6.build.product_line=STM32F030x6 +GenF030.menu.pnum.GENERIC_F030K6.build.variant=GENERIC_F030K6 +GenF030.menu.pnum.GENERIC_F030K6.build.cmsis_lib_gcc=arm_cortexM0l_math + +GenF030.menu.flash.K6=32k (default) +GenF030.menu.flash.K6.upload.maximum_size=32768 +GenF030.menu.flash.K6.build.ldscript=ldscript.ld + +# Upload menu +GenF030.menu.upload_method.STLinkMethod=STLink +GenF030.menu.upload_method.STLinkMethod.upload.protocol=STLink +GenF030.menu.upload_method.STLinkMethod.upload.tool=stlink_upload + + ############################### # Generic F103 GenF103.name=Generic STM32F103 series @@ -550,6 +585,12 @@ GenF103.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NON GenF103.menu.xserial.disabled=Disabled (No Serial) GenF103.menu.xserial.disabled.build.xSerial= +GenF030.menu.xserial.generic=Enabled with generic Serial +GenF030.menu.xserial.none=Enabled without generic Serial +GenF030.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE +GenF030.menu.xserial.disabled=Disabled (No Serial) +GenF030.menu.xserial.disabled.build.xSerial= + Maple.menu.xserial.generic=Enabled with generic Serial Maple.menu.xserial.none=Enabled without generic Serial Maple.menu.xserial.none.build.xSerial=-DHAL_UART_MODULE_ENABLED -DHWSERIAL_NONE @@ -712,6 +753,34 @@ GenF103.menu.opt.ogstd=Debug (-g) GenF103.menu.opt.ogstd.build.flags.optimize=-g -Og GenF103.menu.opt.ogstd.build.flags.ldspecs= +GenF030.menu.opt.osstd=Smallest (-Os default) +GenF030.menu.opt.osstd.build.flags.optimize=-Os +GenF030.menu.opt.osstd.build.flags.ldspecs= +GenF030.menu.opt.oslto=Smallest (-Os) with LTO +GenF030.menu.opt.oslto.build.flags.optimize=-Os -flto +GenF030.menu.opt.oslto.build.flags.ldspecs=-flto +GenF030.menu.opt.o1std=Fast (-O1) +GenF030.menu.opt.o1std.build.flags.optimize=-O1 +GenF030.menu.opt.o1std.build.flags.ldspecs= +GenF030.menu.opt.o1lto=Fast (-O1) with LTO +GenF030.menu.opt.o1lto.build.flags.optimize=-O1 -flto +GenF030.menu.opt.o1lto.build.flags.ldspecs=-flto +GenF030.menu.opt.o2std=Faster (-O2) +GenF030.menu.opt.o2std.build.flags.optimize=-O2 +GenF030.menu.opt.o2std.build.flags.ldspecs= +GenF030.menu.opt.o2lto=Faster (-O2) with LTO +GenF030.menu.opt.o2lto.build.flags.optimize=-O2 -flto +GenF030.menu.opt.o2lto.build.flags.ldspecs=-flto +GenF030.menu.opt.o3std=Fastest (-O3) +GenF030.menu.opt.o3std.build.flags.optimize=-O3 +GenF030.menu.opt.o3std.build.flags.ldspecs= +GenF030.menu.opt.o3lto=Fastest (-O3) with LTO +GenF030.menu.opt.o3lto.build.flags.optimize=-O3 -flto +GenF030.menu.opt.o3lto.build.flags.ldspecs=-flto +GenF030.menu.opt.ogstd=Debug (-g) +GenF030.menu.opt.ogstd.build.flags.optimize=-g -Og +GenF030.menu.opt.ogstd.build.flags.ldspecs= + Maple.menu.opt.osstd=Smallest (-Os default) Maple.menu.opt.oslto=Smallest (-Os) with LTO Maple.menu.opt.oslto.build.flags.optimize=-Os -flto diff --git a/variants/GENERIC_F030K6/PeripheralPins.c b/variants/GENERIC_F030K6/PeripheralPins.c new file mode 100644 index 0000000000..c2130e4c3b --- /dev/null +++ b/variants/GENERIC_F030K6/PeripheralPins.c @@ -0,0 +1,192 @@ +/* + ******************************************************************************* + * Copyright (c) 2018, 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. + ******************************************************************************* + * Automatically generated from STM32F030K6Tx.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 +const PinMap PinMap_ADC[] = { + {PA_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 0, 0)}, // ADC_IN0 + {PA_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 1, 0)}, // ADC_IN1 + {PA_2, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 2, 0)}, // ADC_IN2 + {PA_3, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 3, 0)}, // ADC_IN3 + {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 + {PB_0, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 8, 0)}, // ADC_IN8 + {PB_1, ADC1, STM_PIN_DATA_EXT(STM_MODE_ANALOG, GPIO_NOPULL, 0, 9, 0)}, // ADC_IN9 + {NC, NP, 0} +}; +#endif + +//*** DAC *** + +//*** No DAC *** + +//*** I2C *** + +#ifdef HAL_I2C_MODULE_ENABLED +const PinMap PinMap_I2C_SDA[] = { + {PA_10, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_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 +const PinMap PinMap_I2C_SCL[] = { + {PA_9, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF4_I2C1)}, + {PB_6, I2C1, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_NOPULL, GPIO_AF1_I2C1)}, + {NC, NP, 0} +}; +#endif + +//*** PWM *** + +#ifdef HAL_TIM_MODULE_ENABLED +const PinMap PinMap_PWM[] = { + {PA_4, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_6, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PA_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM16, 1, 0)}, // TIM16_CH1 + {PA_7, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 1)}, // TIM1_CH1N + {PA_7, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PA_7, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF4_TIM14, 1, 0)}, // TIM14_CH1 + {PA_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF5_TIM17, 1, 0)}, // TIM17_CH1 + {PA_8, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 1, 0)}, // TIM1_CH1 + {PA_9, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 0)}, // TIM1_CH2 + {PA_10, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 0)}, // TIM1_CH3 + {PA_11, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 4, 0)}, // TIM1_CH4 + {PB_0, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 2, 1)}, // TIM1_CH2N + {PB_0, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 3, 0)}, // TIM3_CH3 + {PB_1, TIM1, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM1, 3, 1)}, // TIM1_CH3N + {PB_1, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 4, 0)}, // TIM3_CH4 + {PB_1, TIM14, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_TIM14, 1, 0)}, // TIM14_CH1 + {PB_4, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 1, 0)}, // TIM3_CH1 + {PB_5, TIM3, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_TIM3, 2, 0)}, // TIM3_CH2 + {PB_6, TIM16, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM16, 1, 1)}, // TIM16_CH1N + {PB_7, TIM17, STM_PIN_DATA_EXT(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF2_TIM17, 1, 1)}, // TIM17_CH1N + {NC, NP, 0} +}; +#endif + +//*** SERIAL *** + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_TX[] = { + {PA_2, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_9, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_14, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_6, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RX[] = { + {PA_3, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_10, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_15, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PB_7, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_RTS[] = { + {PA_1, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_12, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_UART_MODULE_ENABLED +const PinMap PinMap_UART_CTS[] = { + {PA_0, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {PA_11, USART1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART1)}, + {NC, NP, 0} +}; +#endif + +//*** SPI *** + +#ifdef HAL_SPI_MODULE_ENABLED +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 + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_MISO[] = { + {PA_6, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SCLK[] = { + {PA_5, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PB_3, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +#ifdef HAL_SPI_MODULE_ENABLED +const PinMap PinMap_SPI_SSEL[] = { + {PA_4, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {PA_15, SPI1, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF0_SPI1)}, + {NC, NP, 0} +}; +#endif + +//*** CAN *** + +//*** No CAN_RD *** + +//*** No CAN_TD *** + +//*** ETHERNET *** + +//*** No Ethernet *** + +//*** QUADSPI *** + +//*** No QUADSPI *** diff --git a/variants/GENERIC_F030K6/PinNamesVar.h b/variants/GENERIC_F030K6/PinNamesVar.h new file mode 100644 index 0000000000..b65ff1991e --- /dev/null +++ b/variants/GENERIC_F030K6/PinNamesVar.h @@ -0,0 +1,25 @@ + /* 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 diff --git a/variants/GENERIC_F030K6/ldscript.ld b/variants/GENERIC_F030K6/ldscript.ld new file mode 100644 index 0000000000..1088bd97ed --- /dev/null +++ b/variants/GENERIC_F030K6/ldscript.ld @@ -0,0 +1,178 @@ +/* +****************************************************************************** +File: stm32_flash.ld +Info: Generated by Atollic TrueSTUDIO(R) 9.0.0 2018-08-05 + +Abstract: Linker script for STM32F030K6 device + Set heap size, stack size, stack location, memory areas and + sections according to application requirements. + +The MIT License (MIT) +Copyright (c) 2018 STMicroelectronics + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +****************************************************************************** +*/ + +/* Entry Point */ +ENTRY(Reset_Handler) + +/* Highest address of the user mode stack */ +_estack = 0x20001000; /* end of 4K RAM */ + +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x80; /* required amount of stack */ + +/* Specify the memory areas */ +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K + RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 4K + MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K +} + +/* 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(4); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(4); + } >RAM + + /* MEMORY_bank1 section, code must be located here explicitly */ + /* Example: extern int foo(void) __attribute__ ((section (".mb1text"))); */ + .memory_b1_text : + { + *(.mb1text) /* .mb1text sections (code) */ + *(.mb1text*) /* .mb1text* sections (code) */ + *(.mb1rodata) /* read-only data (constants) */ + *(.mb1rodata*) + } >MEMORY_B1 + + /* Remove information from the standard libraries */ + /DISCARD/ : + { + libc.a ( * ) + libm.a ( * ) + libgcc.a ( * ) + } + + .ARM.attributes 0 : { *(.ARM.attributes) } +} diff --git a/variants/GENERIC_F030K6/readme.txt b/variants/GENERIC_F030K6/readme.txt new file mode 100644 index 0000000000..eee2a55cac --- /dev/null +++ b/variants/GENERIC_F030K6/readme.txt @@ -0,0 +1,2 @@ +See Wiki: +https://github.com/stm32duino/wiki/wiki/GENERIC_F030K6 \ No newline at end of file diff --git a/variants/GENERIC_F030K6/stm32f0xx_hal_conf.h b/variants/GENERIC_F030K6/stm32f0xx_hal_conf.h new file mode 100644 index 0000000000..96167719ef --- /dev/null +++ b/variants/GENERIC_F030K6/stm32f0xx_hal_conf.h @@ -0,0 +1,312 @@ +/** + ****************************************************************************** + * @file stm32f0xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file. + ****************************************************************************** + * @attention + * + *

© COPYRIGHT(c) 2016 STMicroelectronics

+ * + * 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. + * + ****************************************************************************** + */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32F0xx_HAL_CONF_H +#define __STM32F0xx_HAL_CONF_H + +#ifdef __cplusplus + extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ +#define HAL_MODULE_ENABLED +#define HAL_ADC_MODULE_ENABLED +/*#define HAL_CAN_MODULE_ENABLED */ +/*#define HAL_CEC_MODULE_ENABLED */ +/*#define HAL_COMP_MODULE_ENABLED */ +#define HAL_CORTEX_MODULE_ENABLED +/*#define HAL_CRC_MODULE_ENABLED */ +/*#define HAL_DAC_MODULE_ENABLED */ +#define HAL_DMA_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_GPIO_MODULE_ENABLED +#define HAL_I2C_MODULE_ENABLED +/*#define HAL_I2S_MODULE_ENABLED */ +/*#define HAL_IRDA_MODULE_ENABLED */ +#define HAL_IWDG_MODULE_ENABLED +/*#define HAL_PCD_MODULE_ENABLED */ +#define HAL_PWR_MODULE_ENABLED +#define HAL_RCC_MODULE_ENABLED +#define HAL_RTC_MODULE_ENABLED +/*#define HAL_SMARTCARD_MODULE_ENABLED */ +/*#define HAL_SMBUS_MODULE_ENABLED */ +#define HAL_SPI_MODULE_ENABLED +#define HAL_TIM_MODULE_ENABLED +/*#define HAL_TSC_MODULE_ENABLED */ +/*#define HAL_UART_MODULE_ENABLED */ +/*#define HAL_USART_MODULE_ENABLED */ +/*#define HAL_WWDG_MODULE_ENABLED */ + +/* ######################### Oscillator Values adaptation ################### */ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +/** + * @brief In the following line adjust the External High Speed oscillator (HSE) Startup + * Timeout value + */ +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief In the following line adjust the Internal High Speed oscillator (HSI) Startup + * Timeout value + */ +#if !defined (HSI_STARTUP_TIMEOUT) + #define HSI_STARTUP_TIMEOUT 5000U /*!< Time out for HSI start up */ +#endif /* HSI_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator for ADC (HSI14) value. + */ +#if !defined (HSI14_VALUE) + #define HSI14_VALUE 14000000U /*!< Value of the Internal High Speed oscillator for ADC in Hz. + The real value may vary depending on the variations + in voltage and temperature. */ +#endif /* HSI14_VALUE */ + +/** + * @brief Internal High Speed oscillator for USB (HSI48) value. + */ +#if !defined (HSI48_VALUE) + #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB in Hz. + The real value may vary depending on the variations + in voltage and temperature. */ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 40000U +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature. */ +/** + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +/** + * @brief Time out for LSE start up value in ms. + */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY ((uint32_t)(1U<<__NVIC_PRIO_BITS) - 1U) /*!< tick interrupt priority (lowest by default) */ + /* Warning: Must be set to higher priority for HAL_Delay() */ + /* and HAL_GetTick() usage under interrupt context */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 0U +#define DATA_CACHE_ENABLE 0U +#define USE_SPI_CRC 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/*#define USE_FULL_ASSERT 1*/ + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED + #include "stm32f0xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED + #include "stm32f0xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED + #include "stm32f0xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED + #include "stm32f0xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED + #include "stm32f0xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_CAN_MODULE_ENABLED + #include "stm32f0xx_hal_can.h" +#endif /* HAL_CAN_MODULE_ENABLED */ + +#ifdef HAL_CEC_MODULE_ENABLED + #include "stm32f0xx_hal_cec.h" +#endif /* HAL_CEC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED + #include "stm32f0xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED + #include "stm32f0xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED + #include "stm32f0xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED + #include "stm32f0xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED + #include "stm32f0xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED + #include "stm32f0xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED + #include "stm32f0xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED + #include "stm32f0xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED + #include "stm32f0xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED + #include "stm32f0xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED + #include "stm32f0xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED + #include "stm32f0xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED + #include "stm32f0xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED + #include "stm32f0xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED + #include "stm32f0xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_TSC_MODULE_ENABLED + #include "stm32f0xx_hal_tsc.h" +#endif /* HAL_TSC_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED + #include "stm32f0xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED + #include "stm32f0xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED + #include "stm32f0xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ + void assert_failed(char* file, uint32_t line); +#else + #define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32F0xx_HAL_CONF_H */ + + +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ diff --git a/variants/GENERIC_F030K6/variant.cpp b/variants/GENERIC_F030K6/variant.cpp new file mode 100644 index 0000000000..f2d521f4d3 --- /dev/null +++ b/variants/GENERIC_F030K6/variant.cpp @@ -0,0 +1,182 @@ +/* + ******************************************************************************* + * Copyright (c) 2018, 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 "variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Pin number +const PinName digitalPin[] = { + //P1 connector Right side (bottom view) + PC_13, //D0 + PC_14, //D1 + PC_15, //D2 + PF_0, //D3 + PF_1, //D4 + PC_0, //D5 + PC_1, //D6 + PC_2, //D7 + PC_3, //D8 + PA_0, //D9 - USER_BTN + PA_1, //D10 + PA_2, //D11 + PA_3, //D12 + PF_4, //D13 + PF_5, //D14 + PA_4, //D15 + PA_5, //D16 + PA_6, //D17 + PA_7, //D18 + PC_4, //D19 + PC_5, //D20 + PB_0, //D21 + PB_1, //D22 + PB_2, //D23 + PB_10, //D24 + PB_11, //D25 + PB_12, //D26 + //P2 connector Left side (bottom view) + PB_9, //D27 + PB_8, //D28 + PB_7, //D29 + PB_6, //D30 + PB_5, //D31 + PB_4, //D32 + PB_3, //D33 + PD_2, //D34 + PC_12, //D35 + PC_11, //D36 + PC_10, //D37 + PA_15, //D38 + PA_14, //D39 + PF_7, //D40 + PF_6, //D41 + PA_13, //D42 + PA_12, //D43 + PA_11, //D44 + PA_10, //D45 + PA_9, //D46 + PA_8, //D47 + PC_9, //D48 - LED_GREEN (LD3) + PC_8, //D49 - LED_BLUE (LD4) + PC_7, //D50 + PC_6, //D51 + PB_15, //D52 + PB_14, //D53 + PB_13, //D54 + // Duplicated pins in order to be aligned with PinMap_ADC + PC_0, //D55/A0 = D5 + PC_1, //D56/A1 = D6 + PC_2, //D57/A2 = D7 + PC_3, //D58/A3 = D8 + PA_0, //D59/A4 = D9 + PA_1, //D60/A5 = D10 + PA_2, //D61/A6 = D11 + PA_3, //D62/A7 = D12 + PA_4, //D63/A8 = D15 + PA_5, //D64/A9 = D16 + PA_6, //D65/A10= D17 + PA_7, //D66/A11= D18 + PC_4, //D67/A12 = D19 + PC_5, //D68/A13 = D20 + PB_0, //D69/A14 = D21 + PB_1 //D70/A15 = D22 +}; + +#ifdef __cplusplus +} +#endif + +// ---------------------------------------------------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System Clock Configuration + * The system Clock is configured as follow : + * System Clock source = PLL (HSI/2) + * SYSCLK(Hz) = 48000000 + * HCLK(Hz) = 48000000 + * AHB Prescaler = 1 + * APB1 Prescaler = 1 + * HSI Frequency(Hz) = 8000000 + * PREDIV = 1 + * PLLMUL = 12 + * Flash Latency(WS) = 1 + * @param None + * @retval None + */ +WEAK void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct; + RCC_ClkInitTypeDef RCC_ClkInitStruct; + + /* Initializes the CPU, AHB and APB busses clocks */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSICalibrationValue = 16; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL12; + RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1; + 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_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) + { + Error_Handler(); + } + + /* Configure the Systick interrupt time */ + HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); + + /* Configure the Systick */ + HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK); + + /* SysTick_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); +} + +#ifdef __cplusplus +} +#endif diff --git a/variants/GENERIC_F030K6/variant.h b/variants/GENERIC_F030K6/variant.h new file mode 100644 index 0000000000..4c4da24087 --- /dev/null +++ b/variants/GENERIC_F030K6/variant.h @@ -0,0 +1,192 @@ +/* + ******************************************************************************* + * Copyright (c) 2018, 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_ + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "PeripheralPins.h" + +#ifdef __cplusplus +extern "C"{ +#endif // __cplusplus + +/*---------------------------------------------------------------------------- + * Pins + *----------------------------------------------------------------------------*/ +extern const PinName digitalPin[]; + +enum { + //P1 connector Right side (bottom view) + PC13, //D0 + PC14, //D1 + PC15, //D2 + PF0, //D3 + PF1, //D4 + PC0, //D5 + PC1, //D6 + PC2, //D7 + PC3, //D8 + PA0, //D9 - USER_BTN + PA1, //D10 + PA2, //D11 + PA3, //D12 + PF4, //D13 + PF5, //D14 + PA4, //D15 + PA5, //D16 + PA6, //D17 + PA7, //D18 + PC4, //D19 + PC5, //D20 + PB0, //D21 + PB1, //D22 + PB2, //D23 + PB10, //D24 + PB11, //D25 + PB12, //D26 + //P2 connector Left side (bottom view) + PB9, //D27 + PB8, //D28 + PB7, //D29 + PB6, //D30 + PB5, //D31 + PB4, //D32 + PB3, //D33 + PD2, //D34 + PC12, //D35 + PC11, //D36 + PC10, //D37 + PA15, //D38 + PA14, //D39 + PF7, //D40 + PF6, //D41 + PA13, //D42 + PA12, //D43 + PA11, //D44 + PA10, //D45 + PA9, //D46 + PA8, //D47 + PC9, //D48 - LED_GREEN (LD3) + PC8, //D49 - LED_BLUE (LD4) + PC7, //D50 + PC6, //D51 + PB15, //D52 + PB14, //D53 + PB13, //D54 + // Duplicated pins in order to be aligned with PinMap_ADC + PC_0_A, //D55/A0 = D5 + PC_1_A, //D56/A1 = D6 + PC_2_A, //D57/A2 = D7 + PC_3_A, //D58/A3 = D8 + PA_0_A, //D59/A4 = D9 + PA_1_A, //D60/A5 = D10 + PA_2_A, //D61/A6 = D11 + PA_3_A, //D62/A7 = D12 + PA_4_A, //D63/A8 = D15 + PA_5_A, //D64/A9 = D16 + PA_6_A, //D65/A10 = D17 + PA_7_A, //D66/A11 = D18 + PC_4_A, //D67/A12 = D19 + PC_5_A, //D68/A13 = D20 + PB_0_A, //D69/A14 = D21 + PB_1_A, //D70/A15 = D22 + PEND +}; + +// This must be a literal with the same value as PEND +#define NUM_DIGITAL_PINS 71 +// This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS +#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_FIRST 55 + + + +// SPI definitions +// SPI1 is used +#define PIN_SPI_SS PA4 +#define PIN_SPI_SS1 PC4 +#define PIN_SPI_SS2 PB12 +#define PIN_SPI_SS3 PC6 +#define PIN_SPI_MOSI PA7 +#define PIN_SPI_MISO PA6 +#define PIN_SPI_SCK PA5 + +// I2C Definitions +// I2C1 is used +#define PIN_WIRE_SDA PB9 +#define PIN_WIRE_SCL PB8 + +// Timer Definitions +//Do not use timer used by PWM pins when possible. See PinMap_PWM. +// STM32F030x6 does not have basic timers. So we have to use TIM14 (General purpose) +#define TIMER_TONE TIM14 + +//Do not use basic timer: OC is required +#define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work + +// UART Definitions +#define SERIAL_UART_INSTANCE 1 // USART 1 + +// Mandatory for Firmata +#define PIN_SERIAL_RX PA10 +#define PIN_SERIAL_TX PA9 + +#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 d76356a64b9b2f5c7f08111cdc9e5d295a57b618 Mon Sep 17 00:00:00 2001 From: Claudio Hediger Date: Thu, 16 Aug 2018 08:18:18 +0200 Subject: [PATCH 2/4] Removed useless entries in boards.txt Corrected pin-definition in variant.cpp and variant.h --- boards.txt | 12 +-- variants/GENERIC_F030K6/variant.cpp | 109 ++++++++---------------- variants/GENERIC_F030K6/variant.h | 124 ++++++++++------------------ 3 files changed, 82 insertions(+), 163 deletions(-) diff --git a/boards.txt b/boards.txt index 28b6f7aaeb..a7774d79ea 100644 --- a/boards.txt +++ b/boards.txt @@ -440,8 +440,8 @@ Disco.menu.upload_method.STLink.upload.tool=stlink_upload # Other boards ############################### -# Generic F030 -GenF030.name=Generic STM32F030 series +# Generic F030K6 Chip +GenF030.name=Generic STM32F030K6 Chip GenF030.build.vid=0x1EAF GenF030.build.pid=0x0004 @@ -452,10 +452,9 @@ GenF030.build.core=arduino GenF030.build.board=GenF030 GenF030.build.extra_flags=-D{build.product_line} {build.enable_usb} {build.xSerial} -# Generic F030 board +# Generic F030K6 Chip # Support: Serial1 (USART1 on PA10, PA9) -GenF030.menu.pnum.GENERIC_F030K6=Generic F030K6 -GenF030.menu.pnum.GENERIC_F030K6.node="No_mass_storage_for_this_board_Use_STLink_upload_method" +GenF030.menu.pnum.GENERIC_F030K6=Generic F030K6 Chip GenF030.menu.pnum.GENERIC_F030K6.upload.maximum_data_size=4096 GenF030.menu.pnum.GENERIC_F030K6.build.mcu=cortex-m0 GenF030.menu.pnum.GENERIC_F030K6.build.board=GENERIC_F030K6 @@ -753,9 +752,6 @@ GenF103.menu.opt.ogstd=Debug (-g) GenF103.menu.opt.ogstd.build.flags.optimize=-g -Og GenF103.menu.opt.ogstd.build.flags.ldspecs= -GenF030.menu.opt.osstd=Smallest (-Os default) -GenF030.menu.opt.osstd.build.flags.optimize=-Os -GenF030.menu.opt.osstd.build.flags.ldspecs= GenF030.menu.opt.oslto=Smallest (-Os) with LTO GenF030.menu.opt.oslto.build.flags.optimize=-Os -flto GenF030.menu.opt.oslto.build.flags.ldspecs=-flto diff --git a/variants/GENERIC_F030K6/variant.cpp b/variants/GENERIC_F030K6/variant.cpp index f2d521f4d3..17110e5bdd 100644 --- a/variants/GENERIC_F030K6/variant.cpp +++ b/variants/GENERIC_F030K6/variant.cpp @@ -36,80 +36,43 @@ extern "C" { // Pin number const PinName digitalPin[] = { - //P1 connector Right side (bottom view) - PC_13, //D0 - PC_14, //D1 - PC_15, //D2 - PF_0, //D3 - PF_1, //D4 - PC_0, //D5 - PC_1, //D6 - PC_2, //D7 - PC_3, //D8 - PA_0, //D9 - USER_BTN - PA_1, //D10 - PA_2, //D11 - PA_3, //D12 - PF_4, //D13 - PF_5, //D14 - PA_4, //D15 - PA_5, //D16 - PA_6, //D17 - PA_7, //D18 - PC_4, //D19 - PC_5, //D20 - PB_0, //D21 - PB_1, //D22 - PB_2, //D23 - PB_10, //D24 - PB_11, //D25 - PB_12, //D26 - //P2 connector Left side (bottom view) - PB_9, //D27 - PB_8, //D28 - PB_7, //D29 - PB_6, //D30 - PB_5, //D31 - PB_4, //D32 - PB_3, //D33 - PD_2, //D34 - PC_12, //D35 - PC_11, //D36 - PC_10, //D37 - PA_15, //D38 - PA_14, //D39 - PF_7, //D40 - PF_6, //D41 - PA_13, //D42 - PA_12, //D43 - PA_11, //D44 - PA_10, //D45 - PA_9, //D46 - PA_8, //D47 - PC_9, //D48 - LED_GREEN (LD3) - PC_8, //D49 - LED_BLUE (LD4) - PC_7, //D50 - PC_6, //D51 - PB_15, //D52 - PB_14, //D53 - PB_13, //D54 + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PF_0, //D24 + PF_1, //D25 // Duplicated pins in order to be aligned with PinMap_ADC - PC_0, //D55/A0 = D5 - PC_1, //D56/A1 = D6 - PC_2, //D57/A2 = D7 - PC_3, //D58/A3 = D8 - PA_0, //D59/A4 = D9 - PA_1, //D60/A5 = D10 - PA_2, //D61/A6 = D11 - PA_3, //D62/A7 = D12 - PA_4, //D63/A8 = D15 - PA_5, //D64/A9 = D16 - PA_6, //D65/A10= D17 - PA_7, //D66/A11= D18 - PC_4, //D67/A12 = D19 - PC_5, //D68/A13 = D20 - PB_0, //D69/A14 = D21 - PB_1 //D70/A15 = D22 + PA_0, //D26/A0 = D0 + PA_1, //D27/A1 = D1 + PA_2, //D28/A2 = D2 + PA_3, //D29/A3 = D3 + PA_4, //D30/A4 = D4 + PA_5, //D31/A5 = D5 + PA_6, //D32/A6 = D6 + PA_7, //D33/A7 = D7 + PB_0, //D34/A8 = D16 + PB_1, //D35/A9 = D17 }; #ifdef __cplusplus diff --git a/variants/GENERIC_F030K6/variant.h b/variants/GENERIC_F030K6/variant.h index 4c4da24087..5d8be65f97 100644 --- a/variants/GENERIC_F030K6/variant.h +++ b/variants/GENERIC_F030K6/variant.h @@ -47,109 +47,69 @@ extern "C"{ extern const PinName digitalPin[]; enum { - //P1 connector Right side (bottom view) - PC13, //D0 - PC14, //D1 - PC15, //D2 - PF0, //D3 - PF1, //D4 - PC0, //D5 - PC1, //D6 - PC2, //D7 - PC3, //D8 - PA0, //D9 - USER_BTN - PA1, //D10 - PA2, //D11 - PA3, //D12 - PF4, //D13 - PF5, //D14 - PA4, //D15 - PA5, //D16 - PA6, //D17 - PA7, //D18 - PC4, //D19 - PC5, //D20 - PB0, //D21 - PB1, //D22 - PB2, //D23 - PB10, //D24 - PB11, //D25 - PB12, //D26 - //P2 connector Left side (bottom view) - PB9, //D27 - PB8, //D28 - PB7, //D29 - PB6, //D30 - PB5, //D31 - PB4, //D32 - PB3, //D33 - PD2, //D34 - PC12, //D35 - PC11, //D36 - PC10, //D37 - PA15, //D38 - PA14, //D39 - PF7, //D40 - PF6, //D41 - PA13, //D42 - PA12, //D43 - PA11, //D44 - PA10, //D45 - PA9, //D46 - PA8, //D47 - PC9, //D48 - LED_GREEN (LD3) - PC8, //D49 - LED_BLUE (LD4) - PC7, //D50 - PC6, //D51 - PB15, //D52 - PB14, //D53 - PB13, //D54 + PA_0, //D0 + PA_1, //D1 + PA_2, //D2 + PA_3, //D3 + PA_4, //D4 + PA_5, //D5 + PA_6, //D6 + PA_7, //D7 + PA_8, //D8 + PA_9, //D9 + PA_10, //D10 + PA_11, //D11 + PA_12, //D12 + PA_13, //D13 + PA_14, //D14 + PA_15, //D15 + PB_0, //D16 + PB_1, //D17 + PB_2, //D18 + PB_3, //D19 + PB_4, //D20 + PB_5, //D21 + PB_6, //D22 + PB_7, //D23 + PF_0, //D24 + PF_1, //D25 // Duplicated pins in order to be aligned with PinMap_ADC - PC_0_A, //D55/A0 = D5 - PC_1_A, //D56/A1 = D6 - PC_2_A, //D57/A2 = D7 - PC_3_A, //D58/A3 = D8 - PA_0_A, //D59/A4 = D9 - PA_1_A, //D60/A5 = D10 - PA_2_A, //D61/A6 = D11 - PA_3_A, //D62/A7 = D12 - PA_4_A, //D63/A8 = D15 - PA_5_A, //D64/A9 = D16 - PA_6_A, //D65/A10 = D17 - PA_7_A, //D66/A11 = D18 - PC_4_A, //D67/A12 = D19 - PC_5_A, //D68/A13 = D20 - PB_0_A, //D69/A14 = D21 - PB_1_A, //D70/A15 = D22 + PA_0_A, //D26/A0 = D0 + PA_1_A, //D27/A1 = D1 + PA_2_A, //D28/A2 = D2 + PA_3_A, //D29/A3 = D3 + PA_4_A, //D30/A4 = D4 + PA_5_A, //D31/A5 = D5 + PA_6_A, //D32/A6 = D6 + PA_7_A, //D33/A7 = D7 + PB_0_A, //D34/A8 = D16 + PB_1_A, //D35/A9 = D17 PEND }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 71 +#define NUM_DIGITAL_PINS 36 // This must be a literal with a value less than or equal to to MAX_ANALOG_INPUTS -#define NUM_ANALOG_INPUTS 16 -#define NUM_ANALOG_FIRST 55 +#define NUM_ANALOG_INPUTS 10 +#define NUM_ANALOG_FIRST 26 // SPI definitions // SPI1 is used #define PIN_SPI_SS PA4 -#define PIN_SPI_SS1 PC4 -#define PIN_SPI_SS2 PB12 -#define PIN_SPI_SS3 PC6 #define PIN_SPI_MOSI PA7 #define PIN_SPI_MISO PA6 #define PIN_SPI_SCK PA5 // I2C Definitions // I2C1 is used -#define PIN_WIRE_SDA PB9 -#define PIN_WIRE_SCL PB8 +#define PIN_WIRE_SDA PB7 +#define PIN_WIRE_SCL PB6 // Timer Definitions //Do not use timer used by PWM pins when possible. See PinMap_PWM. -// STM32F030x6 does not have basic timers. So we have to use TIM14 (General purpose) +// STM32F030K6 does not have basic timers. So we have to use TIM14 (General purpose) #define TIMER_TONE TIM14 //Do not use basic timer: OC is required From e429d229aae08a5685e56216bdaa0b00cbe79ebc Mon Sep 17 00:00:00 2001 From: Claudio Hediger Date: Thu, 16 Aug 2018 08:25:30 +0200 Subject: [PATCH 3/4] - changed enum Pin-Naming from Px_x to Pxx due to error --- variants/GENERIC_F030K6/variant.h | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/variants/GENERIC_F030K6/variant.h b/variants/GENERIC_F030K6/variant.h index 5d8be65f97..6cd6eae0fd 100644 --- a/variants/GENERIC_F030K6/variant.h +++ b/variants/GENERIC_F030K6/variant.h @@ -47,43 +47,43 @@ extern "C"{ extern const PinName digitalPin[]; enum { - PA_0, //D0 - PA_1, //D1 - PA_2, //D2 - PA_3, //D3 - PA_4, //D4 - PA_5, //D5 - PA_6, //D6 - PA_7, //D7 - PA_8, //D8 - PA_9, //D9 - PA_10, //D10 - PA_11, //D11 - PA_12, //D12 - PA_13, //D13 - PA_14, //D14 - PA_15, //D15 - PB_0, //D16 - PB_1, //D17 - PB_2, //D18 - PB_3, //D19 - PB_4, //D20 - PB_5, //D21 - PB_6, //D22 - PB_7, //D23 - PF_0, //D24 - PF_1, //D25 + PA0, //D0 + PA1, //D1 + PA2, //D2 + PA3, //D3 + PA4, //D4 + PA5, //D5 + PA6, //D6 + PA7, //D7 + PA8, //D8 + PA9, //D9 + PA10, //D10 + PA11, //D11 + PA12, //D12 + PA13, //D13 + PA14, //D14 + PA15, //D15 + PB0, //D16 + PB1, //D17 + PB2, //D18 + PB3, //D19 + PB4, //D20 + PB5, //D21 + PB6, //D22 + PB7, //D23 + PF0, //D24 + PF1, //D25 // Duplicated pins in order to be aligned with PinMap_ADC - PA_0_A, //D26/A0 = D0 - PA_1_A, //D27/A1 = D1 - PA_2_A, //D28/A2 = D2 - PA_3_A, //D29/A3 = D3 - PA_4_A, //D30/A4 = D4 - PA_5_A, //D31/A5 = D5 - PA_6_A, //D32/A6 = D6 - PA_7_A, //D33/A7 = D7 - PB_0_A, //D34/A8 = D16 - PB_1_A, //D35/A9 = D17 + PA0_A, //D26/A0 = D0 + PA1_A, //D27/A1 = D1 + PA2_A, //D28/A2 = D2 + PA3_A, //D29/A3 = D3 + PA4_A, //D30/A4 = D4 + PA5_A, //D31/A5 = D5 + PA6_A, //D32/A6 = D6 + PA7_A, //D33/A7 = D7 + PB0_A, //D34/A8 = D16 + PB1_A, //D35/A9 = D17 PEND }; From 93f1fa68813fe538c317ada69fe29fd830fc75f2 Mon Sep 17 00:00:00 2001 From: Claudio Hediger Date: Thu, 16 Aug 2018 08:27:10 +0200 Subject: [PATCH 4/4] Re-Added -Os as optimization option --- boards.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/boards.txt b/boards.txt index a7774d79ea..7b248a8f9b 100644 --- a/boards.txt +++ b/boards.txt @@ -752,6 +752,7 @@ GenF103.menu.opt.ogstd=Debug (-g) GenF103.menu.opt.ogstd.build.flags.optimize=-g -Og GenF103.menu.opt.ogstd.build.flags.ldspecs= +GenF030.menu.opt.osstd=Smallest (-Os default) GenF030.menu.opt.oslto=Smallest (-Os) with LTO GenF030.menu.opt.oslto.build.flags.optimize=-Os -flto GenF030.menu.opt.oslto.build.flags.ldspecs=-flto