diff --git a/boards/arm/efm32pg_stk3402a/CMakeLists.txt b/boards/arm/efm32pg_stk3402a/CMakeLists.txt new file mode 100644 index 00000000000..0c35d352f47 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/CMakeLists.txt @@ -0,0 +1,5 @@ +if(CONFIG_UART_GECKO) + zephyr_library() + zephyr_library_sources(board.c) + zephyr_library_include_directories(${PROJECT_SOURCE_DIR}/drivers) +endif() diff --git a/boards/arm/efm32pg_stk3402a/Kconfig b/boards/arm/efm32pg_stk3402a/Kconfig new file mode 100644 index 00000000000..e7f4be21598 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/Kconfig @@ -0,0 +1,19 @@ +# Kconfig - EFM32PG STK3402A board configuration +# +# Copyright (c) 2018 Christian Taedcke +# +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_EFM32PG_STK3402A + +config BOARD_INIT_PRIORITY + int + + # omit prompt to signify a "hidden" option + default KERNEL_INIT_PRIORITY_DEFAULT + depends on GPIO + help + Board initialization priority. This must be bigger than + GPIO_GECKO_COMMON_INIT_PRIORITY. + +endif # BOARD_EFM32PG_STK3402A diff --git a/boards/arm/efm32pg_stk3402a/Kconfig.board b/boards/arm/efm32pg_stk3402a/Kconfig.board new file mode 100644 index 00000000000..7726fb0f6e4 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/Kconfig.board @@ -0,0 +1,12 @@ +# Kconfig - EFM32PG STK3402A board +# +# Copyright (c) 2018, Christian Taedcke +# +# SPDX-License-Identifier: Apache-2.0 +# + +config BOARD_EFM32PG_STK3402A + bool "SiLabs EFM32PG-STK3402A (Pearl Gecko)" + depends on SOC_SERIES_EFM32PG12B + select SOC_PART_NUMBER_EFM32PG12B500F1024GL125 + select HAS_DTS_I2C diff --git a/boards/arm/efm32pg_stk3402a/Kconfig.defconfig b/boards/arm/efm32pg_stk3402a/Kconfig.defconfig new file mode 100644 index 00000000000..3bb9526ea5f --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/Kconfig.defconfig @@ -0,0 +1,62 @@ +# Kconfig - EFM32PG STK3402A board +# +# Copyright (c) 2018, Christian Taedcke +# +# SPDX-License-Identifier: Apache-2.0 +# + +if BOARD_EFM32PG_STK3402A + +config BOARD + default "efm32pg_stk3402a" + +config CMU_HFXO_FREQ + default 40000000 + +config CMU_LFXO_FREQ + default 32768 + +if GPIO_GECKO + +config GPIO_GECKO_PORTA + default y + +config GPIO_GECKO_PORTB + default y + +config GPIO_GECKO_PORTC + default n + +config GPIO_GECKO_PORTD + default y + +config GPIO_GECKO_PORTE + default n + +config GPIO_GECKO_PORTF + default y + +endif # GPIO_GECKO + +if UART_GECKO + +config USART_GECKO_0 + default y + +endif # UART_GECKO + +if LEUART_GECKO + +config LEUART_GECKO_0 + default y + +endif # LEUART_GECKO + +if I2C_GECKO + +config I2C_0 + default y + +endif # I2C_GECKO + +endif # BOARD_EFM32PG_STK3402A diff --git a/boards/arm/efm32pg_stk3402a/board.c b/boards/arm/efm32pg_stk3402a/board.c new file mode 100644 index 00000000000..763909a75dd --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/board.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2018 Christian Taedcke + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "board.h" +#include +#include + +static int efm32pg_stk3402a_init(struct device *dev) +{ + struct device *bce_dev; /* Board Controller Enable Gpio Device */ + + ARG_UNUSED(dev); + + /* Enable the board controller to be able to use the serial port */ + bce_dev = device_get_binding(BC_ENABLE_GPIO_NAME); + + if (!bce_dev) { + printk("Board controller gpio port was not found!\n"); + return -ENODEV; + } + + gpio_pin_configure(bce_dev, BC_ENABLE_GPIO_PIN, GPIO_DIR_OUT); + gpio_pin_write(bce_dev, BC_ENABLE_GPIO_PIN, 1); + + return 0; +} + +/* needs to be done after GPIO driver init */ +SYS_INIT(efm32pg_stk3402a_init, PRE_KERNEL_1, CONFIG_BOARD_INIT_PRIORITY); diff --git a/boards/arm/efm32pg_stk3402a/board.cmake b/boards/arm/efm32pg_stk3402a/board.cmake new file mode 100644 index 00000000000..b9925901bc8 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/board.cmake @@ -0,0 +1,8 @@ +# +# Copyright (c) 2018, Christian Taedcke +# +# SPDX-License-Identifier: Apache-2.0 +# + +board_runner_args(jlink "--device=EFM32PG12BxxxF1024") +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/efm32pg_stk3402a/board.h b/boards/arm/efm32pg_stk3402a/board.h new file mode 100644 index 00000000000..4e0bffc7a5c --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/board.h @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2018 Christian Taedcke + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __INC_BOARD_H +#define __INC_BOARD_H + +/* This pin is used to enable the serial port using the board controller */ +#define BC_ENABLE_GPIO_NAME DT_GPIO_GECKO_PORTA_NAME +#define BC_ENABLE_GPIO_PIN 5 + +#endif /* __INC_BOARD_H */ diff --git a/boards/arm/efm32pg_stk3402a/doc/efm32pg_stk3402a.rst b/boards/arm/efm32pg_stk3402a/doc/efm32pg_stk3402a.rst new file mode 100644 index 00000000000..3a9a775321d --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/doc/efm32pg_stk3402a.rst @@ -0,0 +1,189 @@ +.. _efm32pg_stk3402a: + +EFM32 Pearl Gecko Starter Kit +############################# + +Overview +******** + +The EFM32 Pearl Gecko Starter Kit EFM32PG-STK3402A contains an MCU from the +EFM32PG family built on an ARM® Cortex®-M4F processor with excellent low +power capabilities. + +.. figure:: slstk3402a-pearl-gecko-pg12-stk.png + :width: 375px + :align: center + :alt: EFM32PG-SLSTK3402A + + EFM32PG-SLSTK3402A (image courtesy of Silicon Labs) + +Hardware +******** + +- Advanced Energy Monitoring provides real-time information about the energy + consumption of an application or prototype design. +- Ultra low power 128x128 pixel Memory-LCD +- 2 user buttons, 2 LEDs and a touch slider +- Humidity, temperature, and inductive-capacitive metal sensor +- On-board Segger J-Link USB debugger + +For more information about the EFM32PG SoC and EFM32PG-STK3402A board: + +- `EFM32PG Website`_ +- `EFM32PG12 Datasheet`_ +- `EFM32PG12 Reference Manual`_ +- `EFM32PG-STK3402A Website`_ +- `EFM32PG-STK3402A User Guide`_ +- `EFM32PG-STK3402A Schematics`_ + +Supported Features +================== + +The efm32pg_stk3402a board configuration supports the following hardware features: + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| SYSTICK | on-chip | systick | ++-----------+------------+-------------------------------------+ +| FLASH | on-chip | flash memory | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial port-polling; | +| | | serial port-interrupt | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c port-polling | ++-----------+------------+-------------------------------------+ + +The default configuration can be found in the defconfig file: + + ``boards/arm/efm32pg_stk3402a/efm32pg_stk3402a_defconfig`` + +Other hardware features are currently not supported by the port. + +Connections and IOs +=================== + +The EFM32PG12 SoC has twelve GPIO controllers (PORTA to PORTL), but only four +are currently enabled (PORTA, PORTB, PORTD and PORTF) for the EFM32PG-STK3402A +board. + +In the following table, the column **Name** contains pin names. For example, PE2 +means pin number 2 on PORTE, as used in the board's datasheets and manuals. + ++-------+-------------+-------------------------------------+ +| Name | Function | Usage | ++=======+=============+=====================================+ +| PF4 | GPIO | LED0 | ++-------+-------------+-------------------------------------+ +| PF5 | GPIO | LED1 | ++-------+-------------+-------------------------------------+ +| PF6 | GPIO | Push Button PB0 | ++-------+-------------+-------------------------------------+ +| PF7 | GPIO | Push Button PB1 | ++-------+-------------+-------------------------------------+ +| PA5 | GPIO | Board Controller Enable | +| | | EFM_BC_EN | ++-------+-------------+-------------------------------------+ +| PA0 | UART_TX | UART TX Console VCOM_TX US0_TX #0 | ++-------+-------------+-------------------------------------+ +| PA1 | UART_RX | UART RX Console VCOM_RX US0_RX #0 | ++-------+-------------+-------------------------------------+ +| PD10 | UART_TX | EXP12_UART_TX LEU0_TX #18 | ++-------+-------------+-------------------------------------+ +| PD11 | UART_RX | EXP14_UART_RX LEU0_RX #18 | ++-------+-------------+-------------------------------------+ +| PC10 | I2C_SDA | ENV_I2C_SDA I2C0_SDA #15 | ++-------+-------------+-------------------------------------+ +| PC11 | I2C_SCL | ENV_I2C_SCL I2C0_SCL #15 | ++-------+-------------+-------------------------------------+ + + +System Clock +============ + +The EFM32PG SoC is configured to use the 40 MHz external oscillator on the +board. + +Serial Port +=========== + +The EFM32PG SoC has four USARTs and one Low Energy UART (LEUART). + +Programming and Debugging +************************* + +.. note:: + Before using the kit the first time, you should update the J-Link firmware + from `J-Link-Downloads`_ + +Flashing +======== + +The EFM32PG-STK3402A includes an `J-Link`_ serial and debug adaptor built into the +board. The adaptor provides: + +- A USB connection to the host computer, which exposes a mass storage device and a + USB serial port. +- A serial flash device, which implements the USB flash disk file storage. +- A physical UART connection which is relayed over interface USB serial port. + +Flashing an application to EFM32PG-STK3402A +------------------------------------------- + +The sample application :ref:`hello_world` is used for this example. +Build the Zephyr kernel and application: + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: efm32pg_stk3402a + :goals: build + +Connect the EFM32PG-STK3402A to your host computer using the USB port and you +should see a USB connection which exposes a mass storage device(STK3402A). +Copy the generated zephyr.bin to the STK3402A drive. + +Use a USB-to-UART converter such as an FT232/CP2102 to connect to the UART on the +expansion header. + +Open a serial terminal (minicom, putty, etc.) with the following settings: + +- Speed: 115200 +- Data: 8 bits +- Parity: None +- Stop bits: 1 + +Reset the board and you'll see the following message on the corresponding serial port +terminal session: + +.. code-block:: console + + Hello World! arm + + +.. _EFM32PG-STK3402A Website: + https://www.silabs.com/products/development-tools/mcu/32-bit/efm32-pearl-gecko-pg12-starter-kit + +.. _EFM32PG-STK3402A User Guide: + https://www.silabs.com/documents/public/user-guides/ug257-stk3402-usersguide.pdf + +.. _EFM32PG-STK3402A Schematics: + https://www.silabs.com/documents/public/schematic-files/EFM32PG12-BRD2501A-A01-schematic.pdf + +.. _EFM32PG Website: + https://www.silabs.com/products/mcu/32-bit/efm32-pearl-gecko + +.. _EFM32PG12 Datasheet: + https://www.silabs.com/documents/public/data-sheets/efm32pg12-datasheet.pdf + +.. _EFM32PG12 Reference Manual: + https://www.silabs.com/documents/public/reference-manuals/efm32pg12-rm.pdf + +.. _J-Link: + https://www.segger.com/jlink-debug-probes.html + +.. _J-Link-Downloads: + https://www.segger.com/downloads/jlink diff --git a/boards/arm/efm32pg_stk3402a/doc/slstk3402a-pearl-gecko-pg12-stk.png b/boards/arm/efm32pg_stk3402a/doc/slstk3402a-pearl-gecko-pg12-stk.png new file mode 100644 index 00000000000..2c012d1bbc6 Binary files /dev/null and b/boards/arm/efm32pg_stk3402a/doc/slstk3402a-pearl-gecko-pg12-stk.png differ diff --git a/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts new file mode 100644 index 00000000000..5c37537ed26 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.dts @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2017 Christian Taedcke + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include + +/ { + model = "Silicon Labs EFM32PG STK3402A board"; + compatible = "silabs,efm32pg_stk3402a", "silabs,efm32pg12b"; + + chosen { + zephyr,console = &usart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + i2c-0 = &i2c0; + usart-0 = &usart0; + leuart-0 = &leuart0; + led0 = &led0; + led1 = &led1; + sw0 = &button0; + sw1 = &button1; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpiof 4 0>; + label = "LED 0"; + }; + led1: led_1 { + gpios = <&gpiof 5 0>; + label = "LED 1"; + }; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + /* gpio flags need validation */ + gpios = <&gpiof 6 GPIO_INT_ACTIVE_LOW>; + label = "User Push Button 0"; + }; + button1: button_1 { + /* gpio flags need validation */ + gpios = <&gpiof 7 GPIO_INT_ACTIVE_LOW>; + label = "User Push Button 1"; + }; + }; +}; + +&usart0 { + current-speed = <115200>; + location = <0>; + status = "ok"; +}; + +&leuart0 { + current-speed = <9600>; + location = <18>; + status = "ok"; +}; + +&i2c0 { + location = <15>; + status = "ok"; +}; diff --git a/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.yaml b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.yaml new file mode 100644 index 00000000000..0118fafa19e --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a.yaml @@ -0,0 +1,16 @@ +identifier: efm32pg_stk3402a +name: EFM32PG-STK3402A +type: mcu +arch: arm +ram: 256 +flash: 1024 +toolchain: + - zephyr + - gccarmemb +supported: + - i2c + - gpio +testing: + ignore_tags: + - net + - bluetooth diff --git a/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a_defconfig b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a_defconfig new file mode 100644 index 00000000000..28b125c6ff7 --- /dev/null +++ b/boards/arm/efm32pg_stk3402a/efm32pg_stk3402a_defconfig @@ -0,0 +1,11 @@ +CONFIG_ARM=y +CONFIG_SOC_FAMILY_EXX32=y +CONFIG_SOC_SERIES_EFM32PG12B=y +CONFIG_BOARD_EFM32PG_STK3402A=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y +CONFIG_SERIAL=y +CONFIG_CORTEX_M_SYSTICK=y +CONFIG_GPIO=y +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=40000000 +CONFIG_CMU_HFCLK_HFXO=y