Skip to content

Commit

Permalink
boards: atsame54_xpro: Support driving on-board LED with PWM
Browse files Browse the repository at this point in the history
This commit adds the PWM LED definition in the board device tree for
the on-board LED connected to the pin PC18.

Signed-off-by: Stephanos Ioannidis <[email protected]>
  • Loading branch information
stephanosio authored and nashif committed Jul 4, 2020
1 parent 11c294d commit 17e8a20
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
16 changes: 16 additions & 0 deletions boards/arm/atsame54_xpro/atsame54_xpro.dts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/* These aliases are provided for compatibility with samples */
aliases {
led0 = &led0;
pwm-led0 = &pwm_led0;
sw0 = &button0;
i2c-0 = &sercom7;
};
Expand All @@ -33,6 +34,13 @@
};
};

pwmleds {
compatible = "pwm-leds";
pwm_led0: pwm_led_0 {
pwms = <&tcc0 2>;
};
};

buttons {
compatible = "gpio-keys";
button0: button_0 {
Expand All @@ -42,6 +50,14 @@
};
};

&tcc0 {
status = "okay";
compatible = "atmel,sam0-tcc-pwm";
/* Gives a maximum period of 1.1s for 120MHz main clock */
prescaler = <8>;
#pwm-cells = <1>;
};

&sercom2 {
status = "okay";
compatible = "atmel,sam0-uart";
Expand Down
1 change: 1 addition & 0 deletions boards/arm/atsame54_xpro/atsame54_xpro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ toolchain:
- xtools
supported:
- gpio
- pwm
- spi
- i2c
- usb_device
Expand Down
11 changes: 10 additions & 1 deletion boards/arm/atsame54_xpro/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ features:
+-----------+------------+--------------------------------------+
| GPIO | on-chip | I/O ports |
+-----------+------------+--------------------------------------+
| PWM | on-chip | Pulse Width Modulation |
+-----------+------------+--------------------------------------+
| USART | on-chip | Serial ports |
+-----------+------------+--------------------------------------+
| SPI | on-chip | Serial Peripheral Interface ports |
Expand Down Expand Up @@ -88,7 +90,7 @@ Default Zephyr Peripheral Mapping:
----------------------------------
- SERCOM2 USART TX : PB24
- SERCOM2 USART RX : PB25
- GPIO LED0 : PC18
- GPIO/PWM LED0 : PC18
- GPIO SW0 : PB31

System Clock
Expand All @@ -105,6 +107,13 @@ this BSP. SERCOM2 is the default Zephyr console.

- SERCOM2 115200 8n1 connected to the onboard Atmel Embedded Debugger (EDBG)

PWM
===

The SAME54 MCU has 5 TCC based PWM units with up to 6 outputs each and a period
of 24 bits or 16 bits. If :code:`CONFIG_PWM_SAM0_TCC` is enabled then LED0 is
driven by TCC0 instead of by GPIO.

SPI Port
========

Expand Down
5 changes: 5 additions & 0 deletions boards/arm/atsame54_xpro/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ static int board_pinmux_init(struct device *dev)
pinmux_pin_set(muxd, 9, PINMUX_FUNC_C);
#endif

#if (ATMEL_SAM0_DT_TCC_CHECK(0, atmel_sam0_tcc_pwm) && CONFIG_PWM_SAM0_TCC)
/* TCC0 on WO2=PC18 */
pinmux_pin_set(muxc, 18, PINMUX_FUNC_F);
#endif

#ifdef CONFIG_USB_DC_SAM0
/* USB DP on PA25, USB DM on PA24 */
pinmux_pin_set(muxa, 25, PINMUX_FUNC_H);
Expand Down

0 comments on commit 17e8a20

Please sign in to comment.