25 #include "periph_cpu.h"
46 #define RTC_LOAD_CAP_BITS (RTC_CR_SC8P_MASK | RTC_CR_SC4P_MASK | RTC_CR_SC2P_MASK)
48 static const clock_config_t clock_config = {
61 .clkdiv1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) |
62 SIM_CLKDIV1_OUTDIV3(1) | SIM_CLKDIV1_OUTDIV4(1),
63 .rtc_clc = RTC_LOAD_CAP_BITS,
64 .osc32ksel = SIM_SOPT1_OSC32KSEL(2),
67 KINETIS_CLOCK_RTCOSC_EN |
68 KINETIS_CLOCK_USE_FAST_IRC |
70 .default_mode = KINETIS_MCG_MODE_FEE,
71 .erc_range = KINETIS_MCG_ERC_RANGE_LOW,
74 .osc_clc = OSC_CR_SC16P_MASK,
75 .oscsel = MCG_C7_OSCSEL(1),
76 .fcrdiv = MCG_SC_FCRDIV(0),
77 .fll_frdiv = MCG_C1_FRDIV(0b000),
78 .fll_factor_fei = KINETIS_MCG_FLL_FACTOR_1464,
79 .fll_factor_fee = KINETIS_MCG_FLL_FACTOR_1464,
83 .pll_prdiv = MCG_C5_PRDIV0(0b00111),
84 .pll_vdiv = MCG_C6_VDIV0(0b01100),
86 #define CLOCK_CORECLOCK (48000000ul)
87 #define CLOCK_BUSCLOCK (CLOCK_CORECLOCK / 1)
94 #define PIT_NUMOF (2U)
95 #define PIT_CONFIG { \
105 #define LPTMR_NUMOF (1U)
106 #define LPTMR_CONFIG { \
109 .irqn = LPTMR0_IRQn, \
111 .base_freq = 32768u, \
114 #define TIMER_NUMOF ((PIT_NUMOF) + (LPTMR_NUMOF))
116 #define PIT_BASECLOCK (CLOCK_BUSCLOCK)
117 #define PIT_ISR_0 isr_pit1
118 #define PIT_ISR_1 isr_pit3
119 #define LPTMR_ISR_0 isr_lptmr0
133 .pcr_rx = PORT_PCR_MUX(3),
134 .pcr_tx = PORT_PCR_MUX(3),
135 .irqn = UART0_RX_TX_IRQn,
136 .scgc_addr = &SIM->SCGC4,
137 .scgc_bit = SIM_SCGC4_UART0_SHIFT,
146 .pcr_rx = PORT_PCR_MUX(3),
147 .pcr_tx = PORT_PCR_MUX(3),
148 .irqn = UART1_RX_TX_IRQn,
149 .scgc_addr = &SIM->SCGC4,
150 .scgc_bit = SIM_SCGC4_UART1_SHIFT,
156 #define UART_0_ISR (isr_uart0_rx_tx)
157 #define UART_1_ISR (isr_uart1_rx_tx)
159 #define UART_NUMOF ARRAY_SIZE(uart_config)
205 #define ADC_NUMOF ARRAY_SIZE(adc_config)
212 #define ADC_REF_SETTING 0
222 .scgc_addr = &SIM->SCGC2,
223 .scgc_bit = SIM_SCGC2_DAC0_SHIFT
227 #define DAC_NUMOF ARRAY_SIZE(dac_config)
240 { .pin =
GPIO_UNDEF, .af = 0, .ftm_chan = 0 },
251 { .pin =
GPIO_UNDEF, .af = 0, .ftm_chan = 0 },
259 #define PWM_NUMOF ARRAY_SIZE(pwm_config)
274 SPI_CTAR_PBR(0) | SPI_CTAR_BR(8) |
275 SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(8) |
276 SPI_CTAR_PASC(0) | SPI_CTAR_ASC(8) |
277 SPI_CTAR_PDT(0) | SPI_CTAR_DT(8)
280 SPI_CTAR_PBR(0) | SPI_CTAR_BR(6) |
281 SPI_CTAR_PCSSCK(0) | SPI_CTAR_CSSCK(6) |
282 SPI_CTAR_PASC(0) | SPI_CTAR_ASC(6) |
283 SPI_CTAR_PDT(0) | SPI_CTAR_DT(6)
286 SPI_CTAR_PBR(1) | SPI_CTAR_BR(4) |
287 SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(3) |
288 SPI_CTAR_PASC(1) | SPI_CTAR_ASC(3) |
289 SPI_CTAR_PDT(1) | SPI_CTAR_DT(3)
292 SPI_CTAR_PBR(2) | SPI_CTAR_BR(0) |
293 SPI_CTAR_PCSSCK(2) | SPI_CTAR_CSSCK(0) |
294 SPI_CTAR_PASC(2) | SPI_CTAR_ASC(0) |
295 SPI_CTAR_PDT(2) | SPI_CTAR_DT(0)
298 SPI_CTAR_PBR(1) | SPI_CTAR_BR(0) |
299 SPI_CTAR_PCSSCK(1) | SPI_CTAR_CSSCK(0) |
300 SPI_CTAR_PASC(1) | SPI_CTAR_ASC(0) |
301 SPI_CTAR_PDT(1) | SPI_CTAR_DT(0)
319 .simmask = SIM_SCGC6_SPI0_MASK
334 .simmask = SIM_SCGC6_SPI1_MASK
338 #define SPI_NUMOF ARRAY_SIZE(spi_config)
350 .freq = CLOCK_BUSCLOCK,
353 .scl_pcr = (PORT_PCR_MUX(2) | PORT_PCR_ODE_MASK),
354 .sda_pcr = (PORT_PCR_MUX(2) | PORT_PCR_ODE_MASK),
357 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
358 #define I2C_0_ISR (isr_i2c0)
359 #define I2C_1_ISR (isr_i2c1)