Skip to content

Commit a30800d

Browse files
committed
Add new examples with STM32Cube framework
1 parent 18f010d commit a30800d

File tree

12 files changed

+556
-0
lines changed

12 files changed

+556
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pioenvs
2+
.clang_complete
3+
.gcc-flags.json
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Continuous Integration (CI) is the practice, in software
2+
# engineering, of merging all developer working copies with a shared mainline
3+
# several times a day < http://docs.platformio.org/page/ci/index.html >
4+
#
5+
# Documentation:
6+
#
7+
# * Travis CI Embedded Builds with PlatformIO
8+
# < https://docs.travis-ci.com/user/integration/platformio/ >
9+
#
10+
# * PlatformIO integration with Travis CI
11+
# < http://docs.platformio.org/page/ci/travis.html >
12+
#
13+
# * User Guide for `platformio ci` command
14+
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
15+
#
16+
#
17+
# Please choose one of the following templates (proposed below) and uncomment
18+
# it (remove "# " before each line) or use own configuration according to the
19+
# Travis CI documentation (see above).
20+
#
21+
22+
23+
#
24+
# Template #1: General project. Test it using existing `platformio.ini`.
25+
#
26+
27+
# language: python
28+
# python:
29+
# - "2.7"
30+
#
31+
# sudo: false
32+
# cache:
33+
# directories:
34+
# - "~/.platformio"
35+
#
36+
# install:
37+
# - pip install -U platformio
38+
#
39+
# script:
40+
# - platformio run
41+
42+
43+
#
44+
# Template #2: The project is intended to by used as a library with examples
45+
#
46+
47+
# language: python
48+
# python:
49+
# - "2.7"
50+
#
51+
# sudo: false
52+
# cache:
53+
# directories:
54+
# - "~/.platformio"
55+
#
56+
# env:
57+
# - PLATFORMIO_CI_SRC=path/to/test/file.c
58+
# - PLATFORMIO_CI_SRC=examples/file.ino
59+
# - PLATFORMIO_CI_SRC=path/to/test/directory
60+
#
61+
# install:
62+
# - pip install -U platformio
63+
#
64+
# script:
65+
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.. Copyright 2014-present PlatformIO <[email protected]>
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
http://www.apache.org/licenses/LICENSE-2.0
6+
Unless required by applicable law or agreed to in writing, software
7+
distributed under the License is distributed on an "AS IS" BASIS,
8+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
See the License for the specific language governing permissions and
10+
limitations under the License.
11+
12+
How to build PlatformIO based project
13+
=====================================
14+
15+
1. `Install PlatformIO Core <http://docs.platformio.org/page/core.html>`_
16+
2. Download `development platform with examples <https://github.com/platformio/platform-ststm32/archive/develop.zip>`_
17+
3. Extract ZIP archive
18+
4. Run these commands:
19+
20+
.. code-block:: bash
21+
22+
# Change directory to example
23+
> cd platformio-examples/stm32/stm32cube-hal-blink
24+
25+
# Build project
26+
> platformio run
27+
28+
# Upload firmware
29+
> platformio run --target upload
30+
31+
# Build specific environment
32+
> platformio run -e nucleo_f401re
33+
34+
# Upload firmware for the specific environment
35+
> platformio run -e nucleo_f401re --target upload
36+
37+
# Clean build files
38+
> platformio run --target clean
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
This directory is intended for the project specific (private) libraries.
3+
PlatformIO will compile them to static libraries and link to executable file.
4+
5+
The source code of each library should be placed in separate directory, like
6+
"lib/private_lib/[here are source files]".
7+
8+
For example, see how can be organized `Foo` and `Bar` libraries:
9+
10+
|--lib
11+
| |--Bar
12+
| | |--docs
13+
| | |--examples
14+
| | |--src
15+
| | |- Bar.c
16+
| | |- Bar.h
17+
| |--Foo
18+
| | |- Foo.c
19+
| | |- Foo.h
20+
| |- readme.txt --> THIS FILE
21+
|- platformio.ini
22+
|--src
23+
|- main.c
24+
25+
Then in `src/main.c` you should use:
26+
27+
#include <Foo.h>
28+
#include <Bar.h>
29+
30+
// rest H/C/CPP code
31+
32+
PlatformIO will find your libraries automatically, configure preprocessor's
33+
include paths and build them.
34+
35+
See additional options for PlatformIO Library Dependency Finder `lib_*`:
36+
37+
http://docs.platformio.org/page/projectconf.html#lib-install
38+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
; PlatformIO Project Configuration File
2+
;
3+
; Build options: build flags, source filter, extra scripting
4+
; Upload options: custom port, speed and extra flags
5+
; Library options: dependencies, extra library storages
6+
;
7+
; Please visit documentation for the other options and examples
8+
; http://docs.platformio.org/page/projectconf.html
9+
10+
[env:nucleo_f072rb]
11+
platform = ststm32
12+
framework = stm32cube
13+
board = nucleo_f072rb
14+
build_flags = -DF0
15+
16+
[env:nucleo_f103rb]
17+
platform = ststm32
18+
framework = stm32cube
19+
board = nucleo_f103rb
20+
build_flags = -DF1
21+
22+
[env:nucleo_f207zg]
23+
platform = ststm32
24+
framework = stm32cube
25+
board = nucleo_f207zg
26+
build_flags = -DF2
27+
28+
[env:nucleo_f334r8]
29+
platform = ststm32
30+
framework = stm32cube
31+
board = nucleo_f334r8
32+
build_flags = -DF3
33+
34+
[env:nucleo_f401re]
35+
platform = ststm32
36+
framework = stm32cube
37+
board = nucleo_f401re
38+
build_flags = -DF4
39+
40+
[env:nucleo_f746zg]
41+
platform = ststm32
42+
framework = stm32cube
43+
board = nucleo_f746zg
44+
build_flags = -DF7
45+
46+
[env:nucleo_l053r8]
47+
platform = ststm32
48+
framework = stm32cube
49+
board = nucleo_l053r8
50+
build_flags = -DL0
51+
52+
[env:nucleo_l152re]
53+
platform = ststm32
54+
framework = stm32cube
55+
board = nucleo_l152re
56+
build_flags = -DL1
57+
58+
[env:nucleo_l476rg]
59+
platform = ststm32
60+
framework = stm32cube
61+
board = nucleo_l476rg
62+
build_flags = -DL4
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#if F0
2+
#include "stm32f0xx_hal.h"
3+
#elif F1
4+
#include "stm32f1xx_hal.h"
5+
#elif F2
6+
#include "stm32f2xx_hal.h"
7+
#elif F3
8+
#include "stm32f3xx_hal.h"
9+
#elif F4
10+
#include "stm32f4xx_hal.h"
11+
#elif F7
12+
#include "stm32f7xx_hal.h"
13+
#elif L0
14+
#include "stm32l0xx_hal.h"
15+
#elif L1
16+
#include "stm32l1xx_hal.h"
17+
#elif L4
18+
#include "stm32l4xx_hal.h"
19+
#else
20+
#error "Unsupported STM32 Family"
21+
#endif
22+
23+
#define LED_PIN GPIO_PIN_5
24+
#define LED_GPIO_PORT GPIOA
25+
#define LED_GPIO_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
26+
27+
int main(void)
28+
{
29+
HAL_Init();
30+
31+
LED_GPIO_CLK_ENABLE();
32+
33+
GPIO_InitTypeDef GPIO_InitStruct;
34+
35+
GPIO_InitStruct.Pin = LED_PIN;
36+
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
37+
GPIO_InitStruct.Pull = GPIO_PULLUP;
38+
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
39+
HAL_GPIO_Init(LED_GPIO_PORT, &GPIO_InitStruct);
40+
41+
while (1)
42+
{
43+
HAL_GPIO_TogglePin(LED_GPIO_PORT, LED_PIN);
44+
45+
HAL_Delay(1000);
46+
}
47+
}
48+
49+
void SysTick_Handler(void)
50+
{
51+
HAL_IncTick();
52+
}
53+
54+
void NMI_Handler(void)
55+
{
56+
}
57+
58+
void HardFault_Handler(void)
59+
{
60+
while (1) {}
61+
}
62+
63+
64+
void MemManage_Handler(void)
65+
{
66+
while (1) {}
67+
}
68+
69+
void BusFault_Handler(void)
70+
{
71+
while (1) {}
72+
}
73+
74+
void UsageFault_Handler(void)
75+
{
76+
while (1) {}
77+
}
78+
79+
void SVC_Handler(void)
80+
{
81+
}
82+
83+
84+
void DebugMon_Handler(void)
85+
{
86+
}
87+
88+
void PendSV_Handler(void)
89+
{
90+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.pioenvs
2+
.clang_complete
3+
.gcc-flags.json
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Continuous Integration (CI) is the practice, in software
2+
# engineering, of merging all developer working copies with a shared mainline
3+
# several times a day < http://docs.platformio.org/page/ci/index.html >
4+
#
5+
# Documentation:
6+
#
7+
# * Travis CI Embedded Builds with PlatformIO
8+
# < https://docs.travis-ci.com/user/integration/platformio/ >
9+
#
10+
# * PlatformIO integration with Travis CI
11+
# < http://docs.platformio.org/page/ci/travis.html >
12+
#
13+
# * User Guide for `platformio ci` command
14+
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
15+
#
16+
#
17+
# Please choose one of the following templates (proposed below) and uncomment
18+
# it (remove "# " before each line) or use own configuration according to the
19+
# Travis CI documentation (see above).
20+
#
21+
22+
23+
#
24+
# Template #1: General project. Test it using existing `platformio.ini`.
25+
#
26+
27+
# language: python
28+
# python:
29+
# - "2.7"
30+
#
31+
# sudo: false
32+
# cache:
33+
# directories:
34+
# - "~/.platformio"
35+
#
36+
# install:
37+
# - pip install -U platformio
38+
#
39+
# script:
40+
# - platformio run
41+
42+
43+
#
44+
# Template #2: The project is intended to by used as a library with examples
45+
#
46+
47+
# language: python
48+
# python:
49+
# - "2.7"
50+
#
51+
# sudo: false
52+
# cache:
53+
# directories:
54+
# - "~/.platformio"
55+
#
56+
# env:
57+
# - PLATFORMIO_CI_SRC=path/to/test/file.c
58+
# - PLATFORMIO_CI_SRC=examples/file.ino
59+
# - PLATFORMIO_CI_SRC=path/to/test/directory
60+
#
61+
# install:
62+
# - pip install -U platformio
63+
#
64+
# script:
65+
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N

0 commit comments

Comments
 (0)