1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file frdm_k64f.c
11  * @brief The frdm_k64f.c file defines GPIO pins and I2C CMSIS utilities for FRDM-K64F board.
12  */
13 
14 #include "frdm_k64f.h"
15 
16 // I2C0 Pin Handles
17 gpioHandleKSDK_t D15 = {.base = GPIOE,
18                         .portBase = PORTE,
19                         .pinNumber = 24,
20                         .mask = 1 << (24),
21                         .irq = PORTE_IRQn,
22                         .clockName = kCLOCK_PortE,
23                         .portNumber = PORTE_NUM};
24 gpioHandleKSDK_t D14 = {.base = GPIOE,
25                         .portBase = PORTE,
26                         .pinNumber = 25,
27                         .mask = 1 << (25),
28                         .irq = PORTE_IRQn,
29                         .clockName = kCLOCK_PortE,
30                         .portNumber = PORTE_NUM};
31 
32 // I2C1 Handle
33 gpioHandleKSDK_t A5 = {.base = GPIOC,
34                        .portBase = PORTC,
35                        .pinNumber = 10,
36                        .mask = 1 << (10),
37                        .irq = PORTC_IRQn,
38                        .clockName = kCLOCK_PortC,
39                        .portNumber = PORTC_NUM};
40 gpioHandleKSDK_t A4 = {.base = GPIOC,
41                        .portBase = PORTC,
42                        .pinNumber = 11,
43                        .mask = 1 << (11),
44                        .irq = PORTC_IRQn,
45                        .clockName = kCLOCK_PortC,
46                        .portNumber = PORTC_NUM};
47 
48 // SPI0 Handle
49 gpioHandleKSDK_t D13 = {.base = GPIOD,
50                         .portBase = PORTD,
51                         .pinNumber = 1,
52                         .mask = 1 << (1),
53                         .irq = PORTD_IRQn,
54                         .clockName = kCLOCK_PortD,
55                         .portNumber = PORTD_NUM};
56 gpioHandleKSDK_t D11 = {.base = GPIOD,
57                         .portBase = PORTD,
58                         .pinNumber = 2,
59                         .mask = 1 << (2),
60                         .irq = PORTD_IRQn,
61                         .clockName = kCLOCK_PortD,
62                         .portNumber = PORTD_NUM};
63 gpioHandleKSDK_t D12 = {.base = GPIOD,
64                         .portBase = PORTD,
65                         .pinNumber = 3,
66                         .mask = 1 << (3),
67                         .irq = PORTD_IRQn,
68                         .clockName = kCLOCK_PortD,
69                         .portNumber = PORTD_NUM};
70 
71 // UART3 Handle
72 gpioHandleKSDK_t D0 = {.base = GPIOC,
73                        .portBase = PORTC,
74                        .pinNumber = 16,
75                        .mask = 1 << (16),
76                        .irq = PORTC_IRQn,
77                        .clockName = kCLOCK_PortC,
78                        .portNumber = PORTC_NUM};
79 gpioHandleKSDK_t D1 = {.base = GPIOC,
80                        .portBase = PORTC,
81                        .pinNumber = 17,
82                        .mask = 1 << (17),
83                        .irq = PORTC_IRQn,
84                        .clockName = kCLOCK_PortC,
85                        .portNumber = PORTC_NUM};
86 
87 // FRDM-K64F Arduino Connector Pin Defintion
88 gpioHandleKSDK_t A0 = {.base = GPIOB,
89                        .portBase = PORTB,
90                        .pinNumber = 2,
91                        .mask = 1 << (2),
92                        .irq = PORTB_IRQn,
93                        .clockName = kCLOCK_PortB,
94                        .portNumber = PORTB_NUM};
95 gpioHandleKSDK_t A1 = {.base = GPIOB,
96                        .portBase = PORTB,
97                        .pinNumber = 3,
98                        .mask = 1 << (3),
99                        .irq = PORTB_IRQn,
100                        .clockName = kCLOCK_PortB,
101                        .portNumber = PORTB_NUM};
102 gpioHandleKSDK_t A2 = {.base = GPIOB,
103                        .portBase = PORTB,
104                        .pinNumber = 10,
105                        .mask = 1 << (10),
106                        .irq = PORTB_IRQn,
107                        .clockName = kCLOCK_PortB,
108                        .portNumber = PORTB_NUM};
109 gpioHandleKSDK_t A3 = {.base = GPIOB,
110                        .portBase = PORTB,
111                        .pinNumber = 11,
112                        .mask = 1 << (11),
113                        .irq = PORTB_IRQn,
114                        .clockName = kCLOCK_PortB,
115                        .portNumber = PORTB_NUM};
116 gpioHandleKSDK_t D2 = {.base = GPIOB,
117                        .portBase = PORTB,
118                        .pinNumber = 9,
119                        .mask = 1 << (9),
120                        .irq = PORTB_IRQn,
121                        .clockName = kCLOCK_PortB,
122                        .portNumber = PORTB_NUM};
123 gpioHandleKSDK_t D3 = {.base = GPIOA,
124                        .portBase = PORTA,
125                        .pinNumber = 1,
126                        .mask = 1 << (1),
127                        .irq = PORTA_IRQn,
128                        .clockName = kCLOCK_PortA,
129                        .portNumber = PORTA_NUM};
130 gpioHandleKSDK_t D4 = {.base = GPIOB,
131                        .portBase = PORTB,
132                        .pinNumber = 23,
133                        .mask = 1 << (23),
134                        .irq = PORTB_IRQn,
135                        .clockName = kCLOCK_PortB,
136                        .portNumber = PORTB_NUM};
137 gpioHandleKSDK_t D5 = {.base = GPIOA,
138                        .portBase = PORTA,
139                        .pinNumber = 2,
140                        .mask = 1 << (2),
141                        .irq = PORTA_IRQn,
142                        .clockName = kCLOCK_PortA,
143                        .portNumber = PORTA_NUM};
144 gpioHandleKSDK_t D6 = {.base = GPIOC,
145                        .portBase = PORTC,
146                        .pinNumber = 2,
147                        .mask = 1 << (2),
148                        .irq = PORTC_IRQn,
149                        .clockName = kCLOCK_PortC,
150                        .portNumber = PORTC_NUM};
151 gpioHandleKSDK_t D7 = {.base = GPIOC,
152                        .portBase = PORTC,
153                        .pinNumber = 3,
154                        .mask = 1 << (3),
155                        .irq = PORTC_IRQn,
156                        .clockName = kCLOCK_PortC,
157                        .portNumber = PORTC_NUM};
158 gpioHandleKSDK_t D8 = {.base = GPIOA,
159                        .portBase = PORTA,
160                        .pinNumber = 0,
161                        .mask = 1 << (0),
162                        .irq = PORTA_IRQn,
163                        .clockName = kCLOCK_PortA,
164                        .portNumber = PORTA_NUM};
165 gpioHandleKSDK_t D9 = {.base = GPIOC,
166                        .portBase = PORTC,
167                        .pinNumber = 4,
168                        .mask = 1 << (4),
169                        .irq = PORTC_IRQn,
170                        .clockName = kCLOCK_PortC,
171                        .portNumber = PORTC_NUM};
172 gpioHandleKSDK_t D10 = {.base = GPIOD,
173                         .portBase = PORTD,
174                         .pinNumber = 0,
175                         .mask = 1 << (0),
176                         .irq = PORTD_IRQn,
177                         .clockName = kCLOCK_PortD,
178                         .portNumber = PORTD_NUM};
179 
180 // FRDM-K64F Internal Peripheral Pin Definitions
181 gpioHandleKSDK_t RED_LED = {.base = GPIOB,
182                             .portBase = PORTB,
183                             .pinNumber = 22,
184                             .mask = 1 << (22),
185                             .irq = PORTB_IRQn,
186                             .clockName = kCLOCK_PortB,
187                             .portNumber = PORTB_NUM};
188 gpioHandleKSDK_t GREEN_LED = {.base = GPIOE,
189                               .portBase = PORTE,
190                               .pinNumber = 26,
191                               .mask = 1 << (26),
192                               .irq = PORTE_IRQn,
193                               .clockName = kCLOCK_PortE,
194                               .portNumber = PORTE_NUM};
195 gpioHandleKSDK_t BLUE_LED = {.base = GPIOB,
196                              .portBase = PORTB,
197                              .pinNumber = 21,
198                              .mask = 1 << (21),
199                              .irq = PORTB_IRQn,
200                              .clockName = kCLOCK_PortB,
201                              .portNumber = PORTB_NUM};
202 
203 // FRDM-K64F I2C Inertial Sensor Pin Definitions
204 gpioHandleKSDK_t INT1 = {.base = GPIOC,
205                          .portBase = PORTC,
206                          .pinNumber = 6,
207                          .mask = 1 << (6),
208                          .irq = PORTC_IRQn,
209                          .clockName = kCLOCK_PortC,
210                          .portNumber = PORTC_NUM};
211 gpioHandleKSDK_t INT2 = {.base = GPIOC,
212                          .portBase = PORTC,
213                          .pinNumber = 13,
214                          .mask = 1 << (13),
215                          .irq = PORTC_IRQn,
216                          .clockName = kCLOCK_PortC,
217                          .portNumber = PORTC_NUM};
218 
219 /*! @brief       Determines the Clock Frequency feature.
220  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
221  *  @param[in]   void
222  *  @Constraints None
223  *  @Reentrant   Yes
224  *  @return      uint32_t Returns the clock frequency .
225  */
UART0_GetFreq(void)226 uint32_t UART0_GetFreq(void)
227 {
228     return CLOCK_GetFreq(UART0_CLK_SRC);
229 }
230 
231 /*! @brief       Determines the Clock Frequency feature.
232  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
233  *  @param[in]   void
234  *  @Constraints None
235  *  @Reentrant   Yes
236  *  @return      uint32_t Returns the clock frequency .
237  */
UART1_GetFreq(void)238 uint32_t UART1_GetFreq(void)
239 {
240     return CLOCK_GetFreq(UART1_CLK_SRC);
241 }
242 
243 /*! @brief       Determines the Clock Frequency feature.
244  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
245  *  @param[in]   void
246  *  @Constraints None
247  *  @Reentrant   Yes
248  *  @return      uint32_t Returns the clock frequency .
249  */
UART2_GetFreq(void)250 uint32_t UART2_GetFreq(void)
251 {
252     return CLOCK_GetFreq(UART2_CLK_SRC);
253 }
254 
255 /*! @brief       Determines the Clock Frequency feature.
256  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
257  *  @param[in]   void
258  *  @Constraints None
259  *  @Reentrant   Yes
260  *  @return      uint32_t Returns the clock frequency .
261  */
UART3_GetFreq(void)262 uint32_t UART3_GetFreq(void)
263 {
264     return CLOCK_GetFreq(UART3_CLK_SRC);
265 }
266 
267 /*! @brief       Determines the Clock Frequency feature.
268  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
269  *  @param[in]   void
270  *  @Constraints None
271  *  @Reentrant   Yes
272  *  @return      uint32_t Returns the clock frequency .
273  */
UART4_GetFreq(void)274 uint32_t UART4_GetFreq(void)
275 {
276     return CLOCK_GetFreq(UART4_CLK_SRC);
277 }
278 
279 /*! @brief       Determines the Clock Frequency feature.
280  *  @details     The Clock Frequecny computation API required by fsl_uart_cmsis.c.
281  *  @param[in]   void
282  *  @Constraints None
283  *  @Reentrant   Yes
284  *  @return      uint32_t Returns the clock frequency .
285  */
UART5_GetFreq(void)286 uint32_t UART5_GetFreq(void)
287 {
288     return CLOCK_GetFreq(UART5_CLK_SRC);
289 }
290 
291 /*! @brief       Determines the Clock Frequency feature.
292  *  @details     The Clock Frequecny computation API required by fsl_i2c_cmsis.c.
293  *  @param[in]   void
294  *  @Constraints None
295  *  @Reentrant   Yes
296  *  @return      uint32_t Returns the clock frequency .
297  */
I2C0_GetFreq(void)298 uint32_t I2C0_GetFreq(void)
299 {
300     return CLOCK_GetFreq(I2C0_CLK_SRC);
301 }
302 
303 /*! @brief       Determines the Clock Frequency feature.
304  *  @details     The Clock Frequecny computation API required by fsl_i2c_cmsis.c.
305  *  @param[in]   void
306  *  @Constraints None
307  *  @Reentrant   Yes
308  *  @return      uint32_t Returns the clock frequency .
309  */
I2C1_GetFreq(void)310 uint32_t I2C1_GetFreq(void)
311 {
312     return CLOCK_GetFreq(I2C1_CLK_SRC);
313 }
314 
315 /*! @brief       Determines the Clock Frequency feature.
316  *  @details     The Clock Frequecny computation API required by fsl_i2c_cmsis.c.
317  *  @param[in]   void
318  *  @Constraints None
319  *  @Reentrant   Yes
320  *  @return      uint32_t Returns the clock frequency .
321  */
I2C2_GetFreq(void)322 uint32_t I2C2_GetFreq(void)
323 {
324     return CLOCK_GetFreq(I2C2_CLK_SRC);
325 }
326 
327 /*! @brief       Determines the Clock Frequency feature.
328  *  @details     The Clock Frequecny computation API required by fsl_spi_cmsis.c.
329  *  @param[in]   void
330  *  @Constraints None
331  *  @Reentrant   Yes
332  *  @return      uint32_t Returns the clock frequency .
333  */
DSPI0_GetFreq(void)334 uint32_t DSPI0_GetFreq(void)
335 {
336     return CLOCK_GetBusClkFreq();
337 }
338 
339 /*! @brief       Determines the Clock Frequency feature.
340  *  @details     The Clock Frequecny computation API required by fsl_spi_cmsis.c.
341  *  @param[in]   void
342  *  @Constraints None
343  *  @Reentrant   Yes
344  *  @return      uint32_t Returns the clock frequency .
345  */
DSPI1_GetFreq(void)346 uint32_t DSPI1_GetFreq(void)
347 {
348     return CLOCK_GetBusClkFreq();
349 }
350 
351 /*! @brief       Determines the Clock Frequency feature.
352  *  @details     The Clock Frequecny computation API required by fsl_spi_cmsis.c.
353  *  @param[in]   void
354  *  @Constraints None
355  *  @Reentrant   Yes
356  *  @return      uint32_t Returns the clock frequency .
357  */
DSPI2_GetFreq(void)358 uint32_t DSPI2_GetFreq(void)
359 {
360     return CLOCK_GetBusClkFreq();
361 }
362