ISSDK  1.8
IoT Sensing Software Development Kit
frdm_ke15z.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2017 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 /**
10  * @file frdm_ke15z.c
11  * @brief The frdm_ke15z.c file defines GPIO pins and I2C CMSIS utilities for FRDM-KE15Z board.
12  */
13 
14 #include "fsl_gpio.h"
15 #include "fsl_port.h"
16 #include "frdm_ke15z.h"
17 
18 // I2C1 Pin Handles
20  .portBase = PORTD,
21  .pinNumber = 9,
22  .mask = 1 << (9),
23  .irq = PORTBCD_IRQn,
24  .clockName = kCLOCK_PortD,
25  .portNumber = PORTD_NUM};
27  .portBase = PORTD,
28  .pinNumber = 8,
29  .mask = 1 << (8),
30  .irq = PORTBCD_IRQn,
31  .clockName = kCLOCK_PortD,
32  .portNumber = PORTD_NUM};
33 
34 // I2C0 Handle
35 gpioHandleKSDK_t A5 = {.base = GPIOA,
36  .portBase = PORTA,
37  .pinNumber = 3,
38  .mask = 1 << (3),
39  .irq = PORTAE_IRQn,
40  .clockName = kCLOCK_PortA,
41  .portNumber = PORTA_NUM};
42 gpioHandleKSDK_t A4 = {.base = GPIOA,
43  .portBase = PORTA,
44  .pinNumber = 2,
45  .mask = 1 << (2),
46  .irq = PORTAE_IRQn,
47  .clockName = kCLOCK_PortA,
48  .portNumber = PORTA_NUM};
49 
50 // SPI0 Handle
52  .portBase = PORTE,
53  .pinNumber = 0,
54  .mask = 1 << (0),
55  .irq = PORTAE_IRQn,
56  .clockName = kCLOCK_PortE,
57  .portNumber = PORTE_NUM};
59  .portBase = PORTE,
60  .pinNumber = 1,
61  .mask = 1 << (1),
62  .irq = PORTAE_IRQn,
63  .clockName = kCLOCK_PortE,
64  .portNumber = PORTE_NUM};
66  .portBase = PORTE,
67  .pinNumber = 2,
68  .mask = 1 << (2),
69  .irq = PORTAE_IRQn,
70  .clockName = kCLOCK_PortE,
71  .portNumber = PORTE_NUM};
72 
73 
74 // UART0 Handle
75 gpioHandleKSDK_t D0 = {.base = GPIOC,
76  .portBase = PORTC,
77  .pinNumber = 8,
78  .mask = 1 << (8),
79  .irq = PORTBCD_IRQn,
80  .clockName = kCLOCK_PortC,
81  .portNumber = PORTC_NUM};
82 gpioHandleKSDK_t D1 = {.base = GPIOC,
83  .portBase = PORTC,
84  .pinNumber = 9,
85  .mask = 1 << (9),
86  .irq = PORTBCD_IRQn,
87  .clockName = kCLOCK_PortC,
88  .portNumber = PORTC_NUM};
89 
90 // FRDM-KE15Z Arduino Connector Pin Defintion
91 gpioHandleKSDK_t A0 = {.base = GPIOA,
92  .portBase = PORTA,
93  .pinNumber = 0,
94  .mask = 1 << (0),
95  .irq = PORTAE_IRQn,
96  .clockName = kCLOCK_PortA,
97  .portNumber = PORTA_NUM};
98 gpioHandleKSDK_t A1 = {.base = GPIOA,
99  .portBase = PORTA,
100  .pinNumber = 1,
101  .mask = 1 << (1),
102  .irq = PORTAE_IRQn,
103  .clockName = kCLOCK_PortA,
104  .portNumber = PORTA_NUM};
106  .portBase = PORTA,
107  .pinNumber = 6,
108  .mask = 1 << (6),
109  .irq = PORTAE_IRQn,
110  .clockName = kCLOCK_PortA,
111  .portNumber = PORTA_NUM};
113  .portBase = PORTA,
114  .pinNumber = 7,
115  .mask = 1 << (7),
116  .irq = PORTAE_IRQn,
117  .clockName = kCLOCK_PortA,
118  .portNumber = PORTA_NUM};
120  .portBase = PORTD,
121  .pinNumber = 12,
122  .mask = 1 << (12),
123  .irq = PORTBCD_IRQn,
124  .clockName = kCLOCK_PortD,
125  .portNumber = PORTD_NUM};
127  .portBase = PORTC,
128  .pinNumber = 15,
129  .mask = 1 << (15),
130  .irq = PORTBCD_IRQn,
131  .clockName = kCLOCK_PortC,
132  .portNumber = PORTC_NUM};
134  .portBase = PORTE,
135  .pinNumber = 9,
136  .mask = 1 << (9),
137  .irq = PORTAE_IRQn,
138  .clockName = kCLOCK_PortE,
139  .portNumber = PORTE_NUM};
141  .portBase = PORTC,
142  .pinNumber = 5,
143  .mask = 1 << (5),
144  .irq = PORTBCD_IRQn,
145  .clockName = kCLOCK_PortC,
146  .portNumber = PORTC_NUM};
148  .portBase = PORTA,
149  .pinNumber = 16,
150  .mask = 1 << (16),
151  .irq = PORTAE_IRQn,
152  .clockName = kCLOCK_PortA,
153  .portNumber = PORTA_NUM};
155  .portBase = PORTA,
156  .pinNumber = 17,
157  .mask = 1 << (17),
158  .irq = PORTAE_IRQn,
159  .clockName = kCLOCK_PortA,
160  .portNumber = PORTA_NUM};
162  .portBase = PORTE,
163  .pinNumber = 8,
164  .mask = 1 << (8),
165  .irq = PORTAE_IRQn,
166  .clockName = kCLOCK_PortE,
167  .portNumber = PORTE_NUM};
169  .portBase = PORTE,
170  .pinNumber = 7,
171  .mask = 1 << (7),
172  .irq = PORTAE_IRQn,
173  .clockName = kCLOCK_PortE,
174  .portNumber = PORTE_NUM};
176  .portBase = PORTA,
177  .pinNumber = 15,
178  .mask = 1 << (15),
179  .irq = PORTAE_IRQn,
180  .clockName = kCLOCK_PortA,
181  .portNumber = PORTA_NUM};
182 
183 // FRDM-KE15Z Internal Peripheral Pin Definitions
185  .portBase = PORTD,
186  .pinNumber = 0,
187  .mask = 1 << (0),
188  .irq = PORTBCD_IRQn,
189  .clockName = kCLOCK_PortD,
190  .portNumber = PORTD_NUM};
192  .portBase = PORTD,
193  .pinNumber = 16,
194  .mask = 1 << (16),
195  .irq = PORTBCD_IRQn,
196  .clockName = kCLOCK_PortD,
197  .portNumber = PORTD_NUM};
199  .portBase = PORTD,
200  .pinNumber = 15,
201  .mask = 1 << (15),
202  .irq = PORTBCD_IRQn,
203  .clockName = kCLOCK_PortD,
204  .portNumber = PORTD_NUM};
205 
206 // FRDM-KE15Z I2C Inertial Sensor Pin Definitions
208  .portBase = PORTB,
209  .pinNumber = 10,
210  .mask = 1 << (10),
211  .irq = PORTBCD_IRQn,
212  .clockName = kCLOCK_PortB,
213  .portNumber = PORTB_NUM};
215  .portBase = PORTB,
216  .pinNumber = 9,
217  .mask = 1 << (9),
218  .irq = PORTBCD_IRQn,
219  .clockName = kCLOCK_PortB,
220  .portNumber = PORTB_NUM};
221 
222 /*! @brief Determines the Clock Frequency feature.
223  * @details The Clock Frequecny computation API required by fsl_uart_cmsis.c.
224  * @param[in] void
225  * @Constraints None
226  * @Reentrant Yes
227  * @return uint32_t Returns the clock frequency .
228  */
229 uint32_t LPUART0_GetFreq(void)
230 {
231  CLOCK_SetIpSrc(kCLOCK_Lpuart0, kCLOCK_IpSrcSircAsync);
232  return CLOCK_GetIpFreq(kCLOCK_Lpuart0);
233 }
234 
235 /*! @brief Determines the Clock Frequency feature.
236  * @details The Clock Frequecny computation API required by fsl_uart_cmsis.c.
237  * @param[in] void
238  * @Constraints None
239  * @Reentrant Yes
240  * @return uint32_t Returns the clock frequency .
241  */
242 uint32_t LPUART1_GetFreq(void)
243 {
244  CLOCK_SetIpSrc(kCLOCK_Lpuart1, kCLOCK_IpSrcSircAsync);
245  return CLOCK_GetIpFreq(kCLOCK_Lpuart1);
246 }
247 
248 /*! @brief Determines the Clock Frequency feature.
249  * @details The Clock Frequecny computation API required by fsl_uart_cmsis.c.
250  * @param[in] void
251  * @Constraints None
252  * @Reentrant Yes
253  * @return uint32_t Returns the clock frequency .
254  */
255 uint32_t LPUART2_GetFreq(void)
256 {
257  CLOCK_SetIpSrc(kCLOCK_Lpuart2, kCLOCK_IpSrcSircAsync);
258  return CLOCK_GetIpFreq(kCLOCK_Lpuart2);
259 }
260 
261 /*! @brief Determines the Clock Frequency feature.
262  * @details The Clock Frequecny computation API required by fsl_i2c_cmsis.c.
263  * @param[in] void
264  * @Constraints None
265  * @Reentrant Yes
266  * @return uint32_t Returns the clock frequency .
267  */
268 uint32_t LPI2C0_GetFreq(void)
269 {
270  CLOCK_SetIpSrc(kCLOCK_Lpi2c0, kCLOCK_IpSrcFircAsync);
271  return CLOCK_GetIpFreq(kCLOCK_Lpi2c0);
272 }
273 
274 /*! @brief Determines the Clock Frequency feature.
275  * @details The Clock Frequecny computation API required by fsl_i2c_cmsis.c.
276  * @param[in] void
277  * @Constraints None
278  * @Reentrant Yes
279  * @return uint32_t Returns the clock frequency .
280  */
281 uint32_t LPI2C1_GetFreq(void)
282 {
283  CLOCK_SetIpSrc(kCLOCK_Lpi2c1, kCLOCK_IpSrcFircAsync);
284  return CLOCK_GetIpFreq(kCLOCK_Lpi2c1);
285 }
286 
287 /*! @brief Determines the Clock Frequency feature.
288  * @details The Clock Frequecny computation API required by fsl_spi_cmsis.c.
289  * @param[in] void
290  * @Constraints None
291  * @Reentrant Yes
292  * @return uint32_t Returns the clock frequency .
293  */
294 uint32_t LPSPI0_GetFreq(void)
295 {
296  CLOCK_SetIpSrc(kCLOCK_Lpspi0, kCLOCK_IpSrcFircAsync);
297  return CLOCK_GetIpFreq(kCLOCK_Lpspi0);
298 }
299 
300 /*! @brief Determines the Clock Frequency feature.
301  * @details The Clock Frequecny computation API required by fsl_spi_cmsis.c.
302  * @param[in] void
303  * @Constraints None
304  * @Reentrant Yes
305  * @return uint32_t Returns the clock frequency .
306  */
307 uint32_t LPSPI1_GetFreq(void)
308 {
309  CLOCK_SetIpSrc(kCLOCK_Lpspi1, kCLOCK_IpSrcFircAsync);
310  return CLOCK_GetIpFreq(kCLOCK_Lpspi1);
311 }
312 
313 /*! @brief Reset the onboard FXOS8700.
314  * @details The API to Reset the onboard FXOS8700 after hardware reset to enable I2C communication.
315  * @param[in] void
316  * @Constraints None
317  * @Reentrant Yes
318  * @return void
319  */
321 {
322  uint32_t i;
323  gpio_pin_config_t pin_config;
324 
325  /* Enable Clock for Reset Port */
326  CLOCK_EnableClock(kCLOCK_PortB);
327  /* PORTB9 (pin 76) is configured as PTB9 */
328  PORT_SetPinMux(PORTB, 9, kPORT_MuxAsGpio);
329 
330  /* Reset sensor by reset pin*/
331  pin_config.pinDirection = kGPIO_DigitalOutput;
332  pin_config.outputLogic = 1;
333  GPIO_PinInit(GPIOB, 9, &pin_config);
334  GPIO_WritePinOutput(GPIOB, 9, 1);
335  /* Delay to ensure reliable sensor reset */
336  for (i = 0; i < SystemCoreClock / 1000U; i++)
337  {
338  __NOP();
339  }
340  GPIO_WritePinOutput(GPIOB, 9, 0);
341 
342  /* Delay to wait sensor stable after reset */
343  for (i = 0; i < SystemCoreClock / 1000U; i++)
344  {
345  __NOP();
346  }
347 }
gpioHandleKSDK_t D11
Definition: frdm_ke15z.c:65
void BOARD_ACCEL_Reset(void)
Reset the onboard FXOS8700.
Definition: frdm_ke15z.c:320
gpioHandleKSDK_t D7
Definition: frdm_ke15z.c:154
gpioHandleKSDK_t RST_A
Definition: frdm_ke15z.c:214
uint32_t LPUART1_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:242
uint32_t LPSPI1_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:307
gpioHandleKSDK_t A0
Definition: frdm_ke15z.c:91
gpioHandleKSDK_t INT1
Definition: frdm_ke15z.c:207
gpioHandleKSDK_t RED_LED
Definition: frdm_ke15z.c:184
uint32_t LPUART0_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:229
gpioHandleKSDK_t D6
Definition: frdm_ke15z.c:147
gpioHandleKSDK_t BLUE_LED
Definition: frdm_ke15z.c:198
gpioHandleKSDK_t D10
Definition: frdm_ke15z.c:175
The GPIO pin handle for KSDK.
Definition: gpio_driver.h:49
uint32_t LPI2C1_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:281
gpioHandleKSDK_t A5
Definition: frdm_ke15z.c:35
gpioHandleKSDK_t D12
Definition: frdm_ke15z.c:58
gpioHandleKSDK_t GREEN_LED
Definition: frdm_ke15z.c:191
gpioHandleKSDK_t D5
Definition: frdm_ke15z.c:140
gpioHandleKSDK_t D3
Definition: frdm_ke15z.c:126
gpioHandleKSDK_t A4
Definition: frdm_ke15z.c:42
uint32_t LPSPI0_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:294
gpioHandleKSDK_t D13
Definition: frdm_ke15z.c:51
gpioHandleKSDK_t D4
Definition: frdm_ke15z.c:133
uint32_t LPI2C0_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:268
GPIO_Type * base
Definition: gpio_driver.h:51
gpioHandleKSDK_t A2
Definition: frdm_ke15z.c:105
gpioHandleKSDK_t A1
Definition: frdm_ke15z.c:98
uint32_t LPUART2_GetFreq(void)
Determines the Clock Frequency feature.
Definition: frdm_ke15z.c:255
gpioHandleKSDK_t D9
Definition: frdm_ke15z.c:168
gpioHandleKSDK_t D15
Definition: frdm_ke15z.c:19
gpioHandleKSDK_t D1
Definition: frdm_ke15z.c:82
The frdm_ke15z.h file defines GPIO pin mappings for FRDM-KE15Z board.
uint32_t SystemCoreClock
gpioHandleKSDK_t D0
Definition: frdm_ke15z.c:75
gpioHandleKSDK_t D2
Definition: frdm_ke15z.c:119
gpioHandleKSDK_t A3
Definition: frdm_ke15z.c:112
gpioHandleKSDK_t D14
Definition: frdm_ke15z.c:26
gpioHandleKSDK_t D8
Definition: frdm_ke15z.c:161