Skip to content

Commit

Permalink
Merge #19580
Browse files Browse the repository at this point in the history
19580: board: add Adafruit Grand Central M4 Express support r=maribu a=gschorcht

### Contribution description

This PR provides the support for Adafruit Grand Central M4 Express board. The main features of the board are:

- ATSAMD51 Cortex M4 running at 120 MHz
- 1MB Flash
- 256 KB RAM
- external 8 MB QSPI Flash storage
- Micro SD Card slot connected to SPI

### Testing procedure


### Issues/PRs references


Co-authored-by: Gunar Schorcht <[email protected]>
  • Loading branch information
bors[bot] and gschorcht authored Jun 9, 2023
2 parents ed95055 + 3d9d93e commit 0e09b43
Show file tree
Hide file tree
Showing 12 changed files with 847 additions and 0 deletions.
35 changes: 35 additions & 0 deletions boards/adafruit-grand-central-m4-express/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2023 Gunar Schorcht
#
# 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 "adafruit-grand-central-m4-express" if BOARD_ADAFRUIT_GRAND_CENTRAL_M4_EXPRESS

config BOARD_ADAFRUIT_GRAND_CENTRAL_M4_EXPRESS
bool
default y
select CPU_MODEL_SAMD51P20A
select HAS_ARDUINO
select HAS_HIGHLEVEL_STDIO
select HAS_PERIPH_ADC
select HAS_PERIPH_DAC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_RTC
select HAS_PERIPH_RTT
select HAS_PERIPH_SPI
select HAS_PERIPH_TIMER
select HAS_PERIPH_UART
select HAS_PERIPH_USBDEV
select HAVE_SAUL_GPIO

select HAVE_MTD_SPI_NOR
# This specific board requires SPI_ON_QSPI for the MTD_SPI_NOR
select MODULE_PERIPH_SPI_ON_QSPI if MODULE_MTD_SPI_NOR

select HAVE_MTD_SDCARD_DEFAULT
select MODULE_FATFS_VFS if MODULE_VFS_DEFAULT

source "$(RIOTBOARD)/common/samdx1-arduino-bootloader/Kconfig"
5 changes: 5 additions & 0 deletions boards/adafruit-grand-central-m4-express/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
MODULE = board

DIRS = $(RIOTBOARD)/common/samdx1-arduino-bootloader

include $(RIOTBASE)/Makefile.base
19 changes: 19 additions & 0 deletions boards/adafruit-grand-central-m4-express/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif

# default to using fatfs on SD card
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEPKG += littlefs2
USEMODULE += fatfs_vfs
USEMODULE += mtd
endif

ifneq (,$(filter mtd,$(USEMODULE)))
FEATURES_REQUIRED += periph_spi_on_qspi
USEMODULE += mtd_spi_nor
USEMODULE += mtd_sdcard_default
endif

# setup the samd21 arduino bootloader related dependencies
include $(RIOTBOARD)/common/samdx1-arduino-bootloader/Makefile.dep
19 changes: 19 additions & 0 deletions boards/adafruit-grand-central-m4-express/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CPU = samd5x
CPU_MODEL = samd51p20a

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

# other board features
FEATURES_PROVIDED += arduino
FEATURES_PROVIDED += sdcard_spi
6 changes: 6 additions & 0 deletions boards/adafruit-grand-central-m4-express/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CFLAGS += -DBOOTLOADER_UF2

# Include all definitions for flashing with bossa other USB
include $(RIOTBOARD)/common/samdx1-arduino-bootloader/Makefile.include
# Include handling of serial and non-bossa programmers (if selected by user)
include $(RIOTMAKE)/boards/sam0.inc.mk
68 changes: 68 additions & 0 deletions boards/adafruit-grand-central-m4-express/board.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (C) 2021 ML!PA Consulting GmbH
* 2023 Gunar Schorcht
*
* 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_adafruit-grand-central-m4-express
* @{
*
* @file
* @brief Board specific implementations for the Adafruit Grand Central M4 Express
*
* @author Benjamin Valentin <[email protected]>
* @author Gunar Schorcht <[email protected]>
* @}
*/

#include "board.h"
#include "periph/gpio.h"
#include "timex.h"
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
#endif

#ifdef MODULE_MTD_SPI_NOR

#include "mtd_spi_nor.h"

/* GD25Q64 */
static const mtd_spi_nor_params_t _samd51_nor_params = {
.opcode = &mtd_spi_nor_opcode_default,
.wait_chip_erase = 25 * US_PER_SEC,
.wait_32k_erase = 150 * US_PER_MS,
.wait_64k_erase = 200 * US_PER_MS,
.wait_sector_erase = 50 * US_PER_MS,
.wait_chip_wake_up = 10 * US_PER_MS,
.clk = MHZ(54),
.flag = SPI_NOR_F_SECT_4K
| SPI_NOR_F_SECT_32K
| SPI_NOR_F_SECT_64K,
.spi = SPI_DEV(2),
.mode = SPI_MODE_0,
.cs = SAM0_QSPI_PIN_CS,
.wp = SAM0_QSPI_PIN_DATA_2,
.hold = SAM0_QSPI_PIN_DATA_3,
};

static mtd_spi_nor_t samd51_nor_dev = {
.base = {
.driver = &mtd_spi_nor_driver,
.sector_count = 2048,
.page_size = 256,
.pages_per_sector = 16,
},
.params = &_samd51_nor_params,
};

mtd_dev_t *mtd0 = (mtd_dev_t *)&samd51_nor_dev;

#ifdef MODULE_VFS_DEFAULT
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(samd51_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif

#endif /* MODULE_MTD_SPI_NOR */
45 changes: 45 additions & 0 deletions boards/adafruit-grand-central-m4-express/doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
@defgroup boards_adafruit-grand-central-m4-express Adafruit Grand Central M4 Express
@ingroup boards
@brief Support for the Adafruit Grand Central M4 Express

### General information

![Adafruit Grand Central M4 Expressboard]
(https://cdn-learn.adafruit.com/assets/assets/000/068/748/medium800/adafruit_products_grand_central_top_angle.jpg?1546734839)

The main features of the board are:
- ATSAMD51 Cortex M4 running at 120 MHz
- Hardware DSP and floating point support
- 1MB Flash
- 256 KB RAM
- external 8 MB QSPI Flash storage
- 32-bit, 3.3V logic and power
- Micro SD Card slot connected to SPI
- native USB

### Links

- [Overview](https://learn.adafruit.com/adafruit-grand-central)
- [Schematics](https://learn.adafruit.com/assets/69175)

### Flash the board

The board is flashed using its on-board
[boot loader](https://github.com/adafruit/uf2-samdx1).

The process is automated in the usual `make flash` target.

If RIOT is already running on the board, it will automatically reset the CPU
and enter the bootloader. If some other firmware is running or RIOT crashed,
you need to enter the bootloader manually by double tapping the board's reset
button.

Readiness of the bootloader is indicated by LED pulsing in red.

### Accessing STDIO

The usual way to obtain a console on this board is using an emulated USB serial
port.

*/
73 changes: 73 additions & 0 deletions boards/adafruit-grand-central-m4-express/include/arduino_board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2017 Inria
*
* 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_common_nucleo144
* @{
*
* @file
* @brief Board specific configuration for the Arduino API
*
* @author Alexandre Abadie <[email protected]>
*/

#ifndef ARDUINO_BOARD_H
#define ARDUINO_BOARD_H

#include "arduino_pinmap.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Look-up table for the Arduino's digital pins
*/
static const gpio_t arduino_pinmap[] = {
ARDUINO_PIN_0,
ARDUINO_PIN_1,
ARDUINO_PIN_2,
ARDUINO_PIN_3,
ARDUINO_PIN_4,
ARDUINO_PIN_5,
ARDUINO_PIN_6,
ARDUINO_PIN_7,
ARDUINO_PIN_8,
ARDUINO_PIN_9,
ARDUINO_PIN_10,
ARDUINO_PIN_11,
ARDUINO_PIN_12,
ARDUINO_PIN_13,
ARDUINO_PIN_14,
ARDUINO_PIN_15,
ARDUINO_PIN_A0,
ARDUINO_PIN_A1,
ARDUINO_PIN_A2,
ARDUINO_PIN_A3,
ARDUINO_PIN_A4,
ARDUINO_PIN_A5,
};

/**
* @brief Look-up table for the Arduino's analog pins
*/
static const adc_t arduino_analog_map[] = {
ARDUINO_A0,
ARDUINO_A1,
ARDUINO_A2,
ARDUINO_A3,
ARDUINO_A4,
ARDUINO_A5,
};

#ifdef __cplusplus
}
#endif

#endif /* ARDUINO_BOARD_H */
/** @} */
77 changes: 77 additions & 0 deletions boards/adafruit-grand-central-m4-express/include/arduino_pinmap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2023 Gunar Schorcht
*
* 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_adafruit-grand-central-m4-express
* @{
*
* @file
* @brief Mapping from MCU pins to Arduino pins
*
* @author Gunar Schorcht <[email protected]>
*/

#ifndef ARDUINO_PINMAP_H
#define ARDUINO_PINMAP_H

#include "periph/gpio.h"
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name Mapping of MCU pins to Arduino pins
* @{
*/
#define ARDUINO_PIN_0 GPIO_PIN(PB, 25)
#define ARDUINO_PIN_1 GPIO_PIN(PB, 24)
#define ARDUINO_PIN_2 GPIO_PIN(PC, 18)
#define ARDUINO_PIN_3 GPIO_PIN(PC, 19)
#define ARDUINO_PIN_4 GPIO_PIN(PC, 20)
#define ARDUINO_PIN_5 GPIO_PIN(PC, 21)
#define ARDUINO_PIN_6 GPIO_PIN(PD, 20)
#define ARDUINO_PIN_7 GPIO_PIN(PD, 21)

#define ARDUINO_PIN_8 GPIO_PIN(PB, 18)
#define ARDUINO_PIN_9 GPIO_PIN(PB, 02)
#define ARDUINO_PIN_10 GPIO_PIN(PB, 22)
#define ARDUINO_PIN_11 GPIO_PIN(PB, 23)
#define ARDUINO_PIN_12 GPIO_PIN(PB, 00)
#define ARDUINO_PIN_13 GPIO_PIN(PB, 01)

#define ARDUINO_PIN_14 GPIO_PIN(PB, 20)
#define ARDUINO_PIN_15 GPIO_PIN(PB, 21)

#define ARDUINO_PIN_A0 GPIO_PIN(PA, 3)
#define ARDUINO_PIN_A1 GPIO_PIN(PC, 0)
#define ARDUINO_PIN_A2 GPIO_PIN(PC, 3)
#define ARDUINO_PIN_A3 GPIO_PIN(PC, 1)
#define ARDUINO_PIN_A4 GPIO_PIN(PC, 4)
#define ARDUINO_PIN_A5 GPIO_PIN(PC, 5)
/** @} */

/**
* @name Mapping of Arduino analog pins to RIOT ADC lines
* @{
*/
#define ARDUINO_A0 ADC_LINE(0)
#define ARDUINO_A1 ADC_LINE(1)
#define ARDUINO_A2 ADC_LINE(2)
#define ARDUINO_A3 ADC_LINE(3)
#define ARDUINO_A4 ADC_LINE(4)
#define ARDUINO_A5 ADC_LINE(5)
/** @} */

#ifdef __cplusplus
}
#endif

#endif /* ARDUINO_PINMAP_H */
/** @} */
Loading

0 comments on commit 0e09b43

Please sign in to comment.