cpu_conf_kinetis.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Eistec AB
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
21 #include "cpu_conf_common.h"
22 
23 #if (__CORTEX_M < 3)
24 /*
25  * Kinetis Cortex-M0+ devices have bit manipulation engine (BME) which provides
26  * the same functionality (and some more) as the bitband aliased memory found in
27  * Cortex-M3 and up
28  */
29 #include "bme.h"
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
41 #define CPU_DEFAULT_IRQ_PRIO (1U)
42 #define CPU_IRQ_NUMOF (NUMBER_OF_INT_VECTORS)
43 #define CPU_FLASH_BASE (0x00000000)
50 #define PIN_MUX_FUNCTION_ANALOG 0
51 #define PIN_MUX_FUNCTION_GPIO 1
58 #define PIN_INTERRUPT_RISING 0b1001
59 #define PIN_INTERRUPT_FALLING 0b1010
60 #define PIN_INTERRUPT_EDGE 0b1011
67 /* Different versions of vendor headers use some variations of register names.
68  * This section aims to eliminate these differences in the few places where it
69  * matters for the RIOT driver implementations.
70  */
71 #if !defined(MCG_C2_RANGE0) && defined(MCG_C2_RANGE)
72 #define MCG_C2_RANGE0(x) MCG_C2_RANGE(x)
73 #endif
74 #if !defined(MCG_C2_RANGE0_MASK) && defined(MCG_C2_RANGE_MASK)
75 #define MCG_C2_RANGE0_MASK MCG_C2_RANGE_MASK
76 #endif
77 #if !defined(MCG_C7_OSCSEL) && defined(MCG_C7_OSCSEL_SHIFT)
78 #define MCG_C7_OSCSEL(x) (((uint32_t)(x) << MCG_C7_OSCSEL_SHIFT) & MCG_C7_OSCSEL_MASK)
79 #endif
80 #if !defined(OSC0) && defined(OSC)
81 #define OSC0 OSC
82 #endif
83 #if !defined(SIM_SOPT2_LPUART0SRC_MASK) && defined(SIM_SOPT2_LPUARTSRC_MASK)
84 #define SIM_SOPT2_LPUART0SRC_MASK SIM_SOPT2_LPUARTSRC_MASK
85 #define SIM_SOPT2_LPUART0SRC_SHIFT SIM_SOPT2_LPUARTSRC_SHIFT
86 #define SIM_SOPT2_LPUART0SRC SIM_SOPT2_LPUARTSRC
87 #endif
88 #if !defined(SIM_SCGC5_LPTMR_SHIFT) && defined(SIM_SCGC5_LPTIMER_SHIFT)
89 #define SIM_SCGC5_LPTMR_SHIFT SIM_SCGC5_LPTIMER_SHIFT
90 #endif
91 #if !defined(SIM_SCGC5_LPTMR_MASK) && defined(SIM_SCGC5_LPTIMER_MASK)
92 #define SIM_SCGC5_LPTMR_MASK SIM_SCGC5_LPTIMER_MASK
93 #endif
94 #if !defined(GPIOA_BASE) && defined(PTA_BASE)
95 #define GPIOA_BASE PTA_BASE
96 #define GPIOB_BASE PTB_BASE
97 #define GPIOC_BASE PTC_BASE
98 #define GPIOD_BASE PTD_BASE
99 #define GPIOE_BASE PTE_BASE
100 #define GPIOF_BASE PTF_BASE
101 #define GPIOG_BASE PTG_BASE
102 #endif
103 #if !defined(GPIOA) && defined(PTA)
104 #define GPIOA PTA
105 #define GPIOB PTB
106 #define GPIOC PTC
107 #define GPIOD PTD
108 #define GPIOE PTE
109 #define GPIOF PTF
110 #define GPIOG PTG
111 #endif
118 #ifdef SIM_SCGC5_LPTMR_SHIFT
120 #define LPTMR_CLKEN() (bit_set32(&SIM->SCGC5, SIM_SCGC5_LPTMR_SHIFT))
121 #endif
122 #if defined(SIM_SCGC6_PIT_SHIFT)
124 #define PIT_CLKEN() (bit_set32(&SIM->SCGC6, SIM_SCGC6_PIT_SHIFT))
125 #elif defined(SIM_SCGC_PIT_SHIFT)
126 #define PIT_CLKEN() (bit_set32(&SIM->SCGC, SIM_SCGC_PIT_SHIFT))
127 #endif
128 #ifdef SIM_SCGC6_RTC_SHIFT
130 #define RTC_CLKEN() (bit_set32(&SIM->SCGC6, SIM_SCGC6_RTC_SHIFT))
131 #endif
138 #ifdef SIM_SCGC4_I2C0_SHIFT
140 #define I2C0_CLKEN() (bit_set32(&SIM->SCGC4, SIM_SCGC4_I2C0_SHIFT))
141 #endif
142 #ifdef SIM_SCGC4_I2C1_SHIFT
144 #define I2C1_CLKEN() (bit_set32(&SIM->SCGC4, SIM_SCGC4_I2C1_SHIFT))
145 #endif
146 #ifdef SIM_SCGC1_I2C2_SHIFT
148 #define I2C2_CLKEN() (bit_set32(&SIM->SCGC1, SIM_SCGC1_I2C2_SHIFT))
149 #endif
156 #if !defined(HWRNG_CLK_REG) && !defined(HWRNG_CLK_REG_SHIFT)
157 #if defined(SIM_SCGC3_RNGA_SHIFT)
158 #define HWRNG_CLK_REG SIM->SCGC3
159 #define HWRNG_CLK_REG_SHIFT SIM_SCGC3_RNGA_SHIFT
160 #elif defined(SIM_SCGC6_RNGA_SHIFT)
161 #define HWRNG_CLK_REG SIM->SCGC6
162 #define HWRNG_CLK_REG_SHIFT SIM_SCGC6_RNGA_SHIFT
163 #endif
164 #endif
165 #if defined(RNG)
166 #define KINETIS_RNGA RNG
167 #define HWRNG_CLKEN() (bit_set32(&HWRNG_CLK_REG, HWRNG_CLK_REG_SHIFT))
168 #define HWRNG_CLKDIS() (bit_clear32(&HWRNG_CLK_REG, HWRNG_CLK_REG_SHIFT))
169 #endif /* KINETIS_RNGA */
176 #if defined(MK20D7_H_)
177 #define LLWU_IRQn LLW_IRQn
178 #define LPTMR0_IRQn LPTimer_IRQn
179 #define PIT_TCTRL_CHN_MASK (0x4u)
180 #define PIT_TCTRL_CHN_SHIFT (2)
181 #define PORT_IRQS { PORTA_IRQn, PORTB_IRQn, PORTC_IRQn, PORTD_IRQn, PORTE_IRQn }
182 #endif /* MK20D7_H_ */
185 #ifdef __cplusplus
186 }
187 #endif
188 
Macro definitions for the Kinetis Bit Manipulation Engine (BME)