24#include "periph_cpu.h"
45#define RTC_LOAD_CAP_BITS (RTC_CR_SC8P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC2P_MASK)
47static const clock_config_t clock_config = {
60 .clkdiv1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) |
61 SIM_CLKDIV1_OUTDIV3(1) | SIM_CLKDIV1_OUTDIV4(1),
62 .rtc_clc = RTC_LOAD_CAP_BITS,
63 .osc32ksel = SIM_SOPT1_OSC32KSEL(2),
66 KINETIS_CLOCK_RTCOSC_EN |
67 KINETIS_CLOCK_USE_FAST_IRC |
69 .default_mode = KINETIS_MCG_MODE_FEE,
70 .erc_range = KINETIS_MCG_ERC_RANGE_LOW,
73 .osc_clc = OSC_CR_SC16P_MASK,
74 .oscsel = MCG_C7_OSCSEL(1),
75 .fcrdiv = MCG_SC_FCRDIV(0),
76 .fll_frdiv = MCG_C1_FRDIV(0b000),
77 .fll_factor_fei = KINETIS_MCG_FLL_FACTOR_1464,
78 .fll_factor_fee = KINETIS_MCG_FLL_FACTOR_1464,
82 .pll_prdiv = MCG_C5_PRDIV0(0b00111),
83 .pll_vdiv = MCG_C6_VDIV0(0b01100),
85#define CLOCK_CORECLOCK (48000000ul)
86#define CLOCK_BUSCLOCK (CLOCK_CORECLOCK / 1)
104#define LPTMR_NUMOF (1U)
105#define LPTMR_CONFIG { \
108 .irqn = LPTMR0_IRQn, \
110 .base_freq = 32768u, \
113#define TIMER_NUMOF ((PIT_NUMOF) + (LPTMR_NUMOF))
115#define PIT_BASECLOCK (CLOCK_BUSCLOCK)
116#define PIT_ISR_0 isr_pit1
117#define PIT_ISR_1 isr_pit3
118#define LPTMR_ISR_0 isr_lptmr0
132 .pcr_rx = PORT_PCR_MUX(3),
133 .pcr_tx = PORT_PCR_MUX(3),
134 .irqn = UART0_RX_TX_IRQn,
135 .scgc_addr = &SIM->SCGC4,
136 .scgc_bit = SIM_SCGC4_UART0_SHIFT,
145 .pcr_rx = PORT_PCR_MUX(3),
146 .pcr_tx = PORT_PCR_MUX(3),
147 .irqn = UART1_RX_TX_IRQn,
148 .scgc_addr = &SIM->SCGC4,
149 .scgc_bit = SIM_SCGC4_UART1_SHIFT,
155#define UART_0_ISR (isr_uart0_rx_tx)
156#define UART_1_ISR (isr_uart1_rx_tx)
158#define UART_NUMOF ARRAY_SIZE(uart_config)
204#define ADC_NUMOF ARRAY_SIZE(adc_config)
211#define ADC_REF_SETTING 0
221 .scgc_addr = &SIM->SCGC2,
222 .scgc_bit = SIM_SCGC2_DAC0_SHIFT
226#define DAC_NUMOF ARRAY_SIZE(dac_config)
239 { .pin =
GPIO_UNDEF, .af = 0, .ftm_chan = 0 },
250 { .pin =
GPIO_UNDEF, .af = 0, .ftm_chan = 0 },
258#define PWM_NUMOF ARRAY_SIZE(pwm_config)
271static const uint32_t spi_clk_config[] = {
273 SPI_CTAR_PBR(0) | SPI_CTAR_BR(8) |
274 SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(8) |
275 SPI_CTAR_PASC(0) | SPI_CTAR_ASC(8) |
276 SPI_CTAR_PDT(0) | SPI_CTAR_DT(8)
279 SPI_CTAR_PBR(0) | SPI_CTAR_BR(6) |
280 SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(6) |
281 SPI_CTAR_PASC(0) | SPI_CTAR_ASC(6) |
282 SPI_CTAR_PDT(0) | SPI_CTAR_DT(6)
285 SPI_CTAR_PBR(1) | SPI_CTAR_BR(4) |
286 SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(3) |
287 SPI_CTAR_PASC(1) | SPI_CTAR_ASC(3) |
288 SPI_CTAR_PDT(1) | SPI_CTAR_DT(3)
291 SPI_CTAR_PBR(2) | SPI_CTAR_BR(0) |
292 SPI_CTAR_PCSSCK(2) | SPI_CTAR_CSSCK(0) |
293 SPI_CTAR_PASC(2) | SPI_CTAR_ASC(0) |
294 SPI_CTAR_PDT(2) | SPI_CTAR_DT(0)
297 SPI_CTAR_PBR(1) | SPI_CTAR_BR(0) |
298 SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(0) |
299 SPI_CTAR_PASC(1) | SPI_CTAR_ASC(0) |
300 SPI_CTAR_PDT(1) | SPI_CTAR_DT(0)
318 .simmask = SIM_SCGC6_SPI0_MASK
333 .simmask = SIM_SCGC6_SPI1_MASK
337#define SPI_NUMOF ARRAY_SIZE(spi_config)
352 .scl_pcr = (PORT_PCR_MUX(2) | PORT_PCR_ODE_MASK),
353 .sda_pcr = (PORT_PCR_MUX(2) | PORT_PCR_ODE_MASK),
356#define I2C_NUMOF ARRAY_SIZE(i2c_config)
357#define I2C_0_ISR (isr_i2c0)
358#define I2C_1_ISR (isr_i2c1)
#define CLOCK_CORECLOCK
Clock configuration.
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
#define SPI_CS_UNDEF
Define value for unused CS line.
#define UART0
UART0 register bank.
#define UART1
UART1 register bank.
#define CLOCK_BUSCLOCK
Bus clock frequency, used by several hardware modules in Kinetis CPUs.
#define ADC_AVG_NONE
Disable hardware averaging.
@ KINETIS_UART
Kinetis UART module type.
@ UART_MODE_8N1
8 data bits, no parity, 1 stop bit
#define ADC_AVG_MAX
Maximum hardware averaging (32 samples)
ADC device configuration.
ADC_TypeDef * dev
ADC device used.
DAC line configuration data.
I2C configuration structure.
I2C_Type * i2c
Pointer to hardware module registers.
gpio_t pin
GPIO pin mapped to this channel.
PWM device configuration.
pwm_chan_t chan[TIMER_CHANNEL_NUMOF]
channel mapping set to {GPIO_UNDEF, 0} if not used
SPI device configuration.
SPI_t * dev
pointer to the used SPI device
UART device configuration.
USART_t * dev
pointer to the used UART device