-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21201 from dylad/pr/cpu/sam4s/add_support
cpu/sam4s: add initial support with SAM4S-XPRO board
- Loading branch information
Showing
31 changed files
with
727 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = board | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CPU = sam4s | ||
CPU_MODEL = sam4sd32c | ||
|
||
# Put defined MCU peripherals here (in alphabetical order) | ||
FEATURES_PROVIDED += periph_gpio periph_gpio_irq | ||
FEATURES_PROVIDED += periph_timer | ||
FEATURES_PROVIDED += periph_uart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# export this module and its includes | ||
INCLUDES += -I$(RIOTBOARD)/sam4s-xpro/include | ||
|
||
# setup flasher (using openOCD) | ||
PROGRAMMER ?= openocd | ||
PROGRAMMERS_SUPPORTED += openocd edbg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source [find board/atmel_sam4s_xplained_pro.cfg] | ||
$_TARGETNAME configure -rtos auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
@defgroup boards_sam4s-xpro ATSAM4S Xplained Pro board | ||
@ingroup boards | ||
@brief Support for the ATSAM4S Xplained Pro board | ||
|
||
## Overview | ||
|
||
The `ATSAM4S Xplained Pro` is an evaluation board by Microchip (formerly Atmel) | ||
featuring a SAM4SD32 (Cortex-M4) SoC running up to 120 MHz. This MCU comes with | ||
160Kb of RAM and 2048Kb of flash memory. | ||
|
||
## Hardware | ||
|
||
 | ||
|
||
|
||
### MCU | ||
| MCU | ATSAM4SD32C | | ||
|:------------- |:--------------------- | | ||
| Family | ARM Cortex-M4 | | ||
| Vendor | Microchip | | ||
| RAM | 160Kb | | ||
| Flash | 2048Kb | | ||
| Frequency | up to 120MHz | | ||
| FPU | no | | ||
| Timers | 2 three channels (16-bit) | | ||
| ADCs | 1x 12-bit (16 channels) | | ||
| UARTs | 2 UARTs (+ 2 USARTs shared with SPIs) | | ||
| SPIs | 2 shared with USARTs | | ||
| I2Cs | 2 | | ||
| Datasheet | [Datasheet](https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/DataSheets/Atmel-11100-32-bitCortex-M4-Microcontroller-SAM4S_Datasheet.pdf) | | ||
| Board Manual | [Board Manual](https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ProductDocuments/UserGuides/Atmel-42075-SAM4S-Xplained-Pro_User-Guide.pdf)| | ||
|
||
### User Interface | ||
|
||
1 User button and 1 LED: | ||
|
||
| Device | PIN | | ||
|:------ |:--- | | ||
| LED0 | PC23 | | ||
| SW0 (button) | PA02 | | ||
|
||
### Flashing options | ||
By default, openOCD is used for both flashing and debugging. | ||
EDBG programmer is also available with: | ||
`PROGRAMMER=edbg BOARD=sam4s-xpro make -C tests/leds flash` | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2025 Mesotic SAS | ||
* 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_sam4s-xpro | ||
* @{ | ||
* | ||
* @file | ||
* @brief Board specific definitions for the Microchip SAM 4S Xplained Pro | ||
* board | ||
* | ||
* @author Dylan Laduranty <dylan.laduranty@mesotic.com> | ||
*/ | ||
|
||
#ifndef BOARD_H | ||
#define BOARD_H | ||
|
||
#include "cpu.h" | ||
#include "periph_conf.h" | ||
#include "periph_cpu.h" | ||
#include "periph/gpio.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name ztimer configuration | ||
* @{ | ||
*/ | ||
#define CONFIG_ZTIMER_USEC_WIDTH (16) | ||
/** @} */ | ||
|
||
/** | ||
* @name LED pin definitions and handlers | ||
* @{ | ||
*/ | ||
#define LED0_PIN GPIO_PIN(PC, 23) | ||
|
||
#define LED0_ON (PIOC->PIO_CODR = PIO_PC23) | ||
#define LED0_OFF (PIOC->PIO_SODR = PIO_PC23) | ||
#define LED0_TOGGLE ((PIOC->PIO_ODSR & PIO_PC23) ? LED0_ON : LED0_OFF) | ||
/** @} */ | ||
|
||
/** | ||
* @name SW0 (Button) pin definitions | ||
* @{ | ||
*/ | ||
#define BTN0_PIN GPIO_PIN(PA, 2) | ||
#define BTN0_MODE GPIO_IN_PU | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* BOARD_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2025 Mesotic SAS | ||
* | ||
* 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_sam4s-xpro | ||
* @{ | ||
* | ||
* @file | ||
* @brief Peripheral MCU configuration for SAM4S Xplained pro | ||
* | ||
* @author Dylan Laduranty <dylan.laduranty@mesotic.com> | ||
*/ | ||
|
||
#ifndef PERIPH_CONF_H | ||
#define PERIPH_CONF_H | ||
|
||
#include "periph_cpu.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name Clock configuration | ||
* @{ | ||
*/ | ||
/* targeted system core clock */ | ||
#define CLOCK_CORECLOCK MHZ(120) | ||
/* external oscillator clock */ | ||
#define CLOCK_EXT_OSC MHZ(12) | ||
/* define PLL configuration | ||
* | ||
* The values must fulfill this equation: | ||
* CORECLOCK = (EXT_OCS / PLL_DIV) * (PLL_MUL + 1) | ||
*/ | ||
#define CLOCK_PLL_MUL (9) | ||
#define CLOCK_PLL_DIV (1) | ||
|
||
/* number of wait states before flash read and write operations */ | ||
#define CLOCK_FWS (5) /* 5 is safe for 120 MHz */ | ||
/** @} */ | ||
|
||
/** | ||
* @brief Enable external oscillator for driving the slow clock | ||
*/ | ||
#define CLOCK_SCLK_XTAL (1) | ||
|
||
/** | ||
* @name Timer peripheral configuration | ||
* @{ | ||
*/ | ||
static const timer_conf_t timer_config[] = { | ||
{ .dev = TC0, .id_ch0 = ID_TC0 }, | ||
{ .dev = TC1, .id_ch0 = ID_TC3 } | ||
}; | ||
|
||
#define TIMER_0_ISR isr_tc0 | ||
#define TIMER_1_ISR isr_tc3 | ||
|
||
#define TIMER_NUMOF ARRAY_SIZE(timer_config) | ||
/** @} */ | ||
|
||
/** | ||
* @name UART configuration | ||
* @{ | ||
*/ | ||
static const uart_conf_t uart_config[] = { | ||
{ | ||
.dev = (Uart *)UART1, | ||
.rx_pin = GPIO_PIN(PB, 2), | ||
.tx_pin = GPIO_PIN(PB, 3), | ||
.mux = GPIO_MUX_A, | ||
.pmc_id = ID_UART1, | ||
.irqn = UART1_IRQn | ||
} | ||
}; | ||
|
||
/* define interrupt vectors */ | ||
#define UART_0_ISR isr_uart1 | ||
|
||
#define UART_NUMOF ARRAY_SIZE(uart_config) | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* PERIPH_CONF_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include $(RIOTCPU)/cortexm_common/Makefile.dep | ||
include $(RIOTCPU)/sam_common/Makefile.dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
ROM_START_ADDR ?= 0x80000 | ||
RAM_START_ADDR ?= 0x20070000 | ||
|
||
ROM_LEN ?= 0x80000 | ||
RAM_LEN ?= 0x18000 | ||
|
||
include $(RIOTCPU)/sam_common/Makefile.include | ||
include $(RIOTMAKE)/arch/cortexm.inc.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.