From 238f91f1bbaef7b9beb41d3dbdb33bdc826aaea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Tue, 24 Apr 2018 18:50:34 +0200 Subject: [PATCH] kinetis: Add KL43Z support --- cpu/kinetis/Kconfig | 30 ++++++++++++++++++++++++ cpu/kinetis/Makefile.features | 2 ++ cpu/kinetis/include/cpu_conf_kinetis_l.h | 11 ++++++--- cpu/kinetis/include/periph_cpu.h | 7 ++++++ cpu/kinetis/include/vectors_kinetis.h | 2 ++ cpu/kinetis/isr_kinetis.c | 2 ++ cpu/kinetis/vectors.c | 13 ++++++++-- 7 files changed, 62 insertions(+), 5 deletions(-) diff --git a/cpu/kinetis/Kconfig b/cpu/kinetis/Kconfig index e7a6f9c042..7b9a4443cf 100644 --- a/cpu/kinetis/Kconfig +++ b/cpu/kinetis/Kconfig @@ -24,6 +24,11 @@ config CPU_FAM_K select HAS_PERIPH_FLASHPAGE_RAW select HAS_PERIPH_MCG +config CPU_FAM_L + bool + select CPU_COMMON_KINETIS + select HAS_PERIPH_MCG + config CPU_FAM_W bool select CPU_COMMON_KINETIS @@ -44,6 +49,26 @@ config CPU_MODEL_MK22FN512VLH12 select CPU_FAM_K select HAS_PERIPH_HWRNG +config CPU_MODEL_MKL43Z256VLH4 + bool + select CPU_CORE_CORTEX_M0PLUS + select CPU_FAM_L + +config CPU_MODEL_MKL43Z256VMP4 + bool + select CPU_CORE_CORTEX_M0PLUS + select CPU_FAM_L + +config CPU_MODEL_MKL43Z128VLH4 + bool + select CPU_CORE_CORTEX_M0PLUS + select CPU_FAM_L + +config CPU_MODEL_MKL43Z128VMP4 + bool + select CPU_CORE_CORTEX_M0PLUS + select CPU_FAM_L + config CPU_MODEL_MK60DN512VLL10 bool select CPU_CORE_CORTEX_M4 @@ -111,6 +136,7 @@ config HAS_PERIPH_ICS config CPU_FAM default "ea" if CPU_FAM_EA default "k" if CPU_FAM_K + default "l" if CPU_FAM_L default "w" if CPU_FAM_W config CPU_MODEL @@ -123,6 +149,10 @@ config CPU_MODEL default "mkw22d512vha5" if CPU_MODEL_MKW22D512VHA5 default "mkw41z256vht4" if CPU_MODEL_MKW41Z256VHT4 default "mkw41z512vht4" if CPU_MODEL_MKW41Z512VHT4 + default "mkl43z256vlh4" if CPU_MODEL_MKL43Z256VLH4 + default "mkl43z256vmp4" if CPU_MODEL_MKL43Z256VMP4 + default "mkl43z128vlh4" if CPU_MODEL_MKL43Z128VLH4 + default "mkl43z128vmp4" if CPU_MODEL_MKL43Z128VMP4 default "s9keaz128aclh" if CPU_MODEL_S9KEAZ128ACLH config CPU diff --git a/cpu/kinetis/Makefile.features b/cpu/kinetis/Makefile.features index 951b927e27..093bdc8dbb 100644 --- a/cpu/kinetis/Makefile.features +++ b/cpu/kinetis/Makefile.features @@ -3,6 +3,8 @@ FEATURES_PROVIDED += periph_pm # TRNG driver is not implemented for mkw41z models _KINETIS_CPU_MODELS_WITHOUT_HWRNG += mkw41z256vht4 mkw41z512vht4 +# TRNG driver is not implemented for kl43z models +_KINETIS_CPU_MODELS_WITHOUT_HWRNG += mkl43z% # No HWRNG in mk20d7 devices _KINETIS_CPU_MODELS_WITHOUT_HWRNG += mk20dx256vlh7 diff --git a/cpu/kinetis/include/cpu_conf_kinetis_l.h b/cpu/kinetis/include/cpu_conf_kinetis_l.h index e9e446e1b7..af369ad5f2 100644 --- a/cpu/kinetis/include/cpu_conf_kinetis_l.h +++ b/cpu/kinetis/include/cpu_conf_kinetis_l.h @@ -21,9 +21,14 @@ #ifndef CPU_CONF_KINETIS_L_H #define CPU_CONF_KINETIS_L_H -#if (KINETIS_FAMILY == 2) -#if (KINETIS_SUBFAMILY == 2) -/* Put your vendor includes here */ +#if (KINETIS_FAMILY == 4) +#if (KINETIS_SUBFAMILY == 3) +#if defined(CPU_MODEL_MKL43Z128VLH4) || \ + defined(CPU_MODEL_MKL43Z128VMP4) || \ + defined(CPU_MODEL_MKL43Z256VLH4) || \ + defined(CPU_MODEL_MKL43Z256VMP4) +#include "vendor/MKL43Z4.h" +#endif #endif /* (KINETIS_SUBFAMILY == y) */ #endif /* (KINETIS_FAMILY == x) */ diff --git a/cpu/kinetis/include/periph_cpu.h b/cpu/kinetis/include/periph_cpu.h index 12f461456e..9debb1b078 100644 --- a/cpu/kinetis/include/periph_cpu.h +++ b/cpu/kinetis/include/periph_cpu.h @@ -311,10 +311,17 @@ typedef enum { #ifdef KINETIS_HAVE_MK_SPI #define HAVE_SPI_MODE_T typedef enum { +#if defined(SPI_CTAR_CPHA_MASK) SPI_MODE_0 = 0, /**< CPOL=0, CPHA=0 */ SPI_MODE_1 = (SPI_CTAR_CPHA_MASK), /**< CPOL=0, CPHA=1 */ SPI_MODE_2 = (SPI_CTAR_CPOL_MASK), /**< CPOL=1, CPHA=0 */ SPI_MODE_3 = (SPI_CTAR_CPOL_MASK | SPI_CTAR_CPHA_MASK) /**< CPOL=1, CPHA=1 */ +#elif defined(SPI_C1_CPHA_MASK) + SPI_MODE_0 = 0, /**< CPOL=0, CPHA=0 */ + SPI_MODE_1 = (SPI_C1_CPHA_MASK), /**< CPOL=0, CPHA=1 */ + SPI_MODE_2 = (SPI_C1_CPOL_MASK), /**< CPOL=1, CPHA=0 */ + SPI_MODE_3 = (SPI_C1_CPOL_MASK | SPI_C1_CPHA_MASK) /**< CPOL=1, CPHA=1 */ +#endif } spi_mode_t; /** @} */ #endif /* KINETIS_HAVE_MK_SPI */ diff --git a/cpu/kinetis/include/vectors_kinetis.h b/cpu/kinetis/include/vectors_kinetis.h index 24649dbec2..ceea27d221 100644 --- a/cpu/kinetis/include/vectors_kinetis.h +++ b/cpu/kinetis/include/vectors_kinetis.h @@ -109,6 +109,7 @@ void isr_i2c0(void); /**< I2C0 interrupt handler */ void isr_i2c1(void); /**< I2C1 interrupt handler */ void isr_i2c2(void); /**< I2C2 interrupt handler */ void isr_i2c3(void); /**< I2C3 interrupt handler */ +void isr_i2s0(void); /**< I2S0 interrupt handler */ void isr_i2s0_rx(void); /**< I2S0 receive interrupt handler */ void isr_i2s0_tx(void); /**< I2S0 transmit interrupt handler */ void isr_llwu(void); /**< Low leakage wakeup interrupt handler */ @@ -159,6 +160,7 @@ void isr_uart1_err(void); /**< UART1 error interrupt handler */ void isr_uart1_rx_tx(void); /**< UART1 receive/transmit interrupt handler */ void isr_uart2(void); /**< UART2 unified interrupt handler */ void isr_uart2_err(void); /**< UART2 error interrupt handler */ +void isr_uart2_flexio(void); /**< UART2 or FlexIO interrupt handler */ void isr_uart2_rx_tx(void); /**< UART2 receive/transmit interrupt handler */ void isr_uart3(void); /**< UART3 unified interrupt handler */ void isr_uart3_err(void); /**< UART3 error interrupt handler */ diff --git a/cpu/kinetis/isr_kinetis.c b/cpu/kinetis/isr_kinetis.c index b16319a079..f473a99dd5 100644 --- a/cpu/kinetis/isr_kinetis.c +++ b/cpu/kinetis/isr_kinetis.c @@ -155,6 +155,7 @@ WEAK_DEFAULT void isr_i2c0(void); WEAK_DEFAULT void isr_i2c1(void); WEAK_DEFAULT void isr_i2c2(void); WEAK_DEFAULT void isr_i2c3(void); +WEAK_DEFAULT void isr_i2s0(void); WEAK_DEFAULT void isr_i2s0_rx(void); WEAK_DEFAULT void isr_i2s0_tx(void); WEAK_DEFAULT void isr_llwu(void); @@ -205,6 +206,7 @@ WEAK_DEFAULT void isr_uart1_err(void); WEAK_DEFAULT void isr_uart1_rx_tx(void); WEAK_DEFAULT void isr_uart2(void); WEAK_DEFAULT void isr_uart2_err(void); +WEAK_DEFAULT void isr_uart2_flexio(void); WEAK_DEFAULT void isr_uart2_rx_tx(void); WEAK_DEFAULT void isr_uart3(void); WEAK_DEFAULT void isr_uart3_err(void); diff --git a/cpu/kinetis/vectors.c b/cpu/kinetis/vectors.c index 0b8b0297d1..7b9609393b 100644 --- a/cpu/kinetis/vectors.c +++ b/cpu/kinetis/vectors.c @@ -183,8 +183,14 @@ ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = { [SPI2_IRQn ] = isr_spi2, /* SPI2 Interrupt */ #endif #ifdef I2S0 +#ifdef I2S_TCR1_TFW_MASK + /* K parts */ [I2S0_Tx_IRQn ] = isr_i2s0_tx, /* I2S0 transmit interrupt */ [I2S0_Rx_IRQn ] = isr_i2s0_rx, /* I2S0 receive interrupt */ +#else + /* KL parts */ + [I2S0_IRQn ] = isr_i2s0, /* I2S0 interrupt */ +#endif #endif #ifdef UART0 #ifdef KINETIS_SINGLE_UART_IRQ @@ -206,8 +212,11 @@ ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = { #endif #endif #ifdef UART2 -#ifdef KINETIS_SINGLE_UART_IRQ - [UART2_IRQn] = isr_uart2, /* UART2 interrupt */ +#if defined(KINETIS_SINGLE_UART_IRQ) + [UART2_IRQn] = isr_uart2, /* UART2 interrupt */ +#elif defined(FLEXIO_VERID_MAJOR_MASK) + /* KL parts with FlexIO uses combined IRQ */ + [UART2_FLEXIO_IRQn] = isr_uart2_flexio, /* UART2 or FLEXIO */ #else [UART2_RX_TX_IRQn] = isr_uart2_rx_tx, /* UART2 Receive/Transmit interrupt */ [UART2_ERR_IRQn ] = isr_uart2_err, /* UART2 Error interrupt */