Skip to content

Commit

Permalink
boards: sparkfun: Add support for Sparkfun Thing Plus Matter board
Browse files Browse the repository at this point in the history
Added support for the  Sparkfun Thing Plus Matter MGM240P board.
For more information about this board please check:
https://www.sparkfun.com/products/20270

Signed-off-by: Teresa Zepeda Ventura <teresa.zvent@gmail.com>
  • Loading branch information
Terezvent authored and carlescufi committed Aug 12, 2024
1 parent 403d0d6 commit 7502304
Show file tree
Hide file tree
Showing 15 changed files with 551 additions and 0 deletions.
7 changes: 7 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2021 Sateesh Kotapati
# SPDX-License-Identifier: Apache-2.0

if(CONFIG_UART_GECKO)
zephyr_library()
zephyr_library_sources(board.c)
endif()
9 changes: 9 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPARKFUN THING PLUS MGM240P board

# Copyright (c) 2024 Daikin Comfort Technologies North America, Inc.
# Copyright (c) 2022, Silicon Labs
# SPDX-License-Identifier: Apache-2.0

module = BOARD_SPARKFUN_THING_PLUS_MATTER_MGM240P
module-str = Board Control
source "subsys/logging/Kconfig.template.log_config"
45 changes: 45 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SPARKFUN THING PLUS MGM240P board

# Copyright (c) 2024 Daikin Comfort Technologies North America, Inc.
# Copyright (c) 2021, Sateesh Kotapati
# SPDX-License-Identifier: Apache-2.0

if BOARD_SPARKFUN_THING_PLUS_MATTER_MGM240P

config CMU_HFXO_FREQ
default 40000000

config CMU_LFXO_FREQ
default 32768

config FLASH_BASE_ADDRESS
hex
default 0x08000000

if SOC_GECKO_USE_RAIL

config FPU
default y

endif # SOC_GECKO_USE_RAIL

if BT

config FPU
default y

config COMMON_LIBC_MALLOC_ARENA_SIZE
default 8192

config MAIN_STACK_SIZE
default 2304

if SHELL

config SHELL_STACK_SIZE
default 4096

endif # SHELL

endif # BT
endif # BOARD_SPARKFUN_THING_PLUS_MGM240P
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EFR32XG24 MGM240P board

# Copyright (c) 2024 Daikin Comfort Technologies North America, Inc.
# SPDX-License-Identifier: Apache-2.0

config BOARD_SPARKFUN_THING_PLUS_MATTER_MGM240P
select SOC_PART_NUMBER_EFR32MG24B020F1536IM40
72 changes: 72 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2024 Daikin Comfort Technologies North America, Inc.
* Copyright (c) 2021 Sateesh Kotapati
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/init.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/sys/printk.h>
#include <zephyr/logging/log.h>

#ifdef CONFIG_SOC_GECKO_DEV_INIT
#include "em_cmu.h"
#endif

LOG_MODULE_REGISTER(sparkfun_thing_plus_mgm240p,
CONFIG_BOARD_SPARKFUN_THING_PLUS_MATTER_MGM240P_LOG_LEVEL);

static int sparkfun_thing_plus_mgm240p_init_clocks(void);

static int sparkfun_thing_plus_mgm240p_init(void)
{
int ret;

#ifdef CONFIG_SOC_GECKO_DEV_INIT
sparkfun_thing_plus_mgm240p_init_clocks();
#endif
static struct gpio_dt_spec wake_up_gpio_dev =
GPIO_DT_SPEC_GET(DT_NODELABEL(wake_up_trigger), gpios);


if (!gpio_is_ready_dt(&wake_up_gpio_dev)) {
LOG_ERR("Wake-up GPIO device was not found!\n");
return -ENODEV;
}
ret = gpio_pin_configure_dt(&wake_up_gpio_dev, GPIO_OUTPUT_ACTIVE);
if (ret < 0)
return ret;

return 0;
}

#ifdef CONFIG_SOC_GECKO_DEV_INIT
static int sparkfun_thing_plus_mgm240p_init_clocks(void)
{
CMU_ClockSelectSet(cmuClock_SYSCLK, cmuSelect_HFRCODPLL);
#if defined(_CMU_EM01GRPACLKCTRL_MASK)
CMU_ClockSelectSet(cmuClock_EM01GRPACLK, cmuSelect_HFRCODPLL);
#endif
#if defined(_CMU_EM01GRPBCLKCTRL_MASK)
CMU_ClockSelectSet(cmuClock_EM01GRPBCLK, cmuSelect_HFRCODPLL);
#endif
CMU_ClockSelectSet(cmuClock_EM23GRPACLK, cmuSelect_LFRCO);
CMU_ClockSelectSet(cmuClock_EM4GRPACLK, cmuSelect_LFRCO);
#if defined(RTCC_PRESENT)
CMU_ClockSelectSet(cmuClock_RTCC, cmuSelect_LFRCO);
#endif
#if defined(SYSRTC_PRESENT)
CMU_ClockSelectSet(cmuClock_SYSRTC, cmuSelect_LFRCO);
#endif
CMU_ClockSelectSet(cmuClock_WDOG0, cmuSelect_LFRCO);
#if WDOG_COUNT > 1
CMU_ClockSelectSet(cmuClock_WDOG1, cmuSelect_LFRCO);
#endif

return 0;
}
#endif

/* needs to be done after GPIO driver init */
SYS_INIT(sparkfun_thing_plus_mgm240p_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
7 changes: 7 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Daikin Comfort Technologies North America, Inc.

# SPDX-License-Identifier: Apache-2.0
#

board_runner_args(jlink "--device=EFR32MG24BxxxF1536")
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
5 changes: 5 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
board:
name: sparkfun_thing_plus_matter_mgm240p
vendor: sparkfun
socs:
- name: efr32mg24b020f1536im40
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
168 changes: 168 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
.. _sparkfun_thing_plus_mgm240p:

SPARKFUN THING PLUS MATTER
###########################

Overview
********

The MGM240P Mighty Sparkfun Think Plus Matter contains
a Wireless System-On-Chip from the EFR32MG24 family built on an
ARM Cortex®-M33F processor with excellent low power capabilities.

.. figure:: ./img/MGM240P_Thing_Plus.jpg
:height: 260px
:align: center
:alt: MGM240P Sparkfun Think Plus Matter

xG24-MGM240P (image courtesy of Sparkfun)

Hardware
********

- Based on the Series 2 EFR32MG24 SoC
- CPU core: 32-bit ARM® Cortex®-M33 core at 39 MHz
- Flash memory: 1536 kB
- RAM: 256 kB
- Supports Multiple 802.15.4 Wireless Protocols (Zigbee and OpenThread)
- Bluetooth Low Energy 5.3
- Crystals for LFXO (32 kHz) and HFXO (39 MHz).

For more information about the EFR32MG24 SoC and BRD2601B board, refer to these
documents:

- `EFR32MG24 Website`_
- `EFR32MG24 Datasheet`_
- `EFR32xG24 Reference Manual`_
- `MGM240P Datasheet`_
- `MGM240P Schematics`_

Supported Features
==================

The board configuration supports the following hardware features:

+-----------+------------+-------------------------------------+
| Interface | Controller | Driver/Component |
+===========+============+=====================================+
| COUNTER | on-chip | stimer |
+-----------+------------+-------------------------------------+
| FLASH | on-chip | flash memory |
+-----------+------------+-------------------------------------+
| GPIO | on-chip | gpio |
+-----------+------------+-------------------------------------+
| UART | on-chip | serial |
+-----------+------------+-------------------------------------+
| TRNG | on-chip | semailbox |
+-----------+------------+-------------------------------------+
| WATCHDOG | on-chip | watchdog |
+-----------+------------+-------------------------------------+
| I2C(M/S) | on-chip | i2c |
+-----------+------------+-------------------------------------+
| RADIO | on-chip | bluetooth |
+-----------+------------+-------------------------------------+

Other hardware features are currently not supported by the port.

Connections and IOs
===================

In the following table, the column **Name** contains Pin names. For example, PA2
means Pin number 2 on PORTA, as used in the board's datasheets and manuals.

+-------+-------------+-------------------------------------+
| Name | Function | Usage |
+=======+=============+=====================================+
| PA8 | GPIO | LED0 |
+-------+-------------+-------------------------------------+
| PA5 | USART0_TX | UART Console EFM_BC_TX US0_TX |
+-------+-------------+-------------------------------------+
| PA6 | USART0_RX | UART Console EFM_BC_RX US0_RX |
+-------+-------------+-------------------------------------+

The default configuration can be found in
:zephyr_file:`boards/silabs/sparkfun_thing_plus_mgm240p/sparkfun_thing_plus_mgm240p_defconfig`

System Clock
============

The EFR32MG24 SoC is configured to use the 39 MHz external oscillator on the
board.

Serial Port
===========

The EFR32MG24 SoC has one USART and two EUSARTs.
USART0 is connected to the board controller and is used for the console.

Programming and Debugging
*************************

.. note::
Before using the kit the first time, you should update the J-Link firmware
from `J-Link-Downloads`_

Flashing
========

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: sparkfun_thing_plus_mgm240p
:goals: build

Connect the sparkfun_thing_plus_mgm240p to your host computer using the USB port and you
should see a USB connection.

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! _sparkfun_thing_plus_mgm240p
Bluetooth
=========

To use the BLE function, run the command below to retrieve necessary binary
blobs from the SiLabs HAL repository.

.. code-block:: console
west blobs fetch silabs
Then build the Zephyr kernel and a Bluetooth sample with the following
command. The :ref:`bluetooth-observer-sample` sample application is used in
this example.

.. zephyr-app-commands::
:zephyr-app: samples/bluetooth/observer
:board: sparkfun_thing_plus_mgm240p
:goals: build

.. _EFR32MG24 Website:
https://www.silabs.com/wireless/zigbee/efr32mg24-series-2-socs#

.. _EFR32MG24 Datasheet:
https://www.silabs.com/documents/public/data-sheets/efr32mg24-datasheet.pdf

.. _EFR32xG24 Reference Manual:
https://www.silabs.com/documents/public/reference-manuals/efr32xg24-rm.pdf

.. _MGM240P Datasheet:
https://cdn.sparkfun.com/assets/1/4/5/e/5/MGM240P-Datasheet.pdf

.. _MGM240P Schematics:
https://cdn.sparkfun.com/assets/0/f/8/4/9/Thing_Plus_MGM240P.pdf

.. _J-Link-Downloads:
https://www.segger.com/downloads/jlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2022, Antmicro
# SPDX-License-Identifier: Apache-2.0

description: GPIO Wake Up Trigger for EFR32MG24

compatible: "silabs,gecko-wake-up-trigger"

include: base.yaml

properties:
gpios:
type: phandle-array
required: true
description: |
GPIO used as wake up trigger from EM4 sleep
5 changes: 5 additions & 0 deletions boards/sparkfun/thing_plus_matter_mgm240p/pre_dt_board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2021 Linaro Limited
# SPDX-License-Identifier: Apache-2.0

# SPI is implemented via usart so node name isn't spi@...
list(APPEND EXTRA_DTC_FLAGS "-Wno-spi_bus_bridge")
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2022 Silicon Labs
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <dt-bindings/pinctrl/gecko-pinctrl.h>

&pinctrl {
/* configuration for uart0 device, default state */
usart0_default: usart0_default {
group1 {
/* configure PA.6 as UART_RX and PA.5 as UART_TX */
psels = <GECKO_PSEL(UART_TX, A, 5)>,
<GECKO_PSEL(UART_RX, A, 6)>,
<GECKO_LOC(UART, 0)>;
};
};

i2c0_default: i2c0_default {
group1 {
psels = <GECKO_PSEL(I2C_SDA, B, 3)>,
<GECKO_PSEL(I2C_SCL, B, 4)>,
<GECKO_LOC(I2C_SDA, 5)>,
<GECKO_LOC(I2C_SCL, 5)>;
};
};

};
Loading

0 comments on commit 7502304

Please sign in to comment.