2 * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * o Redistributions of source code must retain the above copyright notice, this list
9 * of conditions and the following disclaimer.
11 * o Redistributions in binary form must reproduce the above copyright notice, this
12 * list of conditions and the following disclaimer in the documentation and/or
13 * other materials provided with the distribution.
15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #if !defined(__FSL_SIM_HAL_H__)
32 #define __FSL_SIM_HAL_H__
37 #include "fsl_device_registers.h"
38 #include "fsl_sim_features.h"
40 /*! @addtogroup sim_hal*/
45 /*******************************************************************************
47 ******************************************************************************/
48 typedef enum _clock_names
{
58 /* other internal clocks used by peripherals*/
82 /* constant clocks (provided in other header files?)*/
95 /*! @brief Clock source and sel names */
96 typedef enum _clock_source_names
{
97 kClockNfcSrc
, /* NFCSRC*/
98 kClockEsdhcSrc
, /* ESDHCSRC K70*/
99 kClockSdhcSrc
, /* SDHCSRC K64*/
100 kClockLcdcSrc
, /* LCDCSRC*/
101 kClockTimeSrc
, /* TIMESRC*/
102 kClockRmiiSrc
, /* RMIISRC*/
103 kClockUsbfSrc
, /* USBFSRC K70*/
104 kClockUsbSrc
, /* USBSRC K64, KL25, KV31, and K22*/
105 kClockUsbhSrc
, /* USBHSRC*/
106 kClockUart0Src
, /* UART0SRC*/
107 kClockLpuartSrc
, /* LPUARTSRC K22, KV31 */
108 kClockTpmSrc
, /* TPMSRC*/
109 kClockOsc32kSel
, /* OSC32KSEL*/
110 kClockUsbfSel
, /* USBF_CLKSEL*/
111 kClockPllfllSel
, /* PLLFLLSEL*/
112 kClockNfcSel
, /* NFC_CLKSEL*/
113 kClockLcdcSel
, /* LCDC_CLKSEL*/
114 kClockTraceSel
, /* TRACE_CLKSEL*/
115 kClockClkoutSel
, /* CLKOUTSEL*/
116 kClockRtcClkoutSel
, /* RTCCLKOUTSEL */
118 } clock_source_names_t
;
120 /*! @brief Clock Divider names*/
121 typedef enum _clock_divider_names
{
122 kClockDividerOutdiv1
, /* OUTDIV1*/
123 kClockDividerOutdiv2
, /* OUTDIV2*/
124 kClockDividerOutdiv3
, /* OUTDIV3*/
125 kClockDividerOutdiv4
, /* OUTDIV4*/
126 kClockDividerUsbFrac
, /* (USBFRAC + 1) / (USBDIV + 1)*/
128 kClockDividerUsbfsFrac
, /* (USBFSFRAC + 1) / (USBFSDIV) + 1)*/
129 kClockDividerUsbfsDiv
,
130 kClockDividerUsbhsFrac
, /* (USBHSFRAC + 1) / (USBHSDIV + 1)*/
131 kClockDividerUsbhsDiv
,
132 kClockDividerLcdcFrac
, /* (LCDCFRAC + 1) / (LCDCDIV + 1)*/
133 kClockDividerLcdcDiv
,
134 kClockDividerNfcFrac
, /* (NFCFRAC + 1) / (NFCDIV + 1)*/
136 kClockDividerSpecial1
, /* special divider 1*/
138 } clock_divider_names_t
;
140 /*! @brief SIM USB voltage regulator in standby mode setting during stop modes */
141 typedef enum _sim_usbsstby_stop
143 kSimUsbsstbyNoRegulator
, /* regulator not in standby during Stop modes */
144 kSimUsbsstbyWithRegulator
/* regulator in standby during Stop modes */
145 } sim_usbsstby_stop_t
;
147 /*! @brief SIM USB voltage regulator in standby mode setting during VLPR and VLPW modes */
148 typedef enum _sim_usbvstby_stop
150 kSimUsbvstbyNoRegulator
, /* regulator not in standby during VLPR and VLPW modes */
151 kSimUsbvstbyWithRegulator
/* regulator in standby during VLPR and VLPW modes */
152 } sim_usbvstby_stop_t
;
154 /*! @brief SIM CMT/UART pad drive strength */
155 typedef enum _sim_cmtuartpad_strengh
157 kSimCmtuartSinglePad
, /* Single-pad drive strength for CMT IRO or UART0_TXD */
158 kSimCmtuartDualPad
/* Dual-pad drive strength for CMT IRO or UART0_TXD */
159 } sim_cmtuartpad_strengh_t
;
161 /*! @brief SIM PTD7 pad drive strength */
162 typedef enum _sim_ptd7pad_strengh
164 kSimPtd7padSinglePad
, /* Single-pad drive strength for PTD7 */
165 kSimPtd7padDualPad
/* Dual-pad drive strength for PTD7 */
166 } sim_ptd7pad_strengh_t
;
168 /*! @brief SIM FlexBus security level */
169 typedef enum _sim_flexbus_security_level
171 kSimFbslLevel0
, /* All off-chip accesses (op code and data) via the FlexBus */
172 /* and DDR controller are disallowed */
173 kSimFbslLevel1
, /* Undefined */
174 kSimFbslLevel2
, /* Off-chip op code accesses are disallowed. Data accesses */
176 kSimFbslLevel3
/* Off-chip op code accesses and data accesses are allowed */
177 } sim_flexbus_security_level_t
;
179 /*! @brief SIM ADCx pre-trigger select */
180 typedef enum _sim_pretrgsel
182 kSimAdcPretrgselA
, /* Pre-trigger A selected for ADCx */
183 kSimAdcPretrgselB
/* Pre-trigger B selected for ADCx */
186 /*! @brief SIM ADCx trigger select */
187 typedef enum _sim_trgsel
189 kSimAdcTrgselExt
, /* External trigger */
190 kSimAdcTrgSelHighSpeedComp0
, /* High speed comparator 0 asynchronous interrupt */
191 kSimAdcTrgSelHighSpeedComp1
, /* High speed comparator 1 asynchronous interrupt */
192 kSimAdcTrgSelHighSpeedComp2
, /* High speed comparator 2 asynchronous interrupt */
193 kSimAdcTrgSelPit0
, /* PIT trigger 0 */
194 kSimAdcTrgSelPit1
, /* PIT trigger 1 */
195 kSimAdcTrgSelPit2
, /* PIT trigger 2 */
196 kSimAdcTrgSelPit3
, /* PIT trigger 3 */
197 kSimAdcTrgSelFtm0
, /* FTM0 trigger */
198 kSimAdcTrgSelFtm1
, /* FTM1 trigger */
199 kSimAdcTrgSelFtm2
, /* FTM2 trigger */
200 kSimAdcTrgSelFtm3
, /* FTM3 trigger */
201 kSimAdcTrgSelRtcAlarm
, /* RTC alarm */
202 kSimAdcTrgSelRtcSec
, /* RTC seconds */
203 kSimAdcTrgSelLptimer
, /* Low-power timer trigger */
204 kSimAdcTrgSelHigSpeedComp3
/* High speed comparator 3 asynchronous interrupt */
207 /*! @brief SIM receive data source select */
208 typedef enum _sim_uart_rxsrc
210 kSimUartRxsrcPin
, /* UARTx_RX Pin */
211 kSimUartRxsrcCmp0
, /* CMP0 */
212 kSimUartRxsrcCmp1
, /* CMP1 */
213 kSimUartRxsrcReserved
/* Reserved */
216 /*! @brief SIM transmit data source select */
217 typedef enum _sim_uart_txsrc
219 kSimUartTxsrcPin
, /* UARTx_TX Pin */
220 kSimUartTxsrcCmp0
, /* UARTx_TX pin modulated with FTM1 channel 0 output */
221 kSimUartTxsrcCmp1
, /* UARTx_TX pin modulated with FTM2 channel 0 output */
222 kSimUartTxsrcReserved
/* Reserved */
225 /*! @brief SIM FlexTimer x trigger y select */
226 typedef enum _sim_ftm_trg_src
228 kSimFtmTrgSrc0
, /* FlexTimer x trigger y select 0 */
229 kSimFtmTrgSrc1
/* FlexTimer x trigger y select 1 */
232 /*! @brief SIM FlexTimer external clock select */
233 typedef enum _sim_ftm_clk_sel
235 kSimFtmClkSel0
, /* FTM CLKIN0 pin. */
236 kSimFtmClkSel1
/* FTM CLKIN1 pin. */
239 /*! @brief SIM FlexTimer x channel y input capture source select */
240 typedef enum _sim_ftm_ch_src
242 kSimFtmChSrc0
, /* See RM for details of each selection for each channel */
243 kSimFtmChSrc1
, /* See RM for details of each selection for each channel */
244 kSimFtmChSrc2
, /* See RM for details of each selection for each channel */
245 kSimFtmChSrc3
/* See RM for details of each selection for each channel */
248 /*! @brief SIM FlexTimer x Fault y select */
249 typedef enum _sim_ftm_flt_sel
251 kSimFtmFltSel0
, /* FlexTimer x fault y select 0 */
252 kSimFtmFltSel1
/* FlexTimer x fault y select 1 */
255 /*! @brief SIM Timer/PWM external clock select */
256 typedef enum _sim_tpm_clk_sel
258 kSimTpmClkSel0
, /* Timer/PWM TPM_CLKIN0 pin. */
259 kSimTpmClkSel1
/* Timer/PWM TPM_CLKIN1 pin. */
262 /*! @brief SIM Timer/PWM x channel y input capture source select */
263 typedef enum _sim_tpm_ch_src
265 kSimTpmChSrc0
, /* TPMx_CH0 signal */
266 kSimTpmChSrc1
/* CMP0 output */
269 /*! @brief SIM HAL API return status*/
270 typedef enum _sim_hal_status
{
274 kSimHalNoSuchClockSrc
,
278 /*! @brief Clock name configuration table structure*/
279 typedef struct ClockNameConfig
{
280 bool useOtherRefClock
; /*!< if it uses the other ref clock*/
281 clock_names_t otherRefClockName
; /*!< other ref clock name*/
282 clock_divider_names_t dividerName
; /*!< clock divider name*/
283 } clock_name_config_t
;
285 /*! @brief clock name configuration table for specified CPU defined in fsl_clock_module_names_Kxxx.h*/
286 extern const clock_name_config_t kClockNameConfigTable
[];
289 /*******************************************************************************
291 ******************************************************************************/
293 #if defined(__cplusplus)
295 #endif /* __cplusplus*/
297 /*! @name clock-related feature APIs*/
301 * @brief Sets the clock source setting.
303 * This function sets the settings for a specified clock source. Each clock
304 * source has its own clock selection settings. See the chip reference manual for
305 * clock source detailed settings and the clock_source_names_t
308 * @param baseAddr Base address for current SIM instance.
309 * @param clockSource Clock source name defined in sim_clock_source_names_t
310 * @param setting Setting value
311 * @return status If the clock source doesn't exist, it returns an error.
313 sim_hal_status_t
CLOCK_HAL_SetSource(uint32_t baseAddr
, clock_source_names_t clockSource
, uint8_t setting
);
316 * @brief Gets the clock source setting.
318 * This function gets the settings for a specified clock source. Each clock
319 * source has its own clock selection settings. See the reference manual for
320 * clock source detailed settings and the clock_source_names_t
323 * @param baseAddr Base address for current SIM instance.
324 * @param clockSource Clock source name
325 * @param setting Current setting pointer for the clock source
326 * @return status If the clock source doesn't exist, it returns an error.
328 sim_hal_status_t
CLOCK_HAL_GetSource(uint32_t baseAddr
, clock_source_names_t clockSource
,
332 * @brief Sets the clock divider setting.
334 * This function sets the setting for a specified clock divider. See the
335 * reference manual for a supported clock divider and value range and the
336 * clock_divider_names_t for dividers.
338 * @param baseAddr Base address for current SIM instance.
339 * @param clockDivider Clock divider name
340 * @param setting Divider setting
341 * @return status If the clock divider doesn't exist, it returns an error.
343 sim_hal_status_t
CLOCK_HAL_SetDivider(uint32_t baseAddr
, clock_divider_names_t clockDivider
,
347 * @brief Sets the clock out dividers setting.
349 * This function sets the setting for all clock out dividers at the same time.
350 * See the reference manual for a supported clock divider and value range and the
351 * clock_divider_names_t for clock out dividers.
353 * @param baseAddr Base address for current SIM instance.
354 * @param outdiv1 Outdivider1 setting
355 * @param outdiv2 Outdivider2 setting
356 * @param outdiv3 Outdivider3 setting
357 * @param outdiv4 Outdivider4 setting
359 void CLOCK_HAL_SetOutDividers(uint32_t baseAddr
, uint32_t outdiv1
, uint32_t outdiv2
,
360 uint32_t outdiv3
, uint32_t outdiv4
);
363 * @brief Gets the clock divider setting.
365 * This function gets the setting for a specified clock divider. See the
366 * reference manual for a supported clock divider and value range and the
367 * clock_divider_names_t for dividers.
369 * @param baseAddr Base address for current SIM instance.
370 * @param clockDivider Clock divider name
371 * @param setting Divider value pointer
372 * @return status If the clock divider doesn't exist, it returns an error.
374 sim_hal_status_t
CLOCK_HAL_GetDivider(uint32_t baseAddr
, clock_divider_names_t clockDivider
,
379 /*! @name individual field access APIs*/
382 #if FSL_FEATURE_SIM_OPT_HAS_RAMSIZE
384 * @brief Gets RAM size.
386 * This function gets the RAM size. The field specifies the amount of system RAM
387 * available on the device.
389 * @param baseAddr Base address for current SIM instance.
390 * @return size RAM size on the device
392 static inline uint32_t SIM_HAL_GetRamSize(uint32_t baseAddr
)
394 return BR_SIM_SOPT1_RAMSIZE(baseAddr
);
396 #endif /* FSL_FEATURE_SIM_OPT_HAS_RAMSIZE */
398 #if FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR
400 * @brief Sets the USB voltage regulator enabled setting.
402 * This function controls whether the USB voltage regulator is enabled. This bit
403 * can only be written when the SOPT1CFG[URWE] bit is set.
405 * @param baseAddr Base address for current SIM instance.
406 * @param enable USB voltage regulator enable setting
407 * - true: USB voltage regulator is enabled.
408 * - false: USB voltage regulator is disabled.
410 static inline void SIM_HAL_SetUsbVoltRegulatorCmd(uint32_t baseAddr
, bool enable
)
412 BW_SIM_SOPT1_USBREGEN(baseAddr
, enable
? 1 : 0);
416 * @brief Gets the USB voltage regulator enabled setting.
418 * This function gets the USB voltage regulator enabled setting.
420 * @param baseAddr Base address for current SIM instance.
421 * @return enabled True if the USB voltage regulator is enabled.
423 static inline bool SIM_HAL_GetUsbVoltRegulatorCmd(uint32_t baseAddr
)
425 return BR_SIM_SOPT1_USBREGEN(baseAddr
);
429 * @brief Sets the USB voltage regulator in a standby mode setting during Stop, VLPS, LLS, and VLLS.
431 * This function controls whether the USB voltage regulator is placed in a standby
432 * mode during Stop, VLPS, LLS, and VLLS modes. This bit can only be written when the
433 * SOPT1CFG[USSWE] bit is set.
435 * @param baseAddr Base address for current SIM instance.
436 * @param setting USB voltage regulator in standby mode setting
437 * - 0: USB voltage regulator not in standby during Stop, VLPS, LLS and
439 * - 1: USB voltage regulator in standby during Stop, VLPS, LLS and VLLS
442 static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopMode(uint32_t baseAddr
,
443 sim_usbsstby_stop_t setting
)
445 BW_SIM_SOPT1_USBSSTBY(baseAddr
, setting
);
449 * @brief Gets the USB voltage regulator in a standby mode setting.
451 * This function gets the USB voltage regulator in a standby mode setting.
453 * @param baseAddr Base address for current SIM instance.
454 * @return setting USB voltage regulator in a standby mode setting
456 static inline sim_usbsstby_stop_t
SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopMode(uint32_t baseAddr
)
458 return (sim_usbsstby_stop_t
)BR_SIM_SOPT1_USBSSTBY(baseAddr
);
462 * @brief Sets the USB voltage regulator in a standby mode during the VLPR or the VLPW.
464 * This function controls whether the USB voltage regulator is placed in a standby
465 * mode during the VLPR and the VLPW modes. This bit can only be written when the
466 * SOPT1CFG[UVSWE] bit is set.
468 * @param baseAddr Base address for current SIM instance.
469 * @param setting USB voltage regulator in standby mode setting
470 * - 0: USB voltage regulator not in standby during VLPR and VLPW modes.
471 * - 1: USB voltage regulator in standby during VLPR and VLPW modes.
473 static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwMode(uint32_t baseAddr
,
474 sim_usbvstby_stop_t setting
)
476 BW_SIM_SOPT1_USBVSTBY(baseAddr
, setting
);
480 * @brief Gets the USB voltage regulator in a standby mode during the VLPR or the VLPW.
482 * This function gets the USB voltage regulator in a standby mode during the VLPR or the VLPW.
484 * @param baseAddr Base address for current SIM instance.
485 * @return setting USB voltage regulator in a standby mode during the VLPR or the VLPW
487 static inline sim_usbvstby_stop_t
SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwMode(uint32_t baseAddr
)
489 return (sim_usbvstby_stop_t
)BR_SIM_SOPT1_USBVSTBY(baseAddr
);
493 * @brief Sets the USB voltage regulator stop standby write enable setting.
495 * This function controls whether the USB voltage regulator stop standby write
496 * feature is enabled. Writing one to this bit allows the SOPT1[USBSSTBY] bit to be written. This
497 * register bit clears after a write to SOPT1[USBSSTBY].
499 * @param baseAddr Base address for current SIM instance.
500 * @param enable USB voltage regulator stop standby write enable setting
501 * - true: SOPT1[USBSSTBY] can be written.
502 * - false: SOPT1[USBSSTBY] cannot be written.
504 static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringStopCmd(uint32_t baseAddr
, bool enable
)
506 BW_SIM_SOPT1CFG_USSWE(baseAddr
, enable
? 1 : 0);
510 * @brief Gets the USB voltage regulator stop standby write enable setting.
512 * This function gets the USB voltage regulator stop standby write enable setting.
514 * @param baseAddr Base address for current SIM instance.
515 * @return enabled True if the USB voltage regulator stop standby write is enabled.
517 static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringStopCmd(uint32_t baseAddr
)
519 return BR_SIM_SOPT1CFG_USSWE(baseAddr
);
523 * @brief Sets the USB voltage regulator VLP standby write enable setting.
525 * This function controls whether USB voltage regulator VLP standby write
526 * feature is enabled. Writing one to this bit allows the SOPT1[USBVSTBY] bit to be written. This
527 * register bit clears after a write to SOPT1[USBVSTBY].
529 * @param baseAddr Base address for current SIM instance.
530 * @param enable USB voltage regulator VLP standby write enable setting
531 * - true: SOPT1[USBSSTBY] can be written.
532 * - false: SOPT1[USBSSTBY] cannot be written.
534 static inline void SIM_HAL_SetUsbVoltRegulatorInStdbyDuringVlprwCmd(uint32_t baseAddr
, bool enable
)
536 BW_SIM_SOPT1CFG_UVSWE(baseAddr
, enable
? 1 : 0);
540 * @brief Gets the USB voltage regulator VLP standby write enable setting.
542 * This function gets the USB voltage regulator VLP standby write enable setting.
544 * @param baseAddr Base address for current SIM instance.
545 * @return enabled True if the USB voltage regulator VLP standby write is enabled.
547 static inline bool SIM_HAL_GetUsbVoltRegulatorInStdbyDuringVlprwCmd(uint32_t baseAddr
)
549 return BR_SIM_SOPT1CFG_UVSWE(baseAddr
);
553 * @brief Sets the USB voltage regulator enable write enable setting.
555 * This function controls whether the USB voltage regulator write enable
556 * feature is enabled. Writing one to this bit allows the SOPT1[USBREGEN] bit to be written.
557 * This register bit clears after a write to SOPT1[USBREGEN].
559 * @param baseAddr Base address for current SIM instance.
560 * @param enable USB voltage regulator enable write enable setting
561 * - true: SOPT1[USBSSTBY] can be written.
562 * - false: SOPT1[USBSSTBY] cannot be written.
564 static inline void SIM_HAL_SetUsbVoltRegulatorWriteCmd(uint32_t baseAddr
, bool enable
)
566 BW_SIM_SOPT1CFG_URWE(baseAddr
, enable
? 1 : 0);
570 * @brief Gets the USB voltage regulator enable write enable setting.
572 * This function gets the USB voltage regulator enable write enable setting.
574 * @param baseAddr Base address for current SIM instance.
575 * @return enabled True if USB voltage regulator enable write is enabled.
577 static inline bool SIM_HAL_GetUsbVoltRegulatorWriteCmd(uint32_t baseAddr
)
579 return BR_SIM_SOPT1CFG_URWE(baseAddr
);
583 #if FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD
585 * @brief Sets the CMT/UART pad drive strength setting.
587 * This function controls the output drive strength of the CMT IRO signal or
588 * UART0_TXD signal on PTD7 pin by selecting either one or two pads to drive it.
590 * @param baseAddr Base address for current SIM instance.
591 * @param setting CMT/UART pad drive strength setting
592 * - 0: Single-pad drive strength for CMT IRO or UART0_TXD.
593 * - 1: Dual-pad drive strength for CMT IRO or UART0_TXD.
595 static inline void SIM_HAL_SetCmtUartPadDriveStrengthMode(uint32_t baseAddr
,
596 sim_cmtuartpad_strengh_t setting
)
598 BW_SIM_SOPT2_CMTUARTPAD(baseAddr
, setting
);
602 * @brief Gets the CMT/UART pad drive strength setting.
604 * This function gets the CMT/UART pad drive strength setting.
606 * @param baseAddr Base address for current SIM instance.
607 * @return setting CMT/UART pad drive strength setting
609 static inline sim_cmtuartpad_strengh_t
SIM_HAL_GetCmtUartPadDriveStrengthMode(uint32_t baseAddr
)
611 return (sim_cmtuartpad_strengh_t
)BR_SIM_SOPT2_CMTUARTPAD(baseAddr
);
613 #endif /* FSL_FEATURE_SIM_OPT_HAS_CMTUARTPAD */
615 #if FSL_FEATURE_SIM_OPT_HAS_PTD7PAD
617 * @brief Sets the PTD7 pad drive strength setting.
619 * This function controls the output drive strength of the PTD7 pin by selecting
620 * either one or two pads to drive it.
622 * @param baseAddr Base address for current SIM instance.
623 * @param setting PTD7 pad drive strength setting
624 * - 0: Single-pad drive strength for PTD7.
625 * - 1: Double pad drive strength for PTD7.
627 static inline void SIM_HAL_SetPtd7PadDriveStrengthMode(uint32_t baseAddr
,
628 sim_ptd7pad_strengh_t setting
)
630 BW_SIM_SOPT2_PTD7PAD(baseAddr
, setting
);
634 * @brief Gets the PTD7 pad drive strength setting.
636 * This function gets the PTD7 pad drive strength setting.
638 * @param baseAddr Base address for current SIM instance.
639 * @return setting PTD7 pad drive strength setting
641 static inline sim_ptd7pad_strengh_t
SIM_HAL_GetPtd7PadDriveStrengthMode(uint32_t baseAddr
)
643 return (sim_ptd7pad_strengh_t
)BR_SIM_SOPT2_PTD7PAD(baseAddr
);
645 #endif /* FSL_FEATURE_SIM_OPT_HAS_PTD7PAD */
647 #if FSL_FEATURE_SIM_OPT_HAS_FBSL
649 * @brief Sets the FlexBus security level setting.
651 * This function sets the FlexBus security level setting. If the security is enabled,
652 * this field affects which CPU operations can access the off-chip via the FlexBus
653 * and DDR controller interfaces. This field has no effect if the security is not enabled.
655 * @param baseAddr Base address for current SIM instance.
656 * @param setting FlexBus security level setting
657 * - 00: All off-chip accesses (op code and data) via the FlexBus and
658 * DDR controller are disallowed.
659 * - 10: Off-chip op code accesses are disallowed. Data accesses are
661 * - 11: Off-chip op code accesses and data accesses are allowed.
663 static inline void SIM_HAL_SetFlexbusSecurityLevelMode(uint32_t baseAddr
,
664 sim_flexbus_security_level_t setting
)
666 BW_SIM_SOPT2_FBSL(baseAddr
, setting
);
670 * @brief Gets the FlexBus security level setting.
672 * This function gets the FlexBus security level setting.
674 * @param baseAddr Base address for current SIM instance.
675 * @return setting FlexBus security level setting
677 static inline sim_flexbus_security_level_t
SIM_HAL_GetFlexbusSecurityLevelMode(uint32_t baseAddr
)
679 return (sim_flexbus_security_level_t
)BR_SIM_SOPT2_FBSL(baseAddr
);
681 #endif /* FSL_FEATURE_SIM_OPT_HAS_FBSL */
683 #if FSL_FEATURE_SIM_OPT_HAS_PCR
685 * @brief Sets the PCR setting.
687 * This function sets the PCR setting. This is the FlexBus hold cycles before
688 * FlexBus can release bus to NFC or to IDLE.
690 * @param baseAddr Base address for current SIM instance.
691 * @param setting PCR setting
693 static inline void SIM_HAL_SetFlexbusHoldCycles(uint32_t baseAddr
, uint32_t setting
)
695 BW_SIM_SOPT6_PCR(baseAddr
, setting
);
699 * @brief Gets the PCR setting.
701 * This function gets the PCR setting.
703 * @param baseAddr Base address for current SIM instance.
704 * @return setting PCR setting
706 static inline uint32_t SIM_HAL_GetFlexbusHoldCycles(uint32_t baseAddr
)
708 return BR_SIM_SOPT6_PCR(baseAddr
);
710 #endif /* FSL_FEATURE_SIM_OPT_HAS_PCR */
712 #if FSL_FEATURE_SIM_OPT_HAS_MCC
714 * @brief Sets the MCC setting.
716 * This function sets the MCC setting. This is the NFC hold cycle in case the
717 * FlexBus request during NFC is granted.
719 * @param baseAddr Base address for current SIM instance.
720 * @param setting MCC setting
722 static inline void SIM_HAL_SetNandFlashControllerHoldCycles(uint32_t baseAddr
, uint32_t setting
)
724 BW_SIM_SOPT6_MCC(baseAddr
, setting
);
728 * @brief Gets the MCC setting.
730 * This function gets the MCC setting.
732 * @param baseAddr Base address for current SIM instance.
733 * @return setting MCC setting
735 static inline uint32_t SIM_HAL_GetNandFlashControllerHoldCycles(uint32_t baseAddr
)
737 return BR_SIM_SOPT6_MCC(baseAddr
);
739 #endif /* FSL_FEATURE_SIM_OPT_HAS_MCC */
742 * @brief Sets the ADCx alternate trigger enable setting.
744 * This function enables/disables the alternative conversion triggers for ADCx.
746 * @param baseAddr Base address for current SIM instance.
747 * @param instance device instance.
748 * @param enable Enable alternative conversion triggers for ADCx
749 * - true: Select alternative conversion trigger.
750 * - false: Select PDB trigger.
752 void SIM_HAL_SetAdcAlternativeTriggerCmd(uint32_t baseAddr
, uint8_t instance
, bool enable
);
755 * @brief Gets the ADCx alternate trigger enable setting.
757 * This function gets the ADCx alternate trigger enable setting.
759 * @param baseAddr Base address for current SIM instance.
760 * @param instance device instance.
761 * @return enabled True if ADCx alternate trigger is enabled
763 bool SIM_HAL_GetAdcAlternativeTriggerCmd(uint32_t baseAddr
, uint8_t instance
);
766 * @brief Sets the ADCx pre-trigger select setting.
768 * This function selects the ADCx pre-trigger source when the alternative triggers
769 * are enabled through ADCxALTTRGEN.
771 * @param baseAddr Base address for current SIM instance.
772 * @param instance device instance.
773 * @param select pre-trigger select setting for ADCx
774 * - 0: Pre-trigger A selected for ADCx.
775 * - 1: Pre-trigger B selected for ADCx.
777 void SIM_HAL_SetAdcPreTriggerMode(uint32_t baseAddr
, uint8_t instance
, sim_pretrgsel_t select
);
780 * @brief Gets the ADCx pre-trigger select setting.
782 * This function gets the ADCx pre-trigger select setting.
784 * @param baseAddr Base address for current SIM instance.
785 * @param instance device instance.
786 * @return select ADCx pre-trigger select setting
788 sim_pretrgsel_t
SIM_HAL_GetAdcPreTriggerMode(uint32_t baseAddr
, uint8_t instance
);
791 * @brief Sets the ADCx trigger select setting.
793 * This function selects the ADCx trigger source when alternative triggers
794 * are enabled through ADCxALTTRGEN.
796 * @param baseAddr Base address for current SIM instance.
797 * @param instance device instance.
798 * @param select trigger select setting for ADCx
799 * - 0000: External trigger
800 * - 0001: High speed comparator 0 asynchronous interrupt
801 * - 0010: High speed comparator 1 asynchronous interrupt
802 * - 0011: High speed comparator 2 asynchronous interrupt
803 * - 0100: PIT trigger 0
804 * - 0101: PIT trigger 1
805 * - 0110: PIT trigger 2
806 * - 0111: PIT trigger 3
807 * - 1000: FTM0 trigger
808 * - 1001: FTM1 trigger
809 * - 1010: FTM2 trigger
810 * - 1011: FTM3 trigger
812 * - 1101: RTC seconds
813 * - 1110: Low-power timer trigger
814 * - 1111: High speed comparator 3 asynchronous interrupt
816 void SIM_HAL_SetAdcTriggerMode(uint32_t baseAddr
, uint8_t instance
, sim_trgsel_t select
);
819 * @brief Gets the ADCx trigger select setting.
821 * This function gets the ADCx trigger select setting.
823 * @param baseAddr Base address for current SIM instance.
824 * @param instance device instance.
825 * @return select ADCx trigger select setting
827 sim_pretrgsel_t
SIM_HAL_GetAdcTriggerMode(uint32_t baseAddr
, uint8_t instance
);
830 * @brief Sets the UARTx receive data source select setting.
832 * This function selects the source for the UARTx receive data.
834 * @param baseAddr Base address for current SIM instance.
835 * @param instance device instance.
836 * @param select the source for the UARTx receive data
837 * - 00: UARTx_RX pin.
842 void SIM_HAL_SetUartRxSrcMode(uint32_t baseAddr
, uint8_t instance
, sim_uart_rxsrc_t select
);
845 * @brief Gets the UARTx receive data source select setting.
847 * This function gets the UARTx receive data source select setting.
849 * @param baseAddr Base address for current SIM instance.
850 * @param instance device instance.
851 * @return select UARTx receive data source select setting
853 sim_uart_rxsrc_t
SIM_HAL_GetUartRxSrcMode(uint32_t baseAddr
, uint8_t instance
);
856 * @brief Sets the UARTx transmit data source select setting.
858 * This function selects the source for the UARTx transmit data.
860 * @param baseAddr Base address for current SIM instance.
861 * @param instance device instance.
862 * @param select the source for the UARTx transmit data
863 * - 00: UARTx_TX pin.
864 * - 01: UARTx_TX pin modulated with FTM1 channel 0 output.
865 * - 10: UARTx_TX pin modulated with FTM2 channel 0 output.
868 void SIM_HAL_SetUartTxSrcMode(uint32_t baseAddr
, uint8_t instance
, sim_uart_txsrc_t select
);
871 * @brief Gets the UARTx transmit data source select setting.
873 * This function gets the UARTx transmit data source select setting.
875 * @param baseAddr Base address for current SIM instance.
876 * @param instance device instance.
877 * @return select UARTx transmit data source select setting
879 sim_uart_txsrc_t
SIM_HAL_GetUartTxSrcMode(uint32_t baseAddr
, uint8_t instance
);
881 #if FSL_FEATURE_SIM_OPT_HAS_ODE
883 * @brief Sets the UARTx Open Drain Enable setting.
885 * This function enables/disables the UARTx Open Drain.
887 * @param baseAddr Base address for current SIM instance.
888 * @param instance device instance.
889 * @param enable Enable/disable UARTx Open Drain
890 * - True: Enable UARTx Open Drain
891 * - False: Disable UARTx Open Drain
893 void SIM_HAL_SetUartOpenDrainCmd(uint32_t baseAddr
, uint8_t instance
, bool enable
);
896 * @brief Gets the UARTx Open Drain Enable setting.
898 * This function gets the UARTx Open Drain Enable setting.
900 * @param baseAddr Base address for current SIM instance.
901 * @param instance device instance.
902 * @return enabled True if UARTx Open Drain is enabled.
904 bool SIM_HAL_GetUartOpenDrainCmd(uint32_t baseAddr
, uint8_t instance
);
907 #if FSL_FEATURE_SIM_OPT_HAS_FTM
909 * @brief Sets the FlexTimer x hardware trigger y source select setting.
911 * This function selects the source of FTMx hardware trigger y.
913 * @param baseAddr Base address for current SIM instance.
914 * @param instance device instance.
915 * @param trigger hardware trigger y
916 * @param select FlexTimer x hardware trigger y
917 * - 0: Pre-trigger A selected for ADCx.
918 * - 1: Pre-trigger B selected for ADCx.
920 void SIM_HAL_SetFtmTriggerSrcMode(uint32_t baseAddr
,
923 sim_ftm_trg_src_t select
);
926 * @brief Gets the FlexTimer x hardware trigger y source select setting.
928 * This function gets the FlexTimer x hardware trigger y source select setting.
930 * @param baseAddr Base address for current SIM instance.
931 * @param instance device instance.
932 * @param trigger hardware trigger y
933 * @return select FlexTimer x hardware trigger y source select setting
935 sim_ftm_trg_src_t
SIM_HAL_GetFtmTriggerSrcMode(uint32_t baseAddr
, uint8_t instance
, uint8_t trigger
);
938 * @brief Sets the FlexTimer x external clock pin select setting.
940 * This function selects the source of FTMx external clock pin select.
942 * @param baseAddr Base address for current SIM instance.
943 * @param instance device instance.
944 * @param select FTMx external clock pin select
945 * - 0: FTMx external clock driven by FTM CLKIN0 pin.
946 * - 1: FTMx external clock driven by FTM CLKIN1 pin.
948 void SIM_HAL_SetFtmExternalClkPinMode(uint32_t baseAddr
, uint8_t instance
, sim_ftm_clk_sel_t select
);
951 * @brief Gets the FlexTimer x external clock pin select setting.
953 * This function gets the FlexTimer x external clock pin select setting.
955 * @param baseAddr Base address for current SIM instance.
956 * @param instance device instance.
957 * @return select FlexTimer x external clock pin select setting
959 sim_ftm_clk_sel_t
SIM_HAL_GetFtmExternalClkPinMode(uint32_t baseAddr
, uint8_t instance
);
962 * @brief Sets the FlexTimer x channel y input capture source select setting.
964 * This function selects the FlexTimer x channel y input capture source.
966 * @param baseAddr Base address for current SIM instance.
967 * @param instance device instance.
968 * @param channel FlexTimer channel y
969 * @param select FlexTimer x channel y input capture source
970 * See the reference manual for detailed definition for each channel and selection.
972 void SIM_HAL_SetFtmChSrcMode(uint32_t baseAddr
, uint8_t instance
, uint8_t channel
, sim_ftm_ch_src_t select
);
975 * @brief Gets the FlexTimer x channel y input capture source select setting.
977 * This function gets the FlexTimer x channel y input capture source select setting.
979 * @param baseAddr Base address for current SIM instance.
980 * @param instance device instance.
981 * @param channel FlexTimer channel y
982 * @return select FlexTimer x channel y input capture source select setting
984 sim_ftm_ch_src_t
SIM_HAL_GetFtmChSrcMode(uint32_t baseAddr
, uint8_t instance
, uint8_t channel
);
987 * @brief Sets the FlexTimer x fault y select setting.
989 * This function sets the FlexTimer x fault y select setting.
991 * @param baseAddr Base address for current SIM instance.
992 * @param instance device instance.
993 * @param fault fault y
994 * @param select FlexTimer x fault y select setting
995 * - 0: FlexTimer x fault y select 0.
996 * - 1: FlexTimer x fault y select 1.
998 void SIM_HAL_SetFtmFaultSelMode(uint32_t baseAddr
, uint8_t instance
, uint8_t fault
, sim_ftm_flt_sel_t select
);
1001 * @brief Gets the FlexTimer x fault y select setting.
1003 * This function gets the FlexTimer x fault y select setting.
1005 * @param baseAddr Base address for current SIM instance.
1006 * @param instance device instance.
1007 * @param fault fault y
1008 * @return select FlexTimer x fault y select setting
1010 sim_ftm_flt_sel_t
SIM_HAL_GetFtmFaultSelMode(uint32_t baseAddr
, uint8_t instance
, uint8_t fault
);
1013 #if FSL_FEATURE_SIM_OPT_HAS_TPM
1015 * @brief Sets the Timer/PWM x external clock pin select setting.
1017 * This function selects the source of the Timer/PWM x external clock pin select.
1019 * @param baseAddr Base address for current SIM instance.
1020 * @param instance device instance.
1021 * @param select Timer/PWM x external clock pin select
1022 * - 0: Timer/PWM x external clock driven by the TPM_CLKIN0 pin.
1023 * - 1: Timer/PWM x external clock driven by the TPM_CLKIN1 pin.
1025 void SIM_HAL_SetTpmExternalClkPinSelMode(uint32_t baseAddr
, uint8_t instance
, sim_tpm_clk_sel_t select
);
1028 * @brief Gets the Timer/PWM x external clock pin select setting.
1030 * This function gets the Timer/PWM x external clock pin select setting.
1032 * @param baseAddr Base address for current SIM instance.
1033 * @param instance device instance.
1034 * @return select Timer/PWM x external clock pin select setting
1036 sim_tpm_clk_sel_t
SIM_HAL_GetTpmExternalClkPinSelMode(uint32_t baseAddr
, uint8_t instance
);
1039 * @brief Sets the Timer/PWM x channel y input capture source select setting.
1041 * This function selects the Timer/PWM x channel y input capture source.
1043 * @param baseAddr Base address for current SIM instance.
1044 * @param instance device instance.
1045 * @param channel TPM channel y
1046 * @param select Timer/PWM x channel y input capture source
1047 * - 0: TPMx_CH0 signal
1050 void SIM_HAL_SetTpmChSrcMode(uint32_t baseAddr
, uint8_t instance
, uint8_t channel
, sim_tpm_ch_src_t select
);
1053 * @brief Gets the Timer/PWM x channel y input capture source select setting.
1055 * This function gets the Timer/PWM x channel y input capture source select setting.
1057 * @param baseAddr Base address for current SIM instance.
1058 * @param instance device instance.
1059 * @param channel Tpm channel y
1060 * @return select Timer/PWM x channel y input capture source select setting
1062 sim_tpm_ch_src_t
SIM_HAL_GetTpmChSrcMode(uint32_t baseAddr
, uint8_t instance
, uint8_t channel
);
1065 #if FSL_FEATURE_SIM_SDID_HAS_FAMILYID
1067 * @brief Gets the Kinetis Family ID in the System Device ID register (SIM_SDID).
1069 * This function gets the Kinetis Family ID in the System Device ID register.
1071 * @param baseAddr Base address for current SIM instance.
1072 * @return id Kinetis Family ID
1074 static inline uint32_t SIM_HAL_GetFamilyId(uint32_t baseAddr
)
1076 return BR_SIM_SDID_FAMILYID(baseAddr
);
1080 #if FSL_FEATURE_SIM_SDID_HAS_SUBFAMID
1082 * @brief Gets the Kinetis Sub-Family ID in the System Device ID register (SIM_SDID).
1084 * This function gets the Kinetis Sub-Family ID in System Device ID register.
1086 * @param baseAddr Base address for current SIM instance.
1087 * @return id Kinetis Sub-Family ID
1089 static inline uint32_t SIM_HAL_GetSubFamilyId(uint32_t baseAddr
)
1091 return BR_SIM_SDID_SUBFAMID(baseAddr
);
1095 #if FSL_FEATURE_SIM_SDID_HAS_SERIESID
1097 * @brief Gets the Kinetis SeriesID in the System Device ID register (SIM_SDID).
1099 * This function gets the Kinetis Series ID in System Device ID register.
1101 * @param baseAddr Base address for current SIM instance.
1102 * @return id Kinetis Series ID
1104 static inline uint32_t SIM_HAL_GetSeriesId(uint32_t baseAddr
)
1106 return BR_SIM_SDID_SERIESID(baseAddr
);
1110 #if FSL_FEATURE_SIM_SDID_HAS_FAMID
1112 * @brief Gets the Kinetis Fam ID in System Device ID register (SIM_SDID).
1114 * This function gets the Kinetis Fam ID in System Device ID register.
1116 * @param baseAddr Base address for current SIM instance.
1117 * @return id Kinetis Fam ID
1119 static inline uint32_t SIM_HAL_GetFamId(uint32_t baseAddr
)
1121 return BR_SIM_SDID_FAMID(baseAddr
);
1126 * @brief Gets the Kinetis Pincount ID in System Device ID register (SIM_SDID).
1128 * This function gets the Kinetis Pincount ID in System Device ID register.
1130 * @param baseAddr Base address for current SIM instance.
1131 * @return id Kinetis Pincount ID
1133 static inline uint32_t SIM_HAL_GetPinCntId(uint32_t baseAddr
)
1135 return BR_SIM_SDID_PINID(baseAddr
);
1139 * @brief Gets the Kinetis Revision ID in the System Device ID register (SIM_SDID).
1141 * This function gets the Kinetis Revision ID in System Device ID register.
1143 * @param baseAddr Base address for current SIM instance.
1144 * @return id Kinetis Revision ID
1146 static inline uint32_t SIM_HAL_GetRevId(uint32_t baseAddr
)
1148 return BR_SIM_SDID_REVID(baseAddr
);
1151 #if FSL_FEATURE_SIM_SDID_HAS_DIEID
1153 * @brief Gets the Kinetis Die ID in the System Device ID register (SIM_SDID).
1155 * This function gets the Kinetis Die ID in System Device ID register.
1157 * @param baseAddr Base address for current SIM instance.
1158 * @return id Kinetis Die ID
1160 static inline uint32_t SIM_HAL_GetDieId(uint32_t baseAddr
)
1162 return BR_SIM_SDID_DIEID(baseAddr
);
1166 #if FSL_FEATURE_SIM_SDID_HAS_SRAMSIZE
1168 * @brief Gets the Kinetis SRAM size in the System Device ID register (SIM_SDID).
1170 * This function gets the Kinetis SRAM Size in System Device ID register.
1172 * @param baseAddr Base address for current SIM instance.
1173 * @return id Kinetis SRAM Size
1175 static inline uint32_t SIM_HAL_GetSramSize(uint32_t baseAddr
)
1177 return BR_SIM_SDID_SRAMSIZE(baseAddr
);
1181 #if FSL_FEATURE_SIM_FCFG_HAS_NVMSIZE
1183 * @brief Gets the FlexNVM size in the Flash Configuration Register 1 (SIM_FCFG).
1185 * This function gets the FlexNVM size in the Flash Configuration Register 1.
1187 * @param baseAddr Base address for current SIM instance.
1188 * @return size FlexNVM Size
1190 static inline uint32_t SIM_HAL_GetFlexnvmSize(uint32_t baseAddr
)
1192 return BR_SIM_FCFG1_NVMSIZE(baseAddr
);
1197 * @brief Gets the program flash size in the Flash Configuration Register 1 (SIM_FCFG).
1199 * This function gets the program flash size in the Flash Configuration Register 1.
1201 * @param baseAddr Base address for current SIM instance.
1202 * @return size Program flash Size
1204 static inline uint32_t SIM_HAL_GetProgramFlashSize(uint32_t baseAddr
)
1206 return BR_SIM_FCFG1_PFSIZE(baseAddr
);
1209 #if FSL_FEATURE_SIM_FCFG_HAS_EESIZE
1211 * @brief Gets the EEProm size in the Flash Configuration Register 1 (SIM_FCFG).
1213 * This function gets the EEProm size in the Flash Configuration Register 1.
1215 * @param baseAddr Base address for current SIM instance.
1216 * @return size EEProm Size
1218 static inline uint32_t SIM_HAL_GetEepromSize(uint32_t baseAddr
)
1220 return BR_SIM_FCFG1_EESIZE(baseAddr
);
1224 #if FSL_FEATURE_SIM_FCFG_HAS_DEPART
1226 * @brief Gets the FlexNVM partition in the Flash Configuration Register 1 (SIM_FCFG).
1228 * This function gets the FlexNVM partition in the Flash Configuration Register 1
1230 * @param baseAddr Base address for current SIM instance.
1231 * @return setting FlexNVM partition setting
1233 static inline uint32_t SIM_HAL_GetFlexnvmPartition(uint32_t baseAddr
)
1235 return BR_SIM_FCFG1_DEPART(baseAddr
);
1239 #if FSL_FEATURE_SIM_FCFG_HAS_FLASHDOZE
1241 * @brief Sets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG).
1243 * This function sets the Flash Doze in the Flash Configuration Register 1.
1245 * @param baseAddr Base address for current SIM instance.
1246 * @param setting Flash Doze setting
1248 static inline void SIM_HAL_SetFlashDoze(uint32_t baseAddr
, uint32_t setting
)
1250 BW_SIM_FCFG1_FLASHDOZE(baseAddr
, setting
);
1254 * @brief Gets the Flash Doze in the Flash Configuration Register 1 (SIM_FCFG).
1256 * This function gets the Flash Doze in the Flash Configuration Register 1.
1258 * @param baseAddr Base address for current SIM instance.
1259 * @return setting Flash Doze setting
1261 static inline uint32_t SIM_HAL_GetFlashDoze(uint32_t baseAddr
)
1263 return BR_SIM_FCFG1_FLASHDOZE(baseAddr
);
1267 #if FSL_FEATURE_SIM_FCFG_HAS_FLASHDIS
1269 * @brief Sets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG).
1271 * This function sets the Flash disable setting in the Flash Configuration Register 1.
1273 * @param baseAddr Base address for current SIM instance.
1274 * @param disable Flash disable setting
1276 static inline void SIM_HAL_SetFlashDisableCmd(uint32_t baseAddr
, bool disable
)
1278 BW_SIM_FCFG1_FLASHDIS(baseAddr
, disable
);
1282 * @brief Gets the Flash disable setting in the Flash Configuration Register 1 (SIM_FCFG).
1284 * This function gets the Flash disable setting in the Flash Configuration Register 1.
1286 * @param baseAddr Base address for current SIM instance.
1287 * @return setting Flash disable setting
1289 static inline bool SIM_HAL_GetFlashDisableCmd(uint32_t baseAddr
)
1291 return (bool)BR_SIM_FCFG1_FLASHDIS(baseAddr
);
1295 #if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR0
1297 * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG).
1299 * This function gets the Flash maximum block 0 in Flash Configuration Register 2.
1301 * @param baseAddr Base address for current SIM instance.
1302 * @return address Flash maximum block 0 address
1304 static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock0(uint32_t baseAddr
)
1306 return BR_SIM_FCFG2_MAXADDR0(baseAddr
);
1310 #if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR1
1312 * @brief Gets the Flash maximum address block 1 in Flash Configuration Register 2.
1314 * This function gets the Flash maximum block 1 in Flash Configuration Register 1.
1316 * @param baseAddr Base address for current SIM instance.
1317 * @return address Flash maximum block 0 address
1319 static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock1(uint32_t baseAddr
)
1321 return BR_SIM_FCFG2_MAXADDR1(baseAddr
);
1325 #if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR01
1327 * @brief Gets the Flash maximum address block 0 in the Flash Configuration Register 1 (SIM_FCFG).
1329 * This function gets the Flash maximum block 0 in Flash Configuration Register 2.
1331 * @param baseAddr Base address for current SIM instance.
1332 * @return address Flash maximum block 0 address
1334 static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock01(uint32_t baseAddr
)
1336 return BR_SIM_FCFG2_MAXADDR01(baseAddr
);
1340 #if FSL_FEATURE_SIM_FCFG_HAS_MAXADDR23
1342 * @brief Gets the Flash maximum address block 1 in the Flash Configuration Register 2.
1344 * This function gets the Flash maximum block 1 in Flash Configuration Register 1.
1346 * @param baseAddr Base address for current SIM instance.
1347 * @return address Flash maximum block 0 address
1349 static inline uint32_t SIM_HAL_GetFlashMaxAddrBlock23(uint32_t baseAddr
)
1351 return BR_SIM_FCFG2_MAXADDR23(baseAddr
);
1355 #if FSL_FEATURE_SIM_FCFG_HAS_PFLSH
1357 * @brief Gets the program flash in the Flash Configuration Register 2.
1359 * This function gets the program flash maximum block 0 in Flash Configuration Register 1.
1361 * @param baseAddr Base address for current SIM instance.
1362 * @return status program flash status
1364 static inline uint32_t SIM_HAL_GetProgramFlashCmd(uint32_t baseAddr
)
1366 return BR_SIM_FCFG2_PFLSH(baseAddr
);
1372 #if defined(__cplusplus)
1374 #endif /* __cplusplus*/
1380 * Include the CPU-specific clock API header files.
1382 #if (defined(CPU_MK02FN128VFM10) || defined(CPU_MK02FN64VFM10) || defined(CPU_MK02FN128VLF10) || \
1383 defined(CPU_MK02FN64VLF10) || defined(CPU_MK02FN128VLH10) || defined(CPU_MK02FN64VLH10))
1385 #define K02F12810_SERIES
1387 #elif (defined(CPU_MK20DX128VMP5) || defined(CPU_MK20DN128VMP5) || defined(CPU_MK20DX64VMP5) || \
1388 defined(CPU_MK20DN64VMP5) || defined(CPU_MK20DX32VMP5) || defined(CPU_MK20DN32VMP5) || \
1389 defined(CPU_MK20DX128VLH5) || defined(CPU_MK20DN128VLH5) || defined(CPU_MK20DX64VLH5) || \
1390 defined(CPU_MK20DN64VLH5) || defined(CPU_MK20DX32VLH5) || defined(CPU_MK20DN32VLH5) || \
1391 defined(CPU_MK20DX128VFM5) || defined(CPU_MK20DN128VFM5) || defined(CPU_MK20DX64VFM5) || \
1392 defined(CPU_MK20DN64VFM5) || defined(CPU_MK20DX32VFM5) || defined(CPU_MK20DN32VFM5) || \
1393 defined(CPU_MK20DX128VFT5) || defined(CPU_MK20DN128VFT5) || defined(CPU_MK20DX64VFT5) || \
1394 defined(CPU_MK20DN64VFT5) || defined(CPU_MK20DX32VFT5) || defined(CPU_MK20DN32VFT5) || \
1395 defined(CPU_MK20DX128VLF5) || defined(CPU_MK20DN128VLF5) || defined(CPU_MK20DX64VLF5) || \
1396 defined(CPU_MK20DN64VLF5) || defined(CPU_MK20DX32VLF5) || defined(CPU_MK20DN32VLF5))
1398 #define K20D5_SERIES
1401 #elif (defined(CPU_MK22FN128VDC10) || defined(CPU_MK22FN128VLH10) || defined(CPU_MK22FN128VLL10) || \
1402 defined(CPU_MK22FN128VMP10))
1404 #define K22F12810_SERIES
1406 /* Clock System Level API header file */
1407 #include "MK22F12810/fsl_sim_hal_K22F12810.h"
1409 #elif (defined(CPU_MK22FN256VDC12) || defined(CPU_MK22FN256VLH12) || defined(CPU_MK22FN256VLL12) || \
1410 defined(CPU_MK22FN256VMP12))
1412 #define K22F25612_SERIES
1414 /* Clock System Level API header file */
1415 #include "MK22F25612/fsl_sim_hal_K22F25612.h"
1419 #elif (defined(CPU_MK22FN512VDC12) || defined(CPU_MK22FN512VLH12) || defined(CPU_MK22FN512VLL12))
1421 #define K22F51212_SERIES
1423 /* Clock System Level API header file */
1424 #include "MK22F51212/fsl_sim_hal_K22F51212.h"
1427 #elif (defined(CPU_MK24FN1M0VDC12) || defined(CPU_MK24FN1M0VLQ12))
1429 #define K24F12_SERIES
1431 /* Clock System Level API header file */
1432 #include "MK24F12/fsl_sim_hal_K24F12.h"
1434 #elif (defined(CPU_MK24FN256VDC12))
1436 #define K24F25612_SERIES
1439 #elif (defined(CPU_MK63FN1M0VLQ12) || defined(CPU_MK63FN1M0VMD12))
1441 #define K63F12_SERIES
1443 /* Clock System Level API header file */
1444 #include "MK63F12/fsl_sim_hal_K63F12.h"
1446 #elif (defined(CPU_MK64FX512VDC12) || defined(CPU_MK64FN1M0VDC12) || defined(CPU_MK64FX512VLL12) || \
1447 defined(CPU_MK64FN1M0VLL12) || defined(CPU_MK64FX512VLQ12) || defined(CPU_MK64FN1M0VLQ12) || \
1448 defined(CPU_MK64FX512VMD12) || defined(CPU_MK64FN1M0VMD12))
1450 #define K64F12_SERIES
1452 /* Clock System Level API header file */
1453 #include "MK64F12/fsl_sim_hal_K64F12.h"
1455 #elif (defined(CPU_MK65FN2M0CAC18) || defined(CPU_MK65FX1M0CAC18) || defined(CPU_MK65FN2M0VMI18) || \
1456 defined(CPU_MK65FX1M0VMI18))
1458 #define K65F18_SERIES
1461 #elif (defined(CPU_MK66FN2M0VLQ18) || defined(CPU_MK66FX1M0VLQ18) || defined(CPU_MK66FN2M0VMD18) || \
1462 defined(CPU_MK66FX1M0VMD18))
1464 #define K66F18_SERIES
1467 #elif (defined(CPU_MK70FN1M0VMF12) || defined(CPU_MK70FX512VMF12) || defined(CPU_MK70FN1M0VMF15) || \
1468 defined(CPU_MK70FX512VMF15) || defined(CPU_MK70FN1M0VMJ12) || defined(CPU_MK70FX512VMJ12) || \
1469 defined(CPU_MK70FN1M0VMJ15) || defined(CPU_MK70FX512VMJ15))
1471 #define K70F12_SERIES
1474 #elif (defined(CPU_MK70FN1M0VMF12) || defined(CPU_MK70FX512VMF12) || defined(CPU_MK70FN1M0VMF15) || \
1475 defined(CPU_MK70FX512VMF15) || defined(CPU_MK70FN1M0VMJ12) || defined(CPU_MK70FX512VMJ12) || \
1476 defined(CPU_MK70FN1M0VMJ15) || defined(CPU_MK70FX512VMJ15))
1478 #define K70F15_SERIES
1481 #elif (defined(CPU_MKL02Z32CAF4) || defined(CPU_MKL02Z8VFG4) || defined(CPU_MKL02Z16VFG4) || \
1482 defined(CPU_MKL02Z32VFG4) || defined(CPU_MKL02Z16VFK4) || defined(CPU_MKL02Z32VFK4) || \
1483 defined(CPU_MKL02Z16VFM4) || defined(CPU_MKL02Z32VFM4))
1485 #define KL02Z4_SERIES
1488 #elif (defined(CPU_MKL03Z32CAF4) || defined(CPU_MKL03Z8VFG4) || defined(CPU_MKL03Z16VFG4) || \
1489 defined(CPU_MKL03Z32VFG4) || defined(CPU_MKL03Z8VFK4) || defined(CPU_MKL03Z16VFK4) || \
1490 defined(CPU_MKL03Z32VFK4))
1492 #define KL03Z4_SERIES
1495 #elif (defined(CPU_MKL05Z8VFK4) || defined(CPU_MKL05Z16VFK4) || defined(CPU_MKL05Z32VFK4) || \
1496 defined(CPU_MKL05Z8VLC4) || defined(CPU_MKL05Z16VLC4) || defined(CPU_MKL05Z32VLC4) || \
1497 defined(CPU_MKL05Z8VFM4) || defined(CPU_MKL05Z16VFM4) || defined(CPU_MKL05Z32VFM4) || \
1498 defined(CPU_MKL05Z16VLF4) || defined(CPU_MKL05Z32VLF4))
1500 #define KL05Z4_SERIES
1503 #elif (defined(CPU_MKL13Z64VFM4) || defined(CPU_MKL13Z128VFM4) || defined(CPU_MKL13Z256VFM4) || \
1504 defined(CPU_MKL13Z64VFT4) || defined(CPU_MKL13Z128VFT4) || defined(CPU_MKL13Z256VFT4) || \
1505 defined(CPU_MKL13Z64VLH4) || defined(CPU_MKL13Z128VLH4) || defined(CPU_MKL13Z256VLH4) || \
1506 defined(CPU_MKL13Z64VMP4) || defined(CPU_MKL13Z128VMP4) || defined(CPU_MKL13Z256VMP4))
1508 #define KL13Z4_SERIES
1511 #elif (defined(CPU_MKL23Z64VFM4) || defined(CPU_MKL23Z128VFM4) || defined(CPU_MKL23Z256VFM4) || \
1512 defined(CPU_MKL23Z64VFT4) || defined(CPU_MKL23Z128VFT4) || defined(CPU_MKL23Z256VFT4) || \
1513 defined(CPU_MKL23Z64VLH4) || defined(CPU_MKL23Z128VLH4) || defined(CPU_MKL23Z256VLH4) || \
1514 defined(CPU_MKL23Z64VMP4) || defined(CPU_MKL23Z128VMP4) || defined(CPU_MKL23Z256VMP4))
1516 #define KL23Z4_SERIES
1519 #elif (defined(CPU_MKL25Z32VFM4) || defined(CPU_MKL25Z64VFM4) || defined(CPU_MKL25Z128VFM4) || \
1520 defined(CPU_MKL25Z32VFT4) || defined(CPU_MKL25Z64VFT4) || defined(CPU_MKL25Z128VFT4) || \
1521 defined(CPU_MKL25Z32VLH4) || defined(CPU_MKL25Z64VLH4) || defined(CPU_MKL25Z128VLH4) || \
1522 defined(CPU_MKL25Z32VLK4) || defined(CPU_MKL25Z64VLK4) || defined(CPU_MKL25Z128VLK4))
1524 #define KL25Z4_SERIES
1526 /* Clock System Level API header file */
1527 #include "MKL25Z4/fsl_sim_hal_KL25Z4.h"
1529 #elif (defined(CPU_MKL26Z32VFM4) || defined(CPU_MKL26Z64VFM4) || defined(CPU_MKL26Z128VFM4) || \
1530 defined(CPU_MKL26Z32VFT4) || defined(CPU_MKL26Z64VFT4) || defined(CPU_MKL26Z128VFT4) || \
1531 defined(CPU_MKL26Z32VLH4) || defined(CPU_MKL26Z64VLH4) || defined(CPU_MKL26Z128VLH4) || \
1532 defined(CPU_MKL26Z256VLH4) || defined(CPU_MKL26Z256VLK4) || defined(CPU_MKL26Z128VLL4) || \
1533 defined(CPU_MKL26Z256VLL4) || defined(CPU_MKL26Z128VMC4) || defined(CPU_MKL26Z256VMC4))
1535 #define KL26Z4_SERIES
1538 #elif (defined(CPU_MKL33Z128VLH4) || defined(CPU_MKL33Z256VLH4) || defined(CPU_MKL33Z128VMP4) || \
1539 defined(CPU_MKL33Z256VMP4))
1541 #define KL33Z4_SERIES
1544 #elif (defined(CPU_MKL43Z64VLH4) || defined(CPU_MKL43Z128VLH4) || defined(CPU_MKL43Z256VLH4) || \
1545 defined(CPU_MKL43Z64VMP4) || defined(CPU_MKL43Z128VMP4) || defined(CPU_MKL43Z256VMP4))
1547 #define KL43Z4_SERIES
1550 #elif (defined(CPU_MKL46Z128VLH4) || defined(CPU_MKL46Z256VLH4) || defined(CPU_MKL46Z128VLL4) || \
1551 defined(CPU_MKL46Z256VLL4) || defined(CPU_MKL46Z128VMC4) || defined(CPU_MKL46Z256VMC4))
1553 #define KL46Z4_SERIES
1556 #elif (defined(CPU_MKV30F128VFM10) || defined(CPU_MKV30F64VFM10) || defined(CPU_MKV30F128VLF10) || \
1557 defined(CPU_MKV30F64VLF10) || defined(CPU_MKV30F128VLH10) || defined(CPU_MKV30F64VLH10))
1559 #define KV30F12810_SERIES
1562 #elif (defined(CPU_MKV31F128VLH10) || defined(CPU_MKV31F128VLL10))
1564 #define KV31F12810_SERIES
1566 /* Clock System Level API header file */
1567 #include "MKV31F12810/fsl_sim_hal_KV31F12810.h"
1569 #elif (defined(CPU_MKV31F256VLH12) || defined(CPU_MKV31F256VLL12))
1571 #define KV31F25612_SERIES
1573 /* Clock System Level API header file */
1574 #include "MKV31F25612/fsl_sim_hal_KV31F25612.h"
1577 #elif (defined(CPU_MKV31F512VLH12) || defined(CPU_MKV31F512VLL12))
1579 #define KV31F51212_SERIES
1581 /* Clock System Level API header file */
1582 #include "MKV31F51212/fsl_sim_hal_KV31F51212.h"
1584 #elif (defined(CPU_MKV40F128VLH15) || defined(CPU_MKV40F128VLL15) || defined(CPU_MKV40F256VLH15) || \
1585 defined(CPU_MKV40F256VLL15) || defined(CPU_MKV40F64VLH15))
1587 #define KV40F15_SERIES
1590 #elif (defined(CPU_MKV43F128VLH15) || defined(CPU_MKV43F128VLL15) || defined(CPU_MKV43F64VLH15))
1592 #define KV43F15_SERIES
1595 #elif (defined(CPU_MKV44F128VLH15) || defined(CPU_MKV44F128VLL15) || defined(CPU_MKV44F64VLH15))
1597 #define KV44F15_SERIES
1600 #elif (defined(CPU_MKV45F128VLH15) || defined(CPU_MKV45F128VLL15) || defined(CPU_MKV45F256VLH15) || \
1601 defined(CPU_MKV45F256VLL15))
1603 #define KV45F15_SERIES
1606 #elif (defined(CPU_MKV46F128VLH15) || defined(CPU_MKV46F128VLL15) || defined(CPU_MKV46F256VLH15) || \
1607 defined(CPU_MKV46F256VLL15))
1609 #define KV46F15_SERIES
1613 #error "No valid CPU defined!"
1616 #endif /* __FSL_SIM_HAL_H__*/
1617 /*******************************************************************************
1619 ******************************************************************************/