Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boards/generic-cc2538-cc2592-dk: add board support #20226

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions boards/generic-cc2538-cc2592-dk/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2020 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

config BOARD
default "generic-cc2538-cc2592-dk" if BOARD_GENERIC_CC2538_CC2592_DK

config BOARD_GENERIC_CC2538_CC2592_DK
bool
default y
select CPU_MODEL_CC2538SF53
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_RTT
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_EMULATOR_RENODE
select HAS_RIOTBOOT

select HAVE_CC2538_RF
3 changes: 3 additions & 0 deletions boards/generic-cc2538-cc2592-dk/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board

include $(RIOTBASE)/Makefile.base
7 changes: 7 additions & 0 deletions boards/generic-cc2538-cc2592-dk/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ifneq (,$(filter netdev_default,$(USEMODULE)))
USEMODULE += cc2538_rf
endif

ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
14 changes: 14 additions & 0 deletions boards/generic-cc2538-cc2592-dk/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CPU = cc2538
CPU_MODEL ?= cc2538sf53

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_rtt
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart

# Various other features (if any)
FEATURES_PROVIDED += emulator_renode
FEATURES_PROVIDED += riotboot
21 changes: 21 additions & 0 deletions boards/generic-cc2538-cc2592-dk/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
TTY_BOARD_FILTER := --vendor 'Silicon Labs' --model 'CP2102 USB to UART Bridge Controller'

OPENOCD_DEBUG_ADAPTER ?= jlink
OPENOCD_TRANSPORT := jtag

ifneq (,$(filter debug debug-server,$(MAKECMDGOALS)))
# `make debug` doesn't work with default cc2538-bsl, so let's default
# OpenOCD when the user wants to debug
PROGRAMMER ?= openocd

# OpenOCD only works for debugging, not flashing
PROGRAMMERS_SUPPORTED += openocd
endif

ifeq (openocd,$(PROGRAMMER))
ifneq (,$(filter flash flash-only,$(MAKECMDGOALS)))
$(error "Flashing the generic-cc2538-cc2592-dk via OpenOCD is not supported (yet), only debugging")
endif
endif

include $(RIOTBOARD)/common/cc2538/Makefile.include
1 change: 1 addition & 0 deletions boards/generic-cc2538-cc2592-dk/dist/openocd.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
source [find target/cc2538.cfg]
84 changes: 84 additions & 0 deletions boards/generic-cc2538-cc2592-dk/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/**
@defgroup boards_generic_cc2538_cc2592_dk Generic CC2538-CC2592-DK Board
@ingroup boards
@brief Support for the 3rd party CC2538-CC2592-DK board

## Overview

@image html https://raw.githubusercontent.com/maribu/images/master/CC2538-CC2592-DK-front.jpeg "Front side of the CC2538-CC2592-DK board" width=50%
@image html https://raw.githubusercontent.com/maribu/images/master/CC2538-CC2592-DK-back.jpeg "Back side of the CC2538-CC2592-DK board" width=50%

The generic CC2538-CC2592-DK board can obtained from various vendors in the
typical [online][buy-cc2538-cc2592-dk-1] [shops][buy-cc2538-cc2592-dk-2].
There are currently few options for readily available and affordable boards
featuring a legacy CC2538 MCU; this is one of them.

The boards seem to be based on the schematics provided by
[`@knowic`][knowic-author] via [the CC2538_CC2592_DK repo][board-repo].

[buy-cc2538-cc2592-dk-1]: https://www.aliexpress.com/wholesale?SearchText=CC2538+CC2592+development+board
[buy-cc2538-cc2592-dk-2]: https://www.ebay.com/sch/i.html?_nkw=CC2538+CC2592+development+board
[knowic-author]: https://github.com/knowic
[board-repo]: https://github.com/knowic/CC2538_CC2592_DK

## Hardware

| MCU | CC2538SF53 |
|:----------------- |:----------------------------------------- |
| Family | ARM Cortex-M3 |
| Vendor | Texas Instruments |
| RAM | 32 KiB |
| Flash | 512 KiB |
| Frequency | 32 MHz |
| FPU | no |
| Timers | 4 |
| ADCs | 1x 12-bit (8 channels) |
| UARTs | 2 |
| SPIs | 2 |
| I2Cs | 1 |
| Vcc | 3.6 V - 5 V (MCU powered @ 3.3 V via LDO) |
| Schematics | [Board Schematics][schematics] |

### Schematics

<img src="https://raw.githubusercontent.com/maribu/images/master/CC2538-CC2592-DK-schematic.svg" alt="Schematics of the CC2538-CC2592-DK board" style="width: 100%;">

[Download schematics from author's repo][schematics].

[schematics]: https://github.com/knowic/CC2538_CC2592_DK/blob/main/CC2538_CC2592_DK_1V3.pdf

## Flashing

Prior to flashing the bootloader needs to be entered. For this, hold the
"SELECT" button, press the "RESET" button, then release the "SELECT"
button. Now run

```
make BOARD=generic-cc2538-cc2592-dk flash
```

@note Flashing via J-Link would also be possible by passing
`PROGRAMMER=jlink`, but requires attaching a J-Link programmer/debugger.

## Accessing the terminal

The board features an CP2102 USB to UART bridge that is used for stdio by
default. Just use

```
make BOARD=generic-cc2538-cc2592-dk term
```

## Debugging

Assuming an J-Link (e.g. the J-Link EDU Mini) debugger is connected, debugging
is as simple as:

```
make BOARD=generic-cc2538-cc2592-dk debug
```

@note By default OpenOCD is used for debugging. While debugging works fine
with OpenOCD, flashing is only supported via the bootloader or `jlink`.

*/
127 changes: 127 additions & 0 deletions boards/generic-cc2538-cc2592-dk/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* Copyright (C) 2024 Marian Buschsieweke
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_generic_cc2538_cc2592_dk
* @{
*
* @file
* @brief Definitions for the Generic CC2538-CC2592-DK Board
*
* @author Marian Buschsieweke <marian.buschsieweke@posteo.net>
*/

#ifndef BOARD_H
#define BOARD_H

#include "cpu.h"
#include "periph/gpio.h"
#include "cc2538_eui_primary.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name LED pin definitions and handlers
* @{
*/
#define LED_GREEN_PIN GPIO_PIN(PORT_C, 0) /**< GPIO pin for green LED */
#define LED_GREEN_PORT GPIO_C /**< GPIO port register to used to control green LED */

Check warning on line 35 in boards/generic-cc2538-cc2592-dk/include/board.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
#define LED_GREEN_BIT (1U << 0) /**< Bitmask to write to @ref LED_GREEN_PORT */
#define LED0_PIN LED_GREEN_PIN /**< Alias for LED_GREEN_PIN */
#define LED0_PORT LED_GREEN_PORT /**< Alias for LED_GREEN_PORT */
#define LED0_BIT LED_GREEN_BIT /**< Alias for LED_GREEN_BIT */

#define LED_RED_PIN GPIO_PIN(PORT_C, 1) /**< GPIO pin for red LED */
#define LED_RED_PORT GPIO_C /**< GPIO port register to used to control red LED */

Check warning on line 42 in boards/generic-cc2538-cc2592-dk/include/board.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
#define LED_RED_BIT (1U << 1) /**< Bitmask to write to @ref LED_RED_PORT */
#define LED1_PIN LED_RED_PIN /**< Alias for LED_RED_PIN */
#define LED1_PORT LED_RED_PORT /**< Alias for LED_RED_PORT */
#define LED1_BIT LED_RED_BIT /**< Alias for LED_RED_BIT */

#define LED_YELLOW_PIN GPIO_PIN(PORT_B, 1) /**< GPIO pin for yellow LED */
#define LED_YELLOW_PORT GPIO_B /**< GPIO port register to used to control yellow LED */

Check warning on line 49 in boards/generic-cc2538-cc2592-dk/include/board.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
#define LED_YELLOW_BIT (1U << 1) /**< Bitmask to write to @ref LED_YELLOW_PORT */
#define LED2_PIN LED_YELLOW_PIN /**< Alias for LED_YELLOW_PIN */
#define LED2_PORT LED_YELLOW_PORT /**< Alias for LED_YELLOW_PORT */
#define LED2_BIT LED_YELLOW_BIT /**< Alias for LED_YELLOW_BIT */

#define LED_BLUE_PIN GPIO_PIN(PORT_B, 0) /**< GPIO pin for blue LED */
#define LED_BLUE_PORT GPIO_B /**< GPIO port register to used to control blue LED */

Check warning on line 56 in boards/generic-cc2538-cc2592-dk/include/board.h

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
#define LED_BLUE_BIT (1U << 0) /**< Bitmask to write to @ref LED_BLUE_PORT */
#define LED3_PIN LED_BLUE_PIN /**< Alias for LED_BLUE_PIN */
#define LED3_PORT LED_BLUE_PORT /**< Alias for LED_BLUE_PORT */
#define LED3_BIT LED_BLUE_BIT /**< Alias for LED_BLUE_BIT */

#define LED0_ON (LED0_PORT->DATA |= LED0_BIT)
#define LED0_OFF (LED0_PORT->DATA &= ~LED0_BIT)
#define LED0_TOGGLE (LED0_PORT->DATA ^= LED0_BIT)

#define LED1_ON (LED1_PORT->DATA |= LED1_BIT)
#define LED1_OFF (LED1_PORT->DATA &= ~LED1_BIT)
#define LED1_TOGGLE (LED1_PORT->DATA ^= LED1_BIT)

#define LED2_ON (LED2_PORT->DATA |= LED2_BIT)
#define LED2_OFF (LED2_PORT->DATA &= ~LED2_BIT)
#define LED2_TOGGLE (LED2_PORT->DATA ^= LED2_BIT)

#define LED3_ON (LED3_PORT->DATA |= LED3_BIT)
#define LED3_OFF (LED3_PORT->DATA &= ~LED3_BIT)
#define LED3_TOGGLE (LED3_PORT->DATA ^= LED3_BIT)
/** @} */

/**
* @name User button
* @{
*/
#define BTN_LEFT_PIN GPIO_PIN(PORT_C, 4) /**< GPIO pin for button "LEFT" */
#define BTN_LEFT_MODE GPIO_IN_PU /**< GPIO mode for button "LEFT" */
#define BTN0_PIN BTN_LEFT_PIN /**< Alias for BTN_LEFT_PIN */
#define BTN0_MODE BTN_LEFT_MODE /**< Alias for BTN_LEFT_MODE */

#define BTN_RIGHT_PIN GPIO_PIN(PORT_C, 5) /**< GPIO pin for button "RIGHT" */
#define BTN_RIGHT_MODE GPIO_IN_PU /**< GPIO mode for button "RIGHT" */
#define BTN1_PIN BTN_RIGHT_PIN /**< Alias for BTN_RIGHT_PIN */
#define BTN1_MODE BTN_RIGHT_MODE /**< Alias for BTN_RIGHT_MODE */

#define BTN_UP_PIN GPIO_PIN(PORT_C, 6) /**< GPIO pin for button "UP" */
#define BTN_UP_MODE GPIO_IN_PU /**< GPIO mode for button "UP" */
#define BTN2_PIN BTN_UP_PIN /**< Alias for BTN_UP_PIN */
#define BTN2_MODE BTN_UP_MODE /**< Alias for BTN_UP_MODE */

#define BTN_DOWN_PIN GPIO_PIN(PORT_C, 7) /**< GPIO pin for button "DOWN" */
#define BTN_DOWN_MODE GPIO_IN_PU /**< GPIO mode for button "DOWN" */
#define BTN3_PIN BTN_DOWN_PIN /**< Alias for BTN_DOWN_PIN */
#define BTN3_MODE BTN_DOWN_MODE /**< Alias for BTN_DOWN_MODE */

#define BTN_SELECT_PIN GPIO_PIN(PORT_A, 3) /**< GPIO pin for button "SELECT" */
#define BTN_SELECT_MODE GPIO_IN_PU /**< GPIO mode for button "SELECT" */
#define BTN4_PIN BTN_SELECT_PIN /**< Alias for BTN_SELECT_PIN */
#define BTN4_MODE BTN_SELECT_MODE /**< Alias for BTN_SELECT_MODE */
/** @} */

/**
* @name Flash Customer Configuration Area (CCA) parameters
* @{
*/
#ifndef UPDATE_CCA
#define UPDATE_CCA 1
#endif

#define CCA_BACKDOOR_ENABLE 1
#define CCA_BACKDOOR_PORT_A_PIN 3 /**< Select button */
#define CCA_BACKDOOR_ACTIVE_LEVEL 0 /**< Active low */
/** @} */

#ifdef __cplusplus
} /* end extern "C" */
#endif

#endif /* BOARD_H */
/** @} */
91 changes: 91 additions & 0 deletions boards/generic-cc2538-cc2592-dk/include/gpio_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2024 Marian Buschsieweke
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_generic_cc2538_cc2592_dk
* @{
*
* @file
* @brief Definitions for the Generic CC2538-CC2592-DK Board
*
* @author Marian Buschsieweke <marian.buschsieweke@posteo.net>
*/
#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H

#include "board.h"
#include "saul/periph.h"

#ifdef __cplusplus
extern "C"
{
#endif

/**
* @brief Expose LEDs and buttons via SAUL
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED Green",
.pin = LED_GREEN_PIN,
.mode = GPIO_OUT,
},
{
.name = "LED Red",
.pin = LED_RED_PIN,
.mode = GPIO_OUT,
},
{
.name = "LED Yellow",
.pin = LED_YELLOW_PIN,
.mode = GPIO_OUT,
},
{
.name = "LED Blue",
.pin = LED_BLUE_PIN,
.mode = GPIO_OUT,
},
{
.name = "BTN Left",
.pin = BTN_LEFT_PIN,
.mode = BTN_LEFT_MODE,
.flags = SAUL_GPIO_INVERTED,
},
{
.name = "BTN Right",
.pin = BTN_RIGHT_PIN,
.mode = BTN_RIGHT_MODE,
.flags = SAUL_GPIO_INVERTED,
},
{
.name = "BTN Up",
.pin = BTN_UP_PIN,
.mode = BTN_UP_MODE,
.flags = SAUL_GPIO_INVERTED,
},
{
.name = "BTN Down",
.pin = BTN_DOWN_PIN,
.mode = BTN_DOWN_MODE,
.flags = SAUL_GPIO_INVERTED,
},
{
.name = "BTN Select",
.pin = BTN_SELECT_PIN,
.mode = BTN_DOWN_MODE,
.flags = SAUL_GPIO_INVERTED,
},
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
Loading
Loading