Skip to content

Commit 79b15e3

Browse files
karlpMaureenHelm
authored andcommitted
boards: add stm32l1 discovery
Tested apps: hello_world, blinky Tested peripherals: UART, SPI Signed-off-by: Karl Palsson <[email protected]>
1 parent e3fdf47 commit 79b15e3

File tree

12 files changed

+448
-0
lines changed

12 files changed

+448
-0
lines changed

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
/boards/arm/olimexino_stm32/ @ydamigos
8686
/boards/arm/sensortile_box/ @avisconti
8787
/boards/arm/steval_fcu001v1/ @Navin-Sankar
88+
/boards/arm/stm32l1_disco/ @karlp
8889
/boards/arm/stm32*_disco/ @erwango
8990
/boards/arm/stm32f3_disco/ @ydamigos
9091
/boards/arm/stm32*_eval/ @erwango
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
if(CONFIG_PINMUX)
4+
zephyr_library()
5+
zephyr_library_sources(pinmux.c)
6+
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
7+
endif()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Kconfig - board configuration
2+
#
3+
# Copyright (c) 2019 eTactica ehf
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
config BOARD_STM32L1_DISCO
9+
bool "STM32L1DISCOVERY Development Board"
10+
depends on SOC_STM32L151XB
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Kconfig - board configuration
2+
#
3+
# Copyright (c) 2019 eTactica ehf
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if BOARD_STM32L1_DISCO
9+
10+
config BOARD
11+
default "stm32l1_disco"
12+
13+
if UART_CONSOLE
14+
15+
config UART_1
16+
default y
17+
18+
endif # UART_CONSOLE
19+
20+
if I2C
21+
22+
config I2C_1
23+
default y
24+
25+
config I2C_2
26+
default y
27+
28+
endif # I2C
29+
30+
if SPI
31+
32+
config SPI_1
33+
default y
34+
35+
config SPI_2
36+
default y
37+
38+
endif # SPI
39+
40+
41+
endif # BOARD_STM32L1_DISCO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
board_runner_args(jlink "--device=STM32L151RB" "--speed=4000")
4+
5+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
6+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
152 KB
Loading
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
.. _stm32l1_disco_board:
2+
3+
ST STM32LDISCOVERY and 32L152CDISCOVERY
4+
#######################################
5+
6+
Overview
7+
********
8+
9+
The two generations of the STM32L1 Discovery development boards come with
10+
an integrated ST-LINK/V2 debugger and programmer. The boards have a
11+
24-segment LCD and a touch slider, along with two user LEDs and a user button.
12+
Support circuitry for measuring power consumption is also available.
13+
It also comes with a comprehensive STM32 software HAL library and various
14+
packaged software examples.
15+
16+
There
17+
are two variants of the board:
18+
19+
- STM32LDISCOVERY targets STM32L152RBT6, with 128K flash, 16K RAM
20+
- 32L152CDISCOVERY targets STM32L152RCT6, with 256K flash, 32K RAM
21+
22+
The STM32LDISCOVERY is no longer sold, but was widely available. The current
23+
configuration assumes only 128K flash and 16K RAM, so it builds and runs
24+
on both variants out of the box.
25+
26+
.. image:: img/stm32l1_disco.jpg
27+
:width: 564px
28+
:height: 600px
29+
:align: center
30+
:alt: STM32LDISCOVERY
31+
32+
More information about the board can be found at the `STM32LDISCOVERY website`_.
33+
34+
Hardware
35+
********
36+
37+
The STM32 Discovery board features:
38+
39+
- On-board ST-LINK/V2 with selection mode switch to use the kit as a standalone
40+
ST-LINK/V2 (with SWD connector for programming and debugging)
41+
- Board power supply: through USB bus or from an external 5 V supply voltage
42+
- External application power supply: 3 V and 5 V
43+
- Four LEDs:
44+
45+
- LD1 (red) for 3.3 V power on
46+
- LD2 (red/green) for USB communication
47+
- LD3 (green) for PC9 output
48+
- LD4 (blue) for PC8 output
49+
- Two push buttons (user and reset)
50+
- Extension header for all LQFP64 I/Os for quick connection to prototyping board
51+
and easy probing
52+
53+
More information about STM32L151x can be found in the `STM32L1x reference manual`_.
54+
55+
Supported Features
56+
==================
57+
58+
The Zephyr stm32l1_disco board configuration supports the following hardware features:
59+
60+
.. list-table:: Supported hardware
61+
:header-rows: 1
62+
63+
* - Interface
64+
- Controller
65+
- Driver/component
66+
* - NVIC
67+
- on-chip
68+
- nested vector interrupt controller
69+
* - UART
70+
- on-chip
71+
- serial port-polling
72+
serial port-interrupt
73+
* - PINMUX
74+
- on-chip
75+
- pinmux
76+
* - GPIO
77+
- on-chip
78+
- gpio
79+
* - CLOCK
80+
- on-chip
81+
- reset and clock control
82+
* - FLASH
83+
- on-chip
84+
- flash memory
85+
* - WATCHDOG
86+
- on-chip
87+
- window watchdog
88+
* - I2C
89+
- on-chip
90+
- i2c
91+
* - SPI
92+
- on-chip
93+
- spi
94+
95+
Other hardware features are not yet supported in this Zephyr port.
96+
97+
The default configuration can be found in the defconfig file:
98+
``boards/arm/stm32l1_disco/stm32l1_disco_defconfig``
99+
100+
Connections and IOs
101+
===================
102+
103+
Each of the GPIO pins can be configured by software as output (push-pull or open-drain), as
104+
input (with or without pull-up or pull-down), or as peripheral alternate function. Most of the
105+
GPIO pins are shared with digital or analog alternate functions. All GPIOs are high current
106+
capable except for analog inputs.
107+
108+
Default Zephyr Peripheral Mapping:
109+
----------------------------------
110+
111+
.. rst-class:: rst-columns
112+
113+
- UART_1_TX : PA9
114+
- UART_1_RX : PA10
115+
- UART_2_TX : PA2
116+
- UART_2_RX : PA3
117+
- I2C1_SCL : PB6
118+
- I2C1_SDA : PB7
119+
- I2C2_SCL : PB10
120+
- I2C2_SDA : PB11
121+
- SPI1_NSS : PA4
122+
- SPI1_SCK : PA5
123+
- SPI1_MISO : PA6
124+
- SPI1_MOSI : PA7
125+
- SPI2_NSS : PB12
126+
- SPI2_SCK : PB13
127+
- SPI2_MISO : PB14
128+
- SPI2_MOSI : PB15
129+
130+
For mode details please refer to `STM32L1DISCOVERY board User Manual`_.
131+
132+
Programming and Debugging
133+
*************************
134+
135+
Applications for the ``stm32l1_disco`` board configuration can be built and
136+
flashed in the usual way (see :ref:`build_an_application` and
137+
:ref:`application_run` for more details).
138+
139+
Flashing
140+
========
141+
142+
STM32L1DISCOVERY board includes an ST-LINK/V2 embedded debug tool interface.
143+
This interface is supported by the openocd version included in the Zephyr SDK.
144+
145+
Flashing an application
146+
-----------------------
147+
148+
Here is an example for the :ref:`blinky-sample` application.
149+
150+
.. zephyr-app-commands::
151+
:zephyr-app: samples/basic/blinky
152+
:board: stm32l1_disco
153+
:goals: build flash
154+
155+
You will see the LED blinking every second.
156+
157+
Debugging
158+
=========
159+
160+
You can debug an application in the usual way. Here is an example for the
161+
:ref:`blinky-sample` application.
162+
163+
.. zephyr-app-commands::
164+
:zephyr-app: samples/basic/blinky
165+
:board: stm32l1_disco
166+
:maybe-skip-config:
167+
:goals: debug
168+
169+
References
170+
**********
171+
172+
.. target-notes::
173+
174+
.. _STM32LDISCOVERY website:
175+
https://www.st.com/en/evaluation-tools/32l152cdiscovery.html
176+
177+
.. _STM32L1x reference manual:
178+
https://www.st.com/resource/en/reference_manual/cd00240193.pdf
179+
180+
.. _STM32L1DISCOVERY board User Manual:
181+
https://www.st.com/resource/en/user_manual/dm00027954.pdf

boards/arm/stm32l1_disco/pinmux.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2019 eTactica ehf
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <kernel.h>
8+
#include <device.h>
9+
#include <init.h>
10+
#include <drivers/pinmux.h>
11+
#include <sys/sys_io.h>
12+
13+
#include <pinmux/stm32/pinmux_stm32.h>
14+
15+
static const struct pin_config pinconf[] = {
16+
#ifdef CONFIG_UART_1
17+
{STM32_PIN_PA9, STM32L1X_PINMUX_FUNC_PA9_USART1_TX},
18+
{STM32_PIN_PA10, STM32L1X_PINMUX_FUNC_PA10_USART1_RX},
19+
#endif /* CONFIG_UART_1 */
20+
#ifdef CONFIG_UART_2
21+
{STM32_PIN_PA2, STM32L1X_PINMUX_FUNC_PA2_USART2_TX},
22+
{STM32_PIN_PA3, STM32L1X_PINMUX_FUNC_PA3_USART2_RX},
23+
#endif /* CONFIG_UART_2 */
24+
#ifdef CONFIG_UART_3
25+
{STM32_PIN_PB10, STM32L1X_PINMUX_FUNC_PB10_USART3_TX},
26+
{STM32_PIN_PB11, STM32L1X_PINMUX_FUNC_PB11_USART3_RX},
27+
#endif /* CONFIG_UART_3 */
28+
#ifdef CONFIG_I2C_1
29+
{STM32_PIN_PB6, STM32L1X_PINMUX_FUNC_PB6_I2C1_SCL},
30+
{STM32_PIN_PB7, STM32L1X_PINMUX_FUNC_PB7_I2C1_SDA},
31+
#endif /* CONFIG_I2C_1 */
32+
#ifdef CONFIG_I2C_2
33+
{STM32_PIN_PB10, STM32L1X_PINMUX_FUNC_PB10_I2C2_SCL},
34+
{STM32_PIN_PB11, STM32L1X_PINMUX_FUNC_PB11_I2C2_SDA},
35+
#endif /* CONFIG_I2C_2 */
36+
#ifdef CONFIG_SPI_1
37+
#ifdef CONFIG_SPI_STM32_USE_HW_SS
38+
{STM32_PIN_PA4, STM32L1X_PINMUX_FUNC_PA4_SPI1_NSS},
39+
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
40+
{STM32_PIN_PA5, STM32L1X_PINMUX_FUNC_PA5_SPI1_SCK},
41+
{STM32_PIN_PA6, STM32L1X_PINMUX_FUNC_PA6_SPI1_MISO},
42+
{STM32_PIN_PA7, STM32L1X_PINMUX_FUNC_PA7_SPI1_MOSI},
43+
#endif /* CONFIG_SPI_1 */
44+
#ifdef CONFIG_SPI_2
45+
#ifdef CONFIG_SPI_STM32_USE_HW_SS
46+
{STM32_PIN_PB12, STM32L1X_PINMUX_FUNC_PB12_SPI2_NSS},
47+
#endif /* CONFIG_SPI_STM32_USE_HW_SS */
48+
{STM32_PIN_PB13, STM32L1X_PINMUX_FUNC_PB13_SPI2_SCK},
49+
{STM32_PIN_PB14, STM32L1X_PINMUX_FUNC_PB14_SPI2_MISO},
50+
{STM32_PIN_PB15, STM32L1X_PINMUX_FUNC_PB15_SPI2_MOSI},
51+
#endif /* CONFIG_SPI_2 */
52+
};
53+
54+
static int pinmux_stm32_init(struct device *port)
55+
{
56+
ARG_UNUSED(port);
57+
58+
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
59+
60+
return 0;
61+
}
62+
63+
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
64+
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);

0 commit comments

Comments
 (0)