1 /* 2 * Copyright 2022 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 */ 7 8 /** 9 * @file kw45b41zevk.c 10 * @brief The kw45b41zevk.c file defines GPIO pins and CMSIS utilities for 11 * kw45b41zevk board. 12 */ 13 14 #include "kw45b41zevk.h" 15 16 #define LPI2C_MASTER_CLOCK (kCLOCK_Lpi2c1) 17 #define LPI2C_MASTER_CLOCK_FREQUENCY (CLOCK_GetIpFreq(LPI2C_MASTER_CLOCK)) 18 19 #define LPSPI_MASTER_CLOCK (kCLOCK_Lpspi0) 20 #define LPSPI_MASTER_CLOCK_FREQUENCY (CLOCK_GetIpFreq(LPSPI_MASTER_CLOCK)) 21 22 #define LPUART_MASTER_CLOCK (kCLOCK_Lpuart1) 23 #define LPUART_MASTER_CLOCK_FREQUENCY (CLOCK_GetIpFreq(LPUART_MASTER_CLOCK)) 24 25 /* Get frequency of lpi2c clock */ 26 #define LPI2C_CLOCK_FREQUENCY (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpi2c0102)) 27 /* Get frequency of lpspi clock */ 28 #define LPSPI_CLOCK_FREQUENCY (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpspi0304)) 29 /* Get frequency of lpspi clock */ 30 #define LPUART_CLOCK_FREQUENCY (CLOCK_GetRootClockFreq(kCLOCK_Root_Lpuart0102)) 31 32 /*! @brief Determines the Clock Frequency feature. 33 * @details The Clock Frequecny computation API required by 34 * fsl_uart_cmsis.c. 35 * @param[in] void 36 * @Constraints None 37 * @Reentrant Yes 38 * @return uint32_t Returns the clock frequency . 39 */ LPUART1_GetFreq(void)40uint32_t LPUART1_GetFreq(void) 41 { 42 /*Clock setting for LPUART*/ 43 CLOCK_SetIpSrc(LPUART_MASTER_CLOCK, kCLOCK_IpSrcFro6M); 44 return LPUART_MASTER_CLOCK_FREQUENCY; 45 } 46 47 /*! @brief Determines the Clock Frequency feature. 48 * @details The Clock Frequecny computation API required by 49 * fsl_i2c_cmsis.c. 50 * @param[in] void 51 * @Constraints None 52 * @Reentrant Yes 53 * @return uint32_t Returns the clock frequency . 54 */ LPI2C1_GetFreq(void)55uint32_t LPI2C1_GetFreq(void) 56 { 57 /*Clock setting for LPI2C*/ 58 CLOCK_SetIpSrc(LPI2C_MASTER_CLOCK, kCLOCK_IpSrcFro192M); 59 CLOCK_SetIpSrcDiv(LPI2C_MASTER_CLOCK, kSCG_SysClkDivBy16); 60 return LPI2C_MASTER_CLOCK_FREQUENCY; 61 } 62 63 /*! @brief Determines the Clock Frequency feature. 64 * @details The Clock Frequecny computation API required by 65 * fsl_spi_cmsis.c. 66 * @param[in] void 67 * @Constraints None 68 * @Reentrant Yes 69 * @return uint32_t Returns the clock frequency . 70 */ LPSPI0_GetFreq(void)71uint32_t LPSPI0_GetFreq(void) 72 { 73 /* Set clock source for LPSPI slave and get the clock source */ 74 CLOCK_SetIpSrc(LPSPI_MASTER_CLOCK, kCLOCK_IpSrcFro192M); 75 CLOCK_SetIpSrcDiv(LPSPI_MASTER_CLOCK, kSCG_SysClkDivBy16); 76 return LPSPI_MASTER_CLOCK_FREQUENCY; 77 } 78