1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/samd5x: define CPU_COMMON_SAMD5X symbol and use it

This commit is contained in:
Benjamin Valentin 2020-08-21 13:27:22 +02:00
parent cc7f897cbc
commit 7ed4979148
8 changed files with 16 additions and 14 deletions

View File

@ -625,7 +625,7 @@ static inline void sercom_clk_en(void *sercom)
const uint8_t id = sercom_id(sercom);
#if defined(CPU_COMMON_SAMD21)
PM->APBCMASK.reg |= (PM_APBCMASK_SERCOM0 << id);
#elif defined (CPU_FAM_SAMD5X)
#elif defined (CPU_COMMON_SAMD5X)
if (id < 2) {
MCLK->APBAMASK.reg |= (1 << (id + 12));
} else if (id < 4) {
@ -655,7 +655,7 @@ static inline void sercom_clk_dis(void *sercom)
const uint8_t id = sercom_id(sercom);
#if defined(CPU_COMMON_SAMD21)
PM->APBCMASK.reg &= ~(PM_APBCMASK_SERCOM0 << id);
#elif defined (CPU_FAM_SAMD5X)
#elif defined (CPU_COMMON_SAMD5X)
if (id < 2) {
MCLK->APBAMASK.reg &= ~(1 << (id + 12));
} else if (id < 4) {
@ -675,7 +675,7 @@ static inline void sercom_clk_dis(void *sercom)
#endif
}
#ifdef CPU_FAM_SAMD5X
#ifdef CPU_COMMON_SAMD5X
static inline uint8_t _sercom_gclk_id_core(uint8_t sercom_id) {
if (sercom_id < 2)
return sercom_id + 7;
@ -700,7 +700,7 @@ static inline void sercom_set_gen(void *sercom, uint8_t gclk)
GCLK->CLKCTRL.reg = (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN(gclk) |
(SERCOM0_GCLK_ID_CORE + id));
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY) {}
#elif defined(CPU_FAM_SAMD5X)
#elif defined(CPU_COMMON_SAMD5X)
GCLK->PCHCTRL[_sercom_gclk_id_core(id)].reg = (GCLK_PCHCTRL_CHEN | GCLK_PCHCTRL_GEN(gclk));
#else
if (id < 5) {

View File

@ -25,7 +25,7 @@
#include "periph/cpuid.h"
#ifdef CPU_SAMD5X
#ifdef CPU_COMMON_SAMD5X
#define WORD0 (*(volatile uint32_t *)0x008061FC)
#define WORD1 (*(volatile uint32_t *)0x00806010)
#define WORD2 (*(volatile uint32_t *)0x00806014)

View File

@ -81,7 +81,7 @@ void dma_init(void)
NVIC_EnableIRQ(DMAC_1_IRQn);
NVIC_EnableIRQ(DMAC_2_IRQn);
NVIC_EnableIRQ(DMAC_3_IRQn);
#elif defined(CPU_FAM_SAMD5X)
#elif defined(CPU_COMMON_SAMD5X)
NVIC_EnableIRQ(DMAC_0_IRQn);
NVIC_EnableIRQ(DMAC_1_IRQn);
NVIC_EnableIRQ(DMAC_2_IRQn);

View File

@ -234,7 +234,7 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
#ifdef CPU_COMMON_SAML1X
/* EXTI[4..7] are binded to EIC_OTHER_IRQn */
NVIC_EnableIRQ((exti > 3 )? EIC_OTHER_IRQn : (EIC_0_IRQn + exti));
#elif defined(CPU_SAMD5X)
#elif defined(CPU_COMMON_SAMD5X)
NVIC_EnableIRQ(EIC_0_IRQn + exti);
#else
NVIC_EnableIRQ(EIC_IRQn);
@ -360,7 +360,7 @@ void isr_eic(void)
cortexm_isr_end();
}
#if defined(CPU_COMMON_SAML1X) || defined(CPU_SAMD5X)
#if defined(CPU_COMMON_SAML1X) || defined(CPU_COMMON_SAMD5X)
#define ISR_EICn(n) \
void isr_eic ## n (void) \
@ -374,7 +374,7 @@ ISR_EICn(0)
ISR_EICn(1)
ISR_EICn(2)
ISR_EICn(3)
#if defined(CPU_SAMD5X)
#if defined(CPU_COMMON_SAMD5X)
ISR_EICn(4)
ISR_EICn(5)
ISR_EICn(6)
@ -389,8 +389,8 @@ ISR_EICn(13)
ISR_EICn(14)
ISR_EICn(15)
#endif /* NUMOF_IRQS > 8 */
#endif /* CPU_SAMD5X */
#endif /* CPU_COMMON_SAML1X || CPU_SAMD5X */
#endif /* CPU_COMMON_SAMD5X */
#endif /* CPU_COMMON_SAML1X || CPU_COMMON_SAMD5X */
#else /* MODULE_PERIPH_GPIO_IRQ */

View File

@ -45,7 +45,7 @@
#define BUSSTATE_OWNER SERCOM_I2CM_STATUS_BUSSTATE(2)
#define BUSSTATE_BUSY SERCOM_I2CM_STATUS_BUSSTATE(3)
#if defined(CPU_COMMON_SAML21) || defined(CPU_COMMON_SAML1X) || defined(CPU_SAMD5X)
#if defined(CPU_COMMON_SAML21) || defined(CPU_COMMON_SAML1X) || defined(CPU_COMMON_SAMD5X)
#define SERCOM_I2CM_CTRLA_MODE_I2C_MASTER SERCOM_I2CM_CTRLA_MODE(5)
#endif

View File

@ -32,7 +32,7 @@
#define ENABLE_DEBUG (0)
#include "debug.h"
#if defined (CPU_COMMON_SAML1X) || defined (CPU_SAMD5X)
#if defined (CPU_COMMON_SAML1X) || defined (CPU_COMMON_SAMD5X)
#define UART_HAS_TX_ISR
#endif

View File

@ -363,7 +363,7 @@ static void _usbdev_init(usbdev_t *dev)
_block_pm();
usbdev->usbdev.cb(&usbdev->usbdev, USBDEV_EVENT_HOST_CONNECT);
/* Interrupt configuration */
#ifdef CPU_FAM_SAMD5X
#ifdef CPU_COMMON_SAMD5X
NVIC_EnableIRQ(USB_0_IRQn);
NVIC_EnableIRQ(USB_1_IRQn);
NVIC_EnableIRQ(USB_2_IRQn);

View File

@ -5,6 +5,8 @@ ifneq (,$(filter same54%,$(CPU_MODEL)))
CFLAGS += -DCPU_SAME54
endif
CFLAGS += -DCPU_COMMON_SAMD5X
# Slot size is determined by "((total_flash_size - RIOTBOOT_LEN) / 2)".
# If RIOTBOOT_LEN uses an uneven number of flashpages, the remainder of the
# flash cannot be divided by two slots while staying FLASHPAGE_SIZE aligned.