Skip to content

Commit

Permalink
boards: nucleo_l496zg: Add pwm mapping and RTC
Browse files Browse the repository at this point in the history
Supported PWM at pins A0, D3, D5 and D6 which are also Arduino
compatible. Also the onboard red LED can be used with PWM.

The basic/{fade_led, blink_led} samples to apply to this board
seemlessly and operate on the onboard red LED.

Also supported RTC.

Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
  • Loading branch information
gon1332 authored and galak committed Jan 23, 2019
1 parent 8fc9748 commit 5151e8a
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 7 deletions.
16 changes: 16 additions & 0 deletions boards/arm/nucleo_l496zg/Kconfig.defconfig
Expand Up @@ -24,4 +24,20 @@ config LPUART_1

endif # SERIAL

if PWM

config PWM_STM32_1
default y

config PWM_STM32_2
default y

config PWM_STM32_4
default y

config PWM_STM32_15
default y

endif # PWM

endif # BOARD_NUCLEO_L496ZG
8 changes: 8 additions & 0 deletions boards/arm/nucleo_l496zg/doc/nucleol496zg.rst
Expand Up @@ -121,6 +121,10 @@ The Zephyr nucleo_l496zg board configuration supports the following hardware fea
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| PWM | on-chip | pwm |
+-----------+------------+-------------------------------------+
| RTC | on-chip | rtc |
+-----------+------------+-------------------------------------+

Other hardware features are not yet supported on this Zephyr port.

Expand All @@ -142,6 +146,10 @@ Default Zephyr Peripheral Mapping:
- UART_2 TX/RX : PD5/PD6
- UART_3 TX/RX : PD8/PD9
- LPUART_1 TX/RX : PG7/PG8
- PWM_1_CH1: PE9
- PWM_1_CH2: PE11
- PWM_1_CH3: PE13
- PWM_2_CH1: PA0
- USER_PB : PC13
- LD1 : PC7
- LD2 : PB7
Expand Down
45 changes: 45 additions & 0 deletions boards/arm/nucleo_l496zg/nucleo_l496zg.dts
Expand Up @@ -33,6 +33,14 @@
};
};

pwmleds {
compatible = "pwm-leds";

red_pwm_led: red_pwm_led {
pwms = <&{/soc/timers@40014000/pwm} 1 4>;
};
};

gpio_keys {
compatible = "gpio-keys";
user_button: button {
Expand All @@ -45,6 +53,7 @@
led0 = &green_led_1;
led1 = &blue_led_2;
led2 = &red_led_3;
pwm-led0 = &red_pwm_led;
sw0 = &user_button;
};
};
Expand All @@ -71,3 +80,39 @@ arduino_serial: &lpuart1 {};
pinctrl-names = "default";
status = "ok";
};

&timers1 {
status = "ok";

pwm {
status = "ok";
};
};

&timers2 {
status = "ok";

pwm {
status = "ok";
};
};

&timers4 {
status = "ok";

pwm {
status = "ok";
};
};

&timers15 {
status = "ok";

pwm {
status = "ok";
};
};

&rtc {
status = "ok";
};
1 change: 1 addition & 0 deletions boards/arm/nucleo_l496zg/nucleo_l496zg.yaml
Expand Up @@ -9,3 +9,4 @@ ram: 320
flash: 1024
supported:
- gpio
- pwm
3 changes: 0 additions & 3 deletions boards/arm/nucleo_l496zg/nucleo_l496zg_defconfig
Expand Up @@ -34,8 +34,5 @@ CONFIG_CLOCK_STM32_APB2_PRESCALER=1
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

#enable pwm
CONFIG_PWM=n

#enable MPU
CONFIG_ARM_MPU=y
11 changes: 11 additions & 0 deletions boards/arm/nucleo_l496zg/pinmux.c
Expand Up @@ -22,6 +22,17 @@ static const struct pin_config pinconf[] = {
{STM32_PIN_PG7, STM32L4X_PINMUX_FUNC_PG7_LPUART1_TX},
{STM32_PIN_PG8, STM32L4X_PINMUX_FUNC_PG8_LPUART1_RX},
#endif /* CONFIG_LPUART_1 */
#ifdef CONFIG_PWM_STM32_1
{STM32_PIN_PE9, STM32L4X_PINMUX_FUNC_PE9_PWM1_CH1},
{STM32_PIN_PE11, STM32L4X_PINMUX_FUNC_PE11_PWM1_CH2},
{STM32_PIN_PE13, STM32L4X_PINMUX_FUNC_PE13_PWM1_CH3},
#endif /* CONFIG_PWM_STM32_1 */
#ifdef CONFIG_PWM_STM32_2
{STM32_PIN_PA0, STM32L4X_PINMUX_FUNC_PA0_PWM2_CH1},
#endif /* CONFIG_PWM_STM32_2 */
#ifdef CONFIG_PWM_STM32_15
{STM32_PIN_PB14, STM32L4X_PINMUX_FUNC_PB14_PWM15_CH1},
#endif /* CONFIG_PWM_STM32_15 */
};

static int pinmux_stm32_init(struct device *port)
Expand Down
11 changes: 11 additions & 0 deletions drivers/pinmux/stm32/pinmux_stm32l4x.h
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2016 Open-RnD Sp. z o.o.
* Copyright (c) 2016 BayLibre, SAS
* Copyright (c) 2018 Centaur Analytics, Inc
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -85,6 +86,8 @@
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUPDR_NO_PULL)
#define STM32L4X_PINMUX_FUNC_PB13_I2C2_SCL \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
#define STM32L4X_PINMUX_FUNC_PB14_PWM15_CH1 \
(STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PB14_I2C2_SDA \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)

Expand Down Expand Up @@ -126,6 +129,14 @@
#define STM32L4X_PINMUX_FUNC_PD13_I2C4_SDA \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)

/* Port E */
#define STM32L4X_PINMUX_FUNC_PE9_PWM1_CH1 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PE11_PWM1_CH2 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PE13_PWM1_CH3 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)

/* Port F */
#define STM32L4X_PINMUX_FUNC_PF1_I2C3_SCL \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
Expand Down
5 changes: 5 additions & 0 deletions samples/basic/blink_led/README.rst
Expand Up @@ -25,6 +25,11 @@ Nucleo_F103RB
=============
Connect PWM1(PA8) to LED

Nucleo_L496ZG
=============
No special board setup is necessary because there are three on-board LEDs (red,
green, blue) connected to the Nucleo's PWM.

Hexiwear K64
============
No special board setup is necessary because there is an on-board RGB LED
Expand Down
2 changes: 1 addition & 1 deletion samples/basic/blink_led/sample.yaml
Expand Up @@ -5,6 +5,6 @@ tests:
# FIXME: We should remove those and just rely on depends_on
platform_whitelist: arduino_101 quark_d2000_crb
nucleo_f103rb nucleo_f302r8 nucleo_f401re nucleo_l476rg stm32f4_disco
hexiwear_k64 colibri_imx7d_m4 nrf52832_mdk nrf52840_mdk
hexiwear_k64 colibri_imx7d_m4 nrf52832_mdk nrf52840_mdk, nucleo_l496zg
tags: drivers pwm
depends_on: pwm
9 changes: 7 additions & 2 deletions samples/basic/fade_led/README.rst
Expand Up @@ -17,14 +17,19 @@ repeat this cycle for ever.
Wiring
******

Nucleo_F401RE and Nucleo_L476RG
===============================
Nucleo_F401RE, Nucleo_L476RG
============================
Connect PWM2(PA0) to LED

Nucleo_F103RB
=============
Connect PWM1(PA8) to LED

Nucleo_L496ZG
=============
No special board setup is necessary because there are three on-board LEDs (red,
green, blue) connected to the Nucleo's PWM.

Hexiwear K64
============
No special board setup is necessary because there is an on-board RGB LED
Expand Down
2 changes: 1 addition & 1 deletion samples/basic/fade_led/sample.yaml
Expand Up @@ -4,6 +4,6 @@ tests:
test:
# FIXME: We should remove those and just rely on depends_on
platform_whitelist: arduino_101 quark_d2000_crb
nucleo_f103rb nucleo_f401re nucleo_l476rg hexiwear_k64
nucleo_f103rb nucleo_f401re nucleo_l476rg nucleo_l496zg hexiwear_k64
tags: drivers pwm
depends_on: pwm

0 comments on commit 5151e8a

Please sign in to comment.