aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h
diff options
context:
space:
mode:
authorAkshay <[email protected]>2022-04-10 12:13:40 +0100
committerAkshay <[email protected]>2022-04-10 12:13:40 +0100
commitdc90387ce7d8ba7b607d9c48540bf6d8b560f14d (patch)
tree4ccb8fa5886b66fa9d480edef74236c27f035e16 /lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h
Diffstat (limited to 'lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h')
-rw-r--r--lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h305
1 files changed, 305 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h b/lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h
new file mode 100644
index 000000000..c309f047f
--- /dev/null
+++ b/lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/k20x5.h
@@ -0,0 +1,305 @@
1/*
2 * Copyright (C) 2014-2016 Fabio Utzig, http://fabioutzig.com
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23#ifndef _K20x5_H_
24#define _K20x5_H_
25
26/*
27 * ==============================================================
28 * ---------- Interrupt Number Definition -----------------------
29 * ==============================================================
30 */
31typedef enum IRQn
32{
33/****** Cortex-M0 Processor Exceptions Numbers ****************/
34 InitialSP_IRQn = -15,
35 InitialPC_IRQn = -15,
36 NonMaskableInt_IRQn = -14,
37 HardFault_IRQn = -13,
38 MemoryManagement_IRQn = -12,
39 BusFault_IRQn = -11,
40 UsageFault_IRQn = -10,
41 SVCall_IRQn = -5,
42 DebugMonitor_IRQn = -4,
43 PendSV_IRQn = -2,
44 SysTick_IRQn = -1,
45
46/****** K20x Specific Interrupt Numbers ***********************/
47 DMA0_IRQn = 0, // Vector40
48 DMA1_IRQn = 1, // Vector44
49 DMA2_IRQn = 2, // Vector48
50 DMA3_IRQn = 3, // Vector4C
51 DMAError_IRQn = 4, // Vector50
52 DMA_IRQn = 5, // Vector54
53 FlashMemComplete_IRQn = 6, // Vector58
54 FlashMemReadCollision_IRQn = 7, // Vector5C
55 LowVoltageWarning_IRQn = 8, // Vector60
56 LLWU_IRQn = 9, // Vector64
57 WDOG_IRQn = 10, // Vector68
58 I2C0_IRQn = 11, // Vector6C
59 SPI0_IRQn = 12, // Vector70
60 I2S0_IRQn = 13, // Vector74
61 I2S1_IRQn = 14, // Vector78
62 UART0LON_IRQn = 15, // Vector7C
63 UART0Status_IRQn = 16, // Vector80
64 UART0Error_IRQn = 17, // Vector84
65 UART1Status_IRQn = 18, // Vector88
66 UART1Error_IRQn = 19, // Vector8C
67 UART2Status_IRQn = 20, // Vector90
68 UART2Error_IRQn = 21, // Vector94
69 ADC0_IRQn = 22, // Vector98
70 CMP0_IRQn = 23, // Vector9C
71 CMP1_IRQn = 24, // VectorA0
72 FTM0_IRQn = 25, // VectorA4
73 FTM1_IRQn = 26, // VectorA8
74 CMT_IRQn = 27, // VectorAC
75 RTCAlarm_IRQn = 28, // VectorB0
76 RTCSeconds_IRQn = 29, // VectorB4
77 PITChannel0_IRQn = 30, // VectorB8
78 PITChannel1_IRQn = 31, // VectorBC
79 PITChannel2_IRQn = 32, // VectorC0
80 PITChannel3_IRQn = 33, // VectorC4
81 PDB_IRQn = 34, // VectorC8
82 USB_OTG_IRQn = 35, // VectorCC
83 USBChargerDetect_IRQn = 36, // VectorD0
84 TSI_IRQn = 37, // VectorD4
85 MCG_IRQn = 38, // VectorD8
86 LPTMR0_IRQn = 39, // VectorDC
87 PINA_IRQn = 40, // VectorE0
88 PINB_IRQn = 41, // VectorE4
89 PINC_IRQn = 42, // VectorE8
90 PIND_IRQn = 43, // VectorEC
91 PINE_IRQn = 44, // VectorF0
92 SoftInitInt_IRQn = 45, // VectorF4
93} IRQn_Type;
94
95/*
96 * ==========================================================================
97 * ----------- Processor and Core Peripheral Section ------------------------
98 * ==========================================================================
99 */
100
101/**
102 * @brief K20x Interrupt Number Definition, according to the selected device
103 * in @ref Library_configuration_section
104 */
105#define __FPU_PRESENT 0
106#define __MPU_PRESENT 0
107#define __NVIC_PRIO_BITS 4
108#define __Vendor_SysTickConfig 0
109
110#include "core_cm4.h" /* Cortex-M4 processor and core peripherals */
111
112#include "k20xx.h"
113
114typedef struct
115{
116 __IO uint32_t SOPT1;
117 __IO uint32_t SOPT1CFG;
118 uint32_t RESERVED0[1023];
119 __IO uint32_t SOPT2;
120 uint32_t RESERVED1[1];
121 __IO uint32_t SOPT4;
122 __IO uint32_t SOPT5;
123 uint32_t RESERVED2[1];
124 __IO uint32_t SOPT7;
125 uint32_t RESERVED3[2];
126 __I uint32_t SDID;
127 uint32_t RESERVED4[3];
128 __IO uint32_t SCGC4;
129 __IO uint32_t SCGC5;
130 __IO uint32_t SCGC6;
131 __IO uint32_t SCGC7;
132 __IO uint32_t CLKDIV1;
133 __IO uint32_t CLKDIV2;
134 __I uint32_t FCFG1;
135 __I uint32_t FCFG2;
136 __I uint32_t UIDH;
137 __I uint32_t UIDMH;
138 __I uint32_t UIDML;
139 __I uint32_t UIDL;
140} SIM_TypeDef;
141
142/****************************************************************/
143/* Peripheral memory map */
144/****************************************************************/
145#define DMA_BASE ((uint32_t)0x40008000)
146#define FTFL_BASE ((uint32_t)0x40020000)
147#define DMAMUX_BASE ((uint32_t)0x40021000)
148#define SPI0_BASE ((uint32_t)0x4002C000)
149#define PIT_BASE ((uint32_t)0x40037000)
150#define FTM0_BASE ((uint32_t)0x40038000)
151#define FTM1_BASE ((uint32_t)0x40039000)
152#define ADC0_BASE ((uint32_t)0x4003B000)
153#define VBAT_BASE ((uint32_t)0x4003E000)
154#define LPTMR0_BASE ((uint32_t)0x40040000)
155#define SRF_BASE ((uint32_t)0x40041000)
156#define TSI0_BASE ((uint32_t)0x40045000)
157#define SIM_BASE ((uint32_t)0x40047000)
158#define PORTA_BASE ((uint32_t)0x40049000)
159#define PORTB_BASE ((uint32_t)0x4004A000)
160#define PORTC_BASE ((uint32_t)0x4004B000)
161#define PORTD_BASE ((uint32_t)0x4004C000)
162#define PORTE_BASE ((uint32_t)0x4004D000)
163#define WDOG_BASE ((uint32_t)0x40052000)
164#define MCG_BASE ((uint32_t)0x40064000)
165#define OSC0_BASE ((uint32_t)0x40065000)
166#define I2C0_BASE ((uint32_t)0x40066000)
167#define UART0_BASE ((uint32_t)0x4006A000)
168#define UART1_BASE ((uint32_t)0x4006B000)
169#define UART2_BASE ((uint32_t)0x4006C000)
170#define USBOTG_BASE ((uint32_t)0x40072000)
171#define LLWU_BASE ((uint32_t)0x4007C000)
172#define PMC_BASE ((uint32_t)0x4007D000)
173#define GPIOA_BASE ((uint32_t)0x400FF000)
174#define GPIOB_BASE ((uint32_t)0x400FF040)
175#define GPIOC_BASE ((uint32_t)0x400FF080)
176#define GPIOD_BASE ((uint32_t)0x400FF0C0)
177#define GPIOE_BASE ((uint32_t)0x400FF100)
178
179/****************************************************************/
180/* Peripheral declaration */
181/****************************************************************/
182#define DMA ((DMA_TypeDef *) DMA_BASE)
183#define FTFL ((FTFL_TypeDef *) FTFL_BASE)
184#define DMAMUX ((DMAMUX_TypeDef *) DMAMUX_BASE)
185#define PIT ((PIT_TypeDef *) PIT_BASE)
186#define FTM0 ((FTM_TypeDef *) FTM0_BASE)
187#define FTM1 ((FTM_TypeDef *) FTM1_BASE)
188#define ADC0 ((ADC_TypeDef *) ADC0_BASE)
189#define VBAT ((volatile uint8_t *)VBAT_BASE) /* 32 bytes */
190#define LPTMR0 ((LPTMR_TypeDef *) LPTMR0_BASE)
191#define SYSTEM_REGISTER_FILE ((volatile uint8_t *)SRF_BASE) /* 32 bytes */
192#define TSI0 ((TSI_TypeDef *) TSI0_BASE)
193#define SIM ((SIM_TypeDef *) SIM_BASE)
194#define LLWU ((LLWU_TypeDef *) LLWU_BASE)
195#define PMC ((PMC_TypeDef *) PMC_BASE)
196#define PORTA ((PORT_TypeDef *) PORTA_BASE)
197#define PORTB ((PORT_TypeDef *) PORTB_BASE)
198#define PORTC ((PORT_TypeDef *) PORTC_BASE)
199#define PORTD ((PORT_TypeDef *) PORTD_BASE)
200#define PORTE ((PORT_TypeDef *) PORTE_BASE)
201#define WDOG ((WDOG_TypeDef *) WDOG_BASE)
202#define USB0 ((USBOTG_TypeDef *) USBOTG_BASE)
203#define MCG ((MCG_TypeDef *) MCG_BASE)
204#define OSC0 ((OSC_TypeDef *) OSC0_BASE)
205#define SPI0 ((SPI_TypeDef *) SPI0_BASE)
206#define I2C0 ((I2C_TypeDef *) I2C0_BASE)
207#define UART0 ((UART_TypeDef *) UART0_BASE)
208#define UART1 ((UART_TypeDef *) UART1_BASE)
209#define UART2 ((UART_TypeDef *) UART2_BASE)
210#define GPIOA ((GPIO_TypeDef *) GPIOA_BASE)
211#define GPIOB ((GPIO_TypeDef *) GPIOB_BASE)
212#define GPIOC ((GPIO_TypeDef *) GPIOC_BASE)
213#define GPIOD ((GPIO_TypeDef *) GPIOD_BASE)
214#define GPIOE ((GPIO_TypeDef *) GPIOE_BASE)
215
216/****************************************************************/
217/* Peripheral Registers Bits Definition */
218/****************************************************************/
219
220/****************************************************************/
221/* */
222/* System Integration Module (SIM) */
223/* */
224/****************************************************************/
225/********* Bits definition for SIM_SOPT1 register *************/
226#define SIM_SOPT1_USBREGEN ((uint32_t)0x80000000) /*!< USB voltage regulator enable */
227#define SIM_SOPT1_USBSSTBY ((uint32_t)0x40000000) /*!< USB voltage regulator in standby mode during Stop, VLPS, LLS and VLLS modes */
228#define SIM_SOPT1_USBVSTBY ((uint32_t)0x20000000) /*!< USB voltage regulator in standby mode during VLPR and VLPW modes */
229#define SIM_SOPT1_OSC32KSEL_SHIFT 18 /*!< 32K oscillator clock select (shift) */
230#define SIM_SOPT1_OSC32KSEL_MASK ((uint32_t)((uint32_t)0x3 << SIM_SOPT1_OSC32KSEL_SHIFT)) /*!< 32K oscillator clock select (mask) */
231#define SIM_SOPT1_OSC32KSEL(x) ((uint32_t)(((uint32_t)(x) << SIM_SOPT1_OSC32KSEL_SHIFT) & SIM_SOPT1_OSC32KSEL_MASK)) /*!< 32K oscillator clock select */
232#define SIM_SOPT1_RAMSIZE_SHIFT 12
233#define SIM_SOPT1_RAMSIZE_MASK ((uint32_t)((uint32_t)0xf << SIM_SOPT1_RAMSIZE_SHIFT))
234#define SIM_SOPT1_RAMSIZE(x) ((uint32_t)(((uint32_t)(x) << SIM_SOPT1_RAMSIZE_SHIFT) & SIM_SOPT1_RAMSIZE_MASK))
235
236/******* Bits definition for SIM_SOPT1CFG register ************/
237#define SIM_SOPT1CFG_USSWE ((uint32_t)0x04000000) /*!< USB voltage regulator stop standby write enable */
238#define SIM_SOPT1CFG_UVSWE ((uint32_t)0x02000000) /*!< USB voltage regulator VLP standby write enable */
239#define SIM_SOPT1CFG_URWE ((uint32_t)0x01000000) /*!< USB voltage regulator voltage regulator write enable */
240
241/******* Bits definition for SIM_SOPT2 register ************/
242#define SIM_SOPT2_USBSRC ((uint32_t)0x00040000) /*!< USB clock source select */
243#define SIM_SOPT2_PLLFLLSEL ((uint32_t)0x00010000) /*!< PLL/FLL clock select */
244#define SIM_SOPT2_TRACECLKSEL ((uint32_t)0x00001000)
245#define SIM_SOPT2_PTD7PAD ((uint32_t)0x00000800)
246#define SIM_SOPT2_CLKOUTSEL_SHIFT 5
247#define SIM_SOPT2_CLKOUTSEL_MASK ((uint32_t)((uint32_t)0x7 << SIM_SOPT2_CLKOUTSEL_SHIFT))
248#define SIM_SOPT2_CLKOUTSEL(x) ((uint32_t)(((uint32_t)(x) << SIM_SOPT2_CLKOUTSEL_SHIFT) & SIM_SOPT2_CLKOUTSEL_MASK))
249#define SIM_SOPT2_RTCCLKOUTSEL ((uint32_t)0x00000010) /*!< RTC clock out select */
250
251/******* Bits definition for SIM_SCGC4 register ************/
252#define SIM_SCGC4_VREF ((uint32_t)0x00100000) /*!< VREF Clock Gate Control */
253#define SIM_SCGC4_CMP ((uint32_t)0x00080000) /*!< Comparator Clock Gate Control */
254#define SIM_SCGC4_USBOTG ((uint32_t)0x00040000) /*!< USB Clock Gate Control */
255#define SIM_SCGC4_UART2 ((uint32_t)0x00001000) /*!< UART2 Clock Gate Control */
256#define SIM_SCGC4_UART1 ((uint32_t)0x00000800) /*!< UART1 Clock Gate Control */
257#define SIM_SCGC4_UART0 ((uint32_t)0x00000400) /*!< UART0 Clock Gate Control */
258#define SIM_SCGC4_I2C0 ((uint32_t)0x00000040) /*!< I2C0 Clock Gate Control */
259#define SIM_SCGC4_CMT ((uint32_t)0x00000004) /*!< CMT Clock Gate Control */
260#define SIM_SCGC4_EMW ((uint32_t)0x00000002) /*!< EWM Clock Gate Control */
261
262/******* Bits definition for SIM_SCGC5 register ************/
263#define SIM_SCGC5_PORTE ((uint32_t)0x00002000) /*!< Port E Clock Gate Control */
264#define SIM_SCGC5_PORTD ((uint32_t)0x00001000) /*!< Port D Clock Gate Control */
265#define SIM_SCGC5_PORTC ((uint32_t)0x00000800) /*!< Port C Clock Gate Control */
266#define SIM_SCGC5_PORTB ((uint32_t)0x00000400) /*!< Port B Clock Gate Control */
267#define SIM_SCGC5_PORTA ((uint32_t)0x00000200) /*!< Port A Clock Gate Control */
268#define SIM_SCGC5_TSI ((uint32_t)0x00000020) /*!< TSI Access Control */
269#define SIM_SCGC5_LPTIMER ((uint32_t)0x00000001) /*!< Low Power Timer Access Control */
270
271/******* Bits definition for SIM_SCGC6 register ************/
272#define SIM_SCGC6_RTC ((uint32_t)0x20000000) /*!< RTC Access Control */
273#define SIM_SCGC6_ADC0 ((uint32_t)0x08000000) /*!< ADC0 Clock Gate Control */
274#define SIM_SCGC6_FTM1 ((uint32_t)0x02000000) /*!< FTM1 Clock Gate Control */
275#define SIM_SCGC6_FTM0 ((uint32_t)0x01000000) /*!< FTM0 Clock Gate Control */
276#define SIM_SCGC6_PIT ((uint32_t)0x00800000) /*!< PIT Clock Gate Control */
277#define SIM_SCGC6_PDB ((uint32_t)0x00400000) /*!< PDB Clock Gate Control */
278#define SIM_SCGC6_USBDCD ((uint32_t)0x00200000) /*!< USB DCD Clock Gate Control */
279#define SIM_SCGC6_CRC ((uint32_t)0x00040000) /*!< Low Power Timer Access Control */
280#define SIM_SCGC6_I2S ((uint32_t)0x00008000) /*!< CRC Clock Gate Control */
281#define SIM_SCGC6_SPI0 ((uint32_t)0x00001000) /*!< SPI0 Clock Gate Control */
282#define SIM_SCGC6_DMAMUX ((uint32_t)0x00000002) /*!< DMA Mux Clock Gate Control */
283#define SIM_SCGC6_FTFL ((uint32_t)0x00000001) /*!< Flash Memory Clock Gate Control */
284
285/******* Bits definition for SIM_SCGC6 register ************/
286#define SIM_SCGC7_DMA ((uint32_t)0x00000002) /*!< DMA Clock Gate Control */
287
288/****** Bits definition for SIM_CLKDIV1 register ***********/
289#define SIM_CLKDIV1_OUTDIV1_SHIFT 28
290#define SIM_CLKDIV1_OUTDIV1_MASK ((uint32_t)((uint32_t)0xF << SIM_CLKDIV1_OUTDIV1_SHIFT))
291#define SIM_CLKDIV1_OUTDIV1(x) ((uint32_t)(((uint32_t)(x) << SIM_CLKDIV1_OUTDIV1_SHIFT) & SIM_CLKDIV1_OUTDIV1_MASK))
292#define SIM_CLKDIV1_OUTDIV2_SHIFT 24
293#define SIM_CLKDIV1_OUTDIV2_MASK ((uint32_t)((uint32_t)0xF << SIM_CLKDIV1_OUTDIV2_SHIFT))
294#define SIM_CLKDIV1_OUTDIV2(x) ((uint32_t)(((uint32_t)(x) << SIM_CLKDIV1_OUTDIV2_SHIFT) & SIM_CLKDIV1_OUTDIV2_MASK))
295#define SIM_CLKDIV1_OUTDIV4_SHIFT 16
296#define SIM_CLKDIV1_OUTDIV4_MASK ((uint32_t)((uint32_t)0x7 << SIM_CLKDIV1_OUTDIV4_SHIFT))
297#define SIM_CLKDIV1_OUTDIV4(x) ((uint32_t)(((uint32_t)(x) << SIM_CLKDIV1_OUTDIV4_SHIFT) & SIM_CLKDIV1_OUTDIV4_MASK))
298
299/****** Bits definition for SIM_CLKDIV2 register ***********/
300#define SIM_CLKDIV2_USBDIV_SHIFT 1
301#define SIM_CLKDIV2_USBDIV_MASK ((uint32_t)((uint32_t)0x7 << SIM_CLKDIV2_USBDIV_SHIFT))
302#define SIM_CLKDIV2_USBDIV(x) ((uint32_t)(((uint32_t)(x) << SIM_CLKDIV2_USBDIV_SHIFT) & SIM_CLKDIV2_USBDIV_MASK))
303#define SIM_CLKDIV2_USBFRAC ((uint32_t)0x00000001)
304
305#endif