diff --git a/boards/bluepill_f103c8.json b/boards/bluepill_f103c8.json index 4ac8643a..cce7286f 100644 --- a/boards/bluepill_f103c8.json +++ b/boards/bluepill_f103c8.json @@ -2,7 +2,7 @@ "build": { "core": "stm32", "cpu": "cortex-m3", - "extra_flags": "-DSTM32F1 -DSTM32F103xB -DARDUINO_BLUEPILL_F103C8", + "extra_flags": "-DSTM32F1 -DSTM32F10X_MD -DSTM32F103xB -DARDUINO_BLUEPILL_F103C8", "f_cpu": "72000000L", "hwids": [ [ @@ -35,7 +35,8 @@ "mbed", "cmsis", "libopencm3", - "stm32cube" + "stm32cube", + "spl" ], "name": "BluePill F103C8", "upload": { diff --git a/boards/genericSTM32L053C8.json b/boards/genericSTM32L053C8.json new file mode 100644 index 00000000..363a12b6 --- /dev/null +++ b/boards/genericSTM32L053C8.json @@ -0,0 +1,41 @@ +{ + "build": { + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32L053xx", + "f_cpu": "32000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32l053c8t6", + "variant": "STM_L053C8" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32L053C8", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32l0_dual_bank", + "svd_path": "STM32L053x.svd" + }, + "frameworks": [ + "arduino" + ], + "name": "STM32L053C8", + "upload": { + "maximum_ram_size": 8192, + "maximum_size": 65536, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial", + "dfu" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l053c8.html", + "vendor": "ST" +} diff --git a/boards/genericSTM32L082CZ.json b/boards/genericSTM32L082CZ.json new file mode 100644 index 00000000..3d73a9a0 --- /dev/null +++ b/boards/genericSTM32L082CZ.json @@ -0,0 +1,43 @@ +{ + "build": { + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32L082xx", + "f_cpu": "32000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32l080cz", + "variant": "STM_L082CZ" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32L080CZ", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32l0_dual_bank", + "svd_path": "STM32L082x.svd" + }, + "frameworks": [ + "arduino", + "mbed", + "stm32cube" + ], + "name": "STM32L082CZ", + "upload": { + "maximum_ram_size": 20480, + "maximum_size": 196608, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial", + "dfu" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l082cz.html", + "vendor": "ST" +} diff --git a/boards/genericSTM32L082KZ.json b/boards/genericSTM32L082KZ.json new file mode 100644 index 00000000..de868b8c --- /dev/null +++ b/boards/genericSTM32L082KZ.json @@ -0,0 +1,43 @@ +{ + "build": { + "cpu": "cortex-m0plus", + "extra_flags": "-DSTM32L082xx", + "f_cpu": "32000000L", + "framework_extra_flags": { + "arduino": "-D__CORTEX_SC=0" + }, + "mcu": "stm32l080kzt6", + "variant": "STM_L082KZ" + }, + "debug": { + "default_tools": [ + "stlink" + ], + "jlink_device": "STM32L080KZ", + "onboard_tools": [ + "stlink" + ], + "openocd_target": "stm32l0_dual_bank", + "svd_path": "STM32L082x.svd" + }, + "frameworks": [ + "arduino", + "mbed", + "stm32cube" + ], + "name": "STM32L082KZ", + "upload": { + "maximum_ram_size": 20480, + "maximum_size": 196608, + "protocol": "stlink", + "protocols": [ + "jlink", + "stlink", + "blackmagic", + "serial", + "dfu" + ] + }, + "url": "https://www.st.com/en/microcontrollers-microprocessors/stm32l082kz.html", + "vendor": "ST" +} diff --git a/examples/spl-bluepill-blink/.gitignore b/examples/spl-bluepill-blink/.gitignore new file mode 100644 index 00000000..6c69f4cc --- /dev/null +++ b/examples/spl-bluepill-blink/.gitignore @@ -0,0 +1,2 @@ +.pioenvs +.piolibdeps diff --git a/examples/spl-bluepill-blink/.travis.yml b/examples/spl-bluepill-blink/.travis.yml new file mode 100644 index 00000000..7c486f18 --- /dev/null +++ b/examples/spl-bluepill-blink/.travis.yml @@ -0,0 +1,67 @@ +# Continuous Integration (CI) is the practice, in software +# engineering, of merging all developer working copies with a shared mainline +# several times a day < https://docs.platformio.org/page/ci/index.html > +# +# Documentation: +# +# * Travis CI Embedded Builds with PlatformIO +# < https://docs.travis-ci.com/user/integration/platformio/ > +# +# * PlatformIO integration with Travis CI +# < https://docs.platformio.org/page/ci/travis.html > +# +# * User Guide for `platformio ci` command +# < https://docs.platformio.org/page/userguide/cmd_ci.html > +# +# +# Please choose one of the following templates (proposed below) and uncomment +# it (remove "# " before each line) or use own configuration according to the +# Travis CI documentation (see above). +# + + +# +# Template #1: General project. Test it using existing `platformio.ini`. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio run + + +# +# Template #2: The project is intended to be used as a library with examples. +# + +# language: python +# python: +# - "2.7" +# +# sudo: false +# cache: +# directories: +# - "~/.platformio" +# +# env: +# - PLATFORMIO_CI_SRC=path/to/test/file.c +# - PLATFORMIO_CI_SRC=examples/file.ino +# - PLATFORMIO_CI_SRC=path/to/test/directory +# +# install: +# - pip install -U platformio +# - platformio update +# +# script: +# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N diff --git a/examples/spl-bluepill-blink/README.rst b/examples/spl-bluepill-blink/README.rst new file mode 100644 index 00000000..666fa9d8 --- /dev/null +++ b/examples/spl-bluepill-blink/README.rst @@ -0,0 +1,38 @@ +.. Copyright 2014-present PlatformIO + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +How to build PlatformIO based project +===================================== + +1. `Install PlatformIO Core `_ +2. Download `development platform with examples `_ +3. Extract ZIP archive +4. Run these commands: + +.. code-block:: bash + + # Change directory to example + > cd platform-ststm32/examples/spl-blink + + # Build project + > platformio run + + # Upload firmware + > platformio run --target upload + + # Build specific environment + > platformio run -e bluepill_f103c8 + + # Upload firmware for the specific environment + > platformio run -e bluepill_f103c8 --target upload + + # Clean build files + > platformio run --target clean diff --git a/examples/spl-bluepill-blink/include/README b/examples/spl-bluepill-blink/include/README new file mode 100644 index 00000000..194dcd43 --- /dev/null +++ b/examples/spl-bluepill-blink/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/examples/spl-bluepill-blink/lib/README b/examples/spl-bluepill-blink/lib/README new file mode 100644 index 00000000..6debab1e --- /dev/null +++ b/examples/spl-bluepill-blink/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/examples/spl-bluepill-blink/platformio.ini b/examples/spl-bluepill-blink/platformio.ini new file mode 100644 index 00000000..4d928072 --- /dev/null +++ b/examples/spl-bluepill-blink/platformio.ini @@ -0,0 +1,13 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter, extra scripting +; Upload options: custom port, speed and extra flags +; Library options: dependencies, extra library storages +; +; Please visit documentation for the other options and examples +; http://docs.platformio.org/page/projectconf.html + +[env:bluepill_f103c8] +platform = ststm32 +board = bluepill_f103c8 +framework = spl \ No newline at end of file diff --git a/examples/spl-bluepill-blink/src/main.c b/examples/spl-bluepill-blink/src/main.c new file mode 100644 index 00000000..d34450d1 --- /dev/null +++ b/examples/spl-bluepill-blink/src/main.c @@ -0,0 +1,113 @@ +#ifndef STM32F1 +#error "This example is for an STM32F1 series board!" +#endif +#include +#include +#include + +/* blinky for PC_13 (on-board red LED) */ +#define LEDPORT (GPIOC) +#define LEDPIN (GPIO_Pin_13) +#define ENABLE_GPIO_CLOCK (RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE)) +/* toggle time */ +#define DELAY_TIME_MILLIS 1000 + +/* variable keeps track of timing delay */ +static __IO uint32_t TimingDelay; + +/** + * @brief Inserts a delay time. + * @param nTime: specifies the delay time length, in milliseconds. + * @retval None + */ +void Delay(__IO uint32_t nTime) { + TimingDelay = nTime; + + while (TimingDelay != 0); +} + +void TimingDelay_Decrement(void) { + if (TimingDelay != 0x00) { + TimingDelay--; + } +} + +/* system entry point */ +int main(void) { + //setup SysTick for 1 millisecond interrupts + if (SysTick_Config(SystemCoreClock / 1000)) { + /* Capture error */ + while (1); + } + /* gpio init struct */ + GPIO_InitTypeDef gpio; + /* enable clock GPIO */ + ENABLE_GPIO_CLOCK; + /* use LED pin */ + gpio.GPIO_Pin = LEDPIN; + /* mode: output */ + gpio.GPIO_Mode = GPIO_Mode_Out_PP; + gpio.GPIO_Speed = GPIO_Speed_50MHz; + /* apply configuration */ + GPIO_Init(LEDPORT, &gpio); + /* main program loop */ + for (;;) { + /* set led on */ + GPIO_SetBits(LEDPORT, LEDPIN); + /* delay */ + Delay(DELAY_TIME_MILLIS); + /* clear led */ + GPIO_ResetBits(LEDPORT, LEDPIN); + /* delay */ + Delay(DELAY_TIME_MILLIS); + } + + /* never reached */ + return 0; +} + +/******************************************************************************/ +/* Cortex-M3 Processor Exceptions Handlers */ +/******************************************************************************/ + +void NMI_Handler(void) { +} + +void HardFault_Handler(void) { + /* Go to infinite loop when Hard Fault exception occurs */ + while (1) { + } +} + +void MemManage_Handler(void) { + /* Go to infinite loop when Memory Manage exception occurs */ + while (1) { + } +} + +void BusFault_Handler(void) { + /* Go to infinite loop when Bus Fault exception occurs */ + while (1) { + } +} + +void UsageFault_Handler(void) { + /* Go to infinite loop when Usage Fault exception occurs */ + while (1) { + } +} + +void SVC_Handler(void) { +} + +void DebugMon_Handler(void) { +} + +void PendSV_Handler(void) { +} + +void SysTick_Handler(void) { + //decrement timing delay here + TimingDelay_Decrement(); +} + diff --git a/examples/spl-bluepill-blink/test/README b/examples/spl-bluepill-blink/test/README new file mode 100644 index 00000000..df5066e6 --- /dev/null +++ b/examples/spl-bluepill-blink/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PIO Unit Testing and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PIO Unit Testing: +- https://docs.platformio.org/page/plus/unit-testing.html