Skip to content

Commit 363fb75

Browse files
committed
boards/sam4s-xpro: introduce initial board support
Signed-off-by: dylad <dylan.laduranty@mesotic.com>
1 parent 8cfc42b commit 363fb75

7 files changed

Lines changed: 222 additions & 0 deletions

File tree

boards/sam4s-xpro/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MODULE = board
2+
3+
include $(RIOTBASE)/Makefile.base
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CPU = sam4s
2+
CPU_MODEL = sam4sd32c
3+
4+
# Put defined MCU peripherals here (in alphabetical order)
5+
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
6+
FEATURES_PROVIDED += periph_timer
7+
FEATURES_PROVIDED += periph_uart

boards/sam4s-xpro/Makefile.include

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# export this module and its includes
2+
INCLUDES += -I$(RIOTBOARD)/sam4s-xpro/include
3+
4+
# setup flasher (using openOCD)
5+
PROGRAMMER ?= openocd
6+
PROGRAMMERS_SUPPORTED += openocd edbg

boards/sam4s-xpro/dist/openocd.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
source [find board/atmel_sam4s_xplained_pro.cfg]
2+
$_TARGETNAME configure -rtos auto

boards/sam4s-xpro/doc.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
@defgroup boards_sam4s-xpro ATSAM4S Xplained Pro board
3+
@ingroup boards
4+
@brief Support for the ATSAM4S Xplained Pro board
5+
6+
## Overview
7+
8+
The `ATSAM4S Xplained Pro` is an evaluation board by Microchip (formerly Atmel)
9+
featuring a SAM4SD32 (Cortex-M4) SoC running up to 120 MHz. This MCU comes with
10+
160Kb of RAM and 2048Kb of flash memory.
11+
12+
## Hardware
13+
14+
![sam4s-xpro image](https://www.microchip.com/content/dam/mchp/mrt-dam/devtools/1801-atsam4s-xpro.jpg)
15+
16+
17+
### MCU
18+
| MCU | ATSAM4SD32C |
19+
|:------------- |:--------------------- |
20+
| Family | ARM Cortex-M4 |
21+
| Vendor | Microchip |
22+
| RAM | 160Kb |
23+
| Flash | 2048Kb |
24+
| Frequency | up to 120MHz |
25+
| FPU | no |
26+
| Timers | 2 three channels (16-bit) |
27+
| ADCs | 1x 12-bit (16 channels) |
28+
| UARTs | 2 UARTs (+ 2 USARTs shared with SPIs) |
29+
| SPIs | 2 shared with USARTs |
30+
| I2Cs | 2 |
31+
| Datasheet | [Datasheet](https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/Atmel-11100-32-bitCortex-M4-Microcontroller-SAM4S_Datasheet.pdf) |
32+
| Board Manual | [Board Manual](https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/UserGuides/Atmel-42075-SAM4S-Xplained-Pro_User-Guide.pdf)|
33+
34+
### User Interface
35+
36+
1 User button and 1 LED:
37+
38+
| Device | PIN |
39+
|:------ |:--- |
40+
| LED0 | PC23 |
41+
| SW0 (button) | PA02 |
42+
43+
### Flashing options
44+
By default, openOCD is used for both flashing and debugging.
45+
EDBG programmer is also available with:
46+
`PROGRAMMER=edbg BOARD=sam4s-xpro make -C tests/leds flash`
47+
48+
*/

boards/sam4s-xpro/include/board.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (C) 2025 Mesotic SAS
3+
* This file is subject to the terms and conditions of the GNU Lesser
4+
* General Public License v2.1. See the file LICENSE in the top level
5+
* directory for more details.
6+
*/
7+
8+
/**
9+
* @ingroup boards_sam4s-xpro
10+
* @{
11+
*
12+
* @file
13+
* @brief Board specific definitions for the Microchip SAM 4S Xplained Pro
14+
* board
15+
*
16+
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
17+
*/
18+
19+
#ifndef BOARD_H
20+
#define BOARD_H
21+
22+
#include "cpu.h"
23+
#include "periph_conf.h"
24+
#include "periph_cpu.h"
25+
#include "periph/gpio.h"
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
/**
32+
* @name ztimer configuration
33+
* @{
34+
*/
35+
#define CONFIG_ZTIMER_USEC_WIDTH (16)
36+
/** @} */
37+
38+
/**
39+
* @name LED pin definitions and handlers
40+
* @{
41+
*/
42+
#define LED0_PIN GPIO_PIN(PC, 23)
43+
44+
#define LED0_ON (PIOC->PIO_CODR = PIO_PC23)
45+
#define LED0_OFF (PIOC->PIO_SODR = PIO_PC23)
46+
#define LED0_TOGGLE ((PIOC->PIO_ODSR & PIO_PC23) ? LED0_ON : LED0_OFF)
47+
/** @} */
48+
49+
/**
50+
* @name SW0 (Button) pin definitions
51+
* @{
52+
*/
53+
#define BTN0_PIN GPIO_PIN(PA, 2)
54+
#define BTN0_MODE GPIO_IN_PU
55+
/** @} */
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif
60+
61+
#endif /* BOARD_H */
62+
/** @} */
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (C) 2025 Mesotic SAS
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser
5+
* General Public License v2.1. See the file LICENSE in the top level
6+
* directory for more details.
7+
*/
8+
9+
/**
10+
* @ingroup boards_sam4s-xpro
11+
* @{
12+
*
13+
* @file
14+
* @brief Peripheral MCU configuration for SAM4S Xplained pro
15+
*
16+
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
17+
*/
18+
19+
#ifndef PERIPH_CONF_H
20+
#define PERIPH_CONF_H
21+
22+
#include "periph_cpu.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
/**
29+
* @name Clock configuration
30+
* @{
31+
*/
32+
/* targeted system core clock */
33+
#define CLOCK_CORECLOCK MHZ(120)
34+
/* external oscillator clock */
35+
#define CLOCK_EXT_OSC MHZ(12)
36+
/* define PLL configuration
37+
*
38+
* The values must fulfill this equation:
39+
* CORECLOCK = (EXT_OCS / PLL_DIV) * (PLL_MUL + 1)
40+
*/
41+
#define CLOCK_PLL_MUL (9)
42+
#define CLOCK_PLL_DIV (1)
43+
44+
/* number of wait states before flash read and write operations */
45+
#define CLOCK_FWS (5) /* 5 is safe for 120 MHz */
46+
/** @} */
47+
48+
/**
49+
* @brief Enable external oscillator for driving the slow clock
50+
*/
51+
#define CLOCK_SCLK_XTAL (1)
52+
53+
/**
54+
* @name Timer peripheral configuration
55+
* @{
56+
*/
57+
static const timer_conf_t timer_config[] = {
58+
{ .dev = TC0, .id_ch0 = ID_TC0 },
59+
{ .dev = TC1, .id_ch0 = ID_TC3 }
60+
};
61+
62+
#define TIMER_0_ISR isr_tc0
63+
#define TIMER_1_ISR isr_tc3
64+
65+
#define TIMER_NUMOF ARRAY_SIZE(timer_config)
66+
/** @} */
67+
68+
/**
69+
* @name UART configuration
70+
* @{
71+
*/
72+
static const uart_conf_t uart_config[] = {
73+
{
74+
.dev = (Uart *)UART1,
75+
.rx_pin = GPIO_PIN(PB, 2),
76+
.tx_pin = GPIO_PIN(PB, 3),
77+
.mux = GPIO_MUX_A,
78+
.pmc_id = ID_UART1,
79+
.irqn = UART1_IRQn
80+
}
81+
};
82+
83+
/* define interrupt vectors */
84+
#define UART_0_ISR isr_uart1
85+
86+
#define UART_NUMOF ARRAY_SIZE(uart_config)
87+
/** @} */
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
93+
#endif /* PERIPH_CONF_H */
94+
/** @} */

0 commit comments

Comments
 (0)