Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

152 wiersze
4.5 KiB

  1. /*
  2. * Copyright (c) 2015, Freescale Semiconductor, Inc.
  3. * Copyright 2016-2019 NXP
  4. * All rights reserved.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef _FSL_SIM_H_
  9. #define _FSL_SIM_H_
  10. #include "fsl_common.h"
  11. /*! @addtogroup sim */
  12. /*! @{*/
  13. /*******************************************************************************
  14. * Definitions
  15. *******************************************************************************/
  16. /*! @name Driver version */
  17. /*@{*/
  18. #define FSL_SIM_DRIVER_VERSION (MAKE_VERSION(2, 1, 1))
  19. /*@}*/
  20. #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR)
  21. /*!@brief USB voltage regulator enable setting. */
  22. enum _sim_usb_volt_reg_enable_mode
  23. {
  24. kSIM_UsbVoltRegEnable = (int)SIM_SOPT1_USBREGEN_MASK, /*!< Enable voltage regulator. */
  25. kSIM_UsbVoltRegEnableInLowPower = SIM_SOPT1_USBVSTBY_MASK, /*!< Enable voltage regulator in VLPR/VLPW modes. */
  26. kSIM_UsbVoltRegEnableInStop = SIM_SOPT1_USBSSTBY_MASK, /*!< Enable voltage regulator in STOP/VLPS/LLS/VLLS modes. */
  27. kSIM_UsbVoltRegEnableInAllModes =
  28. (int)(SIM_SOPT1_USBREGEN_MASK | SIM_SOPT1_USBSSTBY_MASK |
  29. SIM_SOPT1_USBVSTBY_MASK) /*!< Enable voltage regulator in all power modes. */
  30. };
  31. #endif /* (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) */
  32. /*!@brief Unique ID. */
  33. typedef struct _sim_uid
  34. {
  35. #if defined(SIM_UIDH)
  36. uint32_t H; /*!< UIDH. */
  37. #endif
  38. #if (defined(FSL_FEATURE_SIM_HAS_UIDM) && FSL_FEATURE_SIM_HAS_UIDM)
  39. uint32_t M; /*!< SIM_UIDM. */
  40. #else
  41. uint32_t MH; /*!< UIDMH. */
  42. uint32_t ML; /*!< UIDML. */
  43. #endif /* FSL_FEATURE_SIM_HAS_UIDM */
  44. uint32_t L; /*!< UIDL. */
  45. } sim_uid_t;
  46. #if (defined(FSL_FEATURE_SIM_HAS_RF_MAC_ADDR) && FSL_FEATURE_SIM_HAS_RF_MAC_ADDR)
  47. /*! @brief RF Mac Address.*/
  48. typedef struct _sim_rf_addr
  49. {
  50. uint32_t rfAddrL; /*!< RFADDRL. */
  51. uint32_t rfAddrH; /*!< RFADDRH. */
  52. } sim_rf_addr_t;
  53. #endif /* FSL_FEATURE_SIM_HAS_RF_MAC_ADDR */
  54. /*!@brief Flash enable mode. */
  55. enum _sim_flash_mode
  56. {
  57. kSIM_FlashDisableInWait = SIM_FCFG1_FLASHDOZE_MASK, /*!< Disable flash in wait mode. */
  58. kSIM_FlashDisable = SIM_FCFG1_FLASHDIS_MASK /*!< Disable flash in normal mode. */
  59. };
  60. /*******************************************************************************
  61. * API
  62. ******************************************************************************/
  63. #if defined(__cplusplus)
  64. extern "C" {
  65. #endif /* __cplusplus*/
  66. #if (defined(FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR) && FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR)
  67. /*!
  68. * @brief Sets the USB voltage regulator setting.
  69. *
  70. * This function configures whether the USB voltage regulator is enabled in
  71. * normal RUN mode, STOP/VLPS/LLS/VLLS modes, and VLPR/VLPW modes. The configurations
  72. * are passed in as mask value of \ref _sim_usb_volt_reg_enable_mode. For example, to enable
  73. * USB voltage regulator in RUN/VLPR/VLPW modes and disable in STOP/VLPS/LLS/VLLS mode,
  74. * use:
  75. *
  76. * SIM_SetUsbVoltRegulatorEnableMode(kSIM_UsbVoltRegEnable | kSIM_UsbVoltRegEnableInLowPower);
  77. *
  78. * @param mask USB voltage regulator enable setting.
  79. */
  80. void SIM_SetUsbVoltRegulatorEnableMode(uint32_t mask);
  81. #endif /* FSL_FEATURE_SIM_OPT_HAS_USB_VOLTAGE_REGULATOR */
  82. /*!
  83. * @brief Gets the unique identification register value.
  84. *
  85. * @param uid Pointer to the structure to save the UID value.
  86. */
  87. void SIM_GetUniqueId(sim_uid_t *uid);
  88. /*!
  89. * @brief Sets the flash enable mode.
  90. *
  91. * @param mode The mode to set; see \ref _sim_flash_mode for mode details.
  92. */
  93. static inline void SIM_SetFlashMode(uint8_t mode)
  94. {
  95. SIM->FCFG1 = mode;
  96. }
  97. #if (defined(FSL_FEATURE_SIM_HAS_RF_MAC_ADDR) && FSL_FEATURE_SIM_HAS_RF_MAC_ADDR)
  98. /*!
  99. * @brief Gets the RF address register value.
  100. *
  101. * @param info Pointer to the structure to save the RF address value.
  102. */
  103. void SIM_GetRfAddr(sim_rf_addr_t *info);
  104. #endif /* FSL_FEATURE_SIM_HAS_RF_MAC_ADDR */
  105. #if (defined(FSL_FEATURE_SIM_MISC2_HAS_SYSTICK_CLK_EN) && FSL_FEATURE_SIM_MISC2_HAS_SYSTICK_CLK_EN)
  106. /*!
  107. * @brief Enable the Systick clock or not.
  108. *
  109. * The Systick clock is enabled by default.
  110. *
  111. * @param enable The switcher for Systick clock.
  112. */
  113. static inline void SIM_EnableSystickClock(bool enable)
  114. {
  115. if (enable)
  116. {
  117. SIM->MISC2 &= ~SIM_MISC2_SYSTICK_CLK_EN_MASK; /* Clear to enable. */
  118. }
  119. else
  120. {
  121. SIM->MISC2 |= SIM_MISC2_SYSTICK_CLK_EN_MASK; /* Set to disable. */
  122. }
  123. }
  124. #endif /* FSL_FEATURE_SIM_MISC2_HAS_SYSTICK_CLK_EN */
  125. #if defined(__cplusplus)
  126. }
  127. #endif /* __cplusplus*/
  128. /*! @}*/
  129. #endif /* _FSL_SIM_H_ */