fsl_dcdc.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. * Copyright 2017-2021, NXP
  3. * All rights reserved.
  4. *
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #ifndef __FSL_DCDC_H__
  9. #define __FSL_DCDC_H__
  10. #include "fsl_common.h"
  11. /*!
  12. * @addtogroup dcdc
  13. * @{
  14. */
  15. /*******************************************************************************
  16. * Definitions
  17. ******************************************************************************/
  18. /*! @brief DCDC driver version. */
  19. #define FSL_DCDC_DRIVER_VERSION (MAKE_VERSION(2, 3, 0)) /*!< Version 2.3.0. */
  20. /*!
  21. * @brief DCDC status flags.
  22. */
  23. enum _dcdc_status_flags_t
  24. {
  25. kDCDC_LockedOKStatus = (1U << 0U), /*!< Indicate DCDC status. 1'b1: DCDC already settled 1'b0: DCDC is settling. */
  26. };
  27. /*!
  28. * @brief The current bias of low power comparator.
  29. */
  30. typedef enum _dcdc_comparator_current_bias
  31. {
  32. kDCDC_ComparatorCurrentBias50nA = 0U, /*!< The current bias of low power comparator is 50nA. */
  33. kDCDC_ComparatorCurrentBias100nA = 1U, /*!< The current bias of low power comparator is 100nA. */
  34. kDCDC_ComparatorCurrentBias200nA = 2U, /*!< The current bias of low power comparator is 200nA. */
  35. kDCDC_ComparatorCurrentBias400nA = 3U, /*!< The current bias of low power comparator is 400nA. */
  36. } dcdc_comparator_current_bias_t;
  37. /*!
  38. * @brief The threshold of over current detection.
  39. */
  40. typedef enum _dcdc_over_current_threshold
  41. {
  42. kDCDC_OverCurrentThresholdAlt0 = 0U, /*!< 1A in the run mode, 0.25A in the power save mode. */
  43. kDCDC_OverCurrentThresholdAlt1 = 1U, /*!< 2A in the run mode, 0.25A in the power save mode. */
  44. kDCDC_OverCurrentThresholdAlt2 = 2U, /*!< 1A in the run mode, 0.2A in the power save mode. */
  45. kDCDC_OverCurrentThresholdAlt3 = 3U, /*!< 2A in the run mode, 0.2A in the power save mode. */
  46. } dcdc_over_current_threshold_t;
  47. /*!
  48. * @brief The threshold if peak current detection.
  49. */
  50. typedef enum _dcdc_peak_current_threshold
  51. {
  52. kDCDC_PeakCurrentThresholdAlt0 = 0U, /*!< 150mA peak current threshold. */
  53. kDCDC_PeakCurrentThresholdAlt1 = 1U, /*!< 250mA peak current threshold. */
  54. kDCDC_PeakCurrentThresholdAlt2 = 2U, /*!< 350mA peak current threshold. */
  55. kDCDC_PeakCurrentThresholdAlt3 = 3U, /*!< 450mA peak current threshold. */
  56. kDCDC_PeakCurrentThresholdAlt4 = 4U, /*!< 550mA peak current threshold. */
  57. kDCDC_PeakCurrentThresholdAlt5 = 5U, /*!< 650mA peak current threshold. */
  58. } dcdc_peak_current_threshold_t;
  59. /*!
  60. * @brief The period of counting the charging times in power save mode.
  61. */
  62. typedef enum _dcdc_count_charging_time_period
  63. {
  64. kDCDC_CountChargingTimePeriod8Cycle = 0U, /*!< Eight 32k cycle. */
  65. kDCDC_CountChargingTimePeriod16Cycle = 1U, /*!< Sixteen 32k cycle. */
  66. } dcdc_count_charging_time_period_t;
  67. /*!
  68. * @brief The threshold of the counting number of charging times
  69. */
  70. typedef enum _dcdc_count_charging_time_threshold
  71. {
  72. kDCDC_CountChargingTimeThreshold32 = 0U, /*!< 0x0: 32. */
  73. kDCDC_CountChargingTimeThreshold64 = 1U, /*!< 0x1: 64. */
  74. kDCDC_CountChargingTimeThreshold16 = 2U, /*!< 0x2: 16. */
  75. kDCDC_CountChargingTimeThreshold8 = 3U, /*!< 0x3: 8. */
  76. } dcdc_count_charging_time_threshold_t;
  77. /*!
  78. * @brief Oscillator clock option.
  79. */
  80. typedef enum _dcdc_clock_source
  81. {
  82. kDCDC_ClockAutoSwitch = 0U, /*!< Automatic clock switch from internal oscillator to external clock. */
  83. kDCDC_ClockInternalOsc = 1U, /*!< Use internal oscillator. */
  84. kDCDC_ClockExternalOsc = 2U, /*!< Use external 24M crystal oscillator. */
  85. } dcdc_clock_source_t;
  86. #if (defined(FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT) && (FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT == 2))
  87. /*!
  88. * @brief Voltage output option.
  89. */
  90. typedef enum _dcdc_voltage_output_sel
  91. {
  92. kDCDC_VoltageOutput1P8 = 0U, /*!< 1.8V output. */
  93. kDCDC_VoltageOutput1P0 = 1U, /*!< 1.0V output. */
  94. } dcdc_voltage_output_sel_t;
  95. #endif /* FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT */
  96. #if defined(FSL_FEATURE_DCDC_HAS_CTRL_REG) && FSL_FEATURE_DCDC_HAS_CTRL_REG
  97. /*!
  98. * @brief DCDC low power modes.
  99. */
  100. typedef enum _dcdc_low_power_mode
  101. {
  102. kDCDC_StandbyMode = 0U, /*!< Standby mode. */
  103. kDCDC_LowPowerMode = 1U, /*!< Low power mode. */
  104. kDCDC_GpcStandbyLowPowerMode = 2U, /*!< low power mode for GPC standby request. */
  105. } dcdc_low_power_mode_t;
  106. /*!
  107. * @brief DCDC control mode.
  108. */
  109. typedef enum _dcdc_control_mode
  110. {
  111. kDCDC_StaticControl = 0U, /*!< Static control. */
  112. kDCDC_SetPointControl = 1U, /*!< Controlled by GPC set points. */
  113. } dcdc_control_mode_t;
  114. /*!
  115. * @brief DCDC trim input mode.
  116. */
  117. typedef enum _dcdc_trim_input_mode
  118. {
  119. kDCDC_SampleTrimInput = 0U, /*!< Sample trim input. */
  120. kDCDC_HoldTrimInput = 1U, /*!< Hold trim input. */
  121. } dcdc_trim_input_mode_t;
  122. #if defined(DCDC_REG4_ENABLE_SP_MASK) && DCDC_REG4_ENABLE_SP_MASK
  123. /*!
  124. * @brief System setpoints enumeration.
  125. */
  126. enum _dcdc_setpoint_map
  127. {
  128. kDCDC_SetPoint0 = 1UL << 0UL, /*!< Set point 0. */
  129. kDCDC_SetPoint1 = 1UL << 1UL, /*!< Set point 1. */
  130. kDCDC_SetPoint2 = 1UL << 2UL, /*!< Set point 2. */
  131. kDCDC_SetPoint3 = 1UL << 3UL, /*!< Set point 3. */
  132. kDCDC_SetPoint4 = 1UL << 4UL, /*!< Set point 4. */
  133. kDCDC_SetPoint5 = 1UL << 5UL, /*!< Set point 5. */
  134. kDCDC_SetPoint6 = 1UL << 6UL, /*!< Set point 6. */
  135. kDCDC_SetPoint7 = 1UL << 7UL, /*!< Set point 7. */
  136. kDCDC_SetPoint8 = 1UL << 8UL, /*!< Set point 8. */
  137. kDCDC_SetPoint9 = 1UL << 9UL, /*!< Set point 9. */
  138. kDCDC_SetPoint10 = 1UL << 10UL, /*!< Set point 10. */
  139. kDCDC_SetPoint11 = 1UL << 11UL, /*!< Set point 11. */
  140. kDCDC_SetPoint12 = 1UL << 12UL, /*!< Set point 12. */
  141. kDCDC_SetPoint13 = 1UL << 13UL, /*!< Set point 13. */
  142. kDCDC_SetPoint14 = 1UL << 14UL, /*!< Set point 14. */
  143. kDCDC_SetPoint15 = 1UL << 15UL /*!< Set point 15. */
  144. };
  145. #endif /* DCDC_REG4_ENABLE_SP_MASK */
  146. /*!
  147. * @brief Configuration for DCDC.
  148. */
  149. typedef struct _dcdc_config
  150. {
  151. dcdc_control_mode_t controlMode; /*!< DCDC control mode. */
  152. dcdc_trim_input_mode_t trimInputMode; /*!< Hold trim input. */
  153. bool enableDcdcTimeout; /*!< Enable internal count for DCDC_OK timeout. */
  154. bool enableSwitchingConverterOutput; /*!< Enable the VDDIO switching converter output.*/
  155. } dcdc_config_t;
  156. #endif /* FSL_FEATURE_DCDC_HAS_CTRL_REGp */
  157. /*!
  158. * @brief Configuration for DCDC detection.
  159. */
  160. typedef struct _dcdc_detection_config
  161. {
  162. bool enableXtalokDetection; /*!< Enable xtalok detection circuit. */
  163. #if (defined(FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT) && (FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT == 2))
  164. bool powerDownOverVoltageVdd1P8Detection; /*!< Power down over-voltage detection comparator for VDD1P8. */
  165. bool powerDownOverVoltageVdd1P0Detection; /*!< Power down over-voltage detection comparator for VDD1P0. */
  166. #else
  167. bool powerDownOverVoltageDetection; /*!< Power down over-voltage detection comparator. */
  168. #endif /* FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT */
  169. bool powerDownLowVlotageDetection; /*!< Power down low-voltage detection comparator. */
  170. bool powerDownOverCurrentDetection; /*!< Power down over-current detection. */
  171. bool powerDownPeakCurrentDetection; /*!< Power down peak-current detection. */
  172. bool powerDownZeroCrossDetection; /*!< Power down the zero cross detection function for discontinuous conductor
  173. mode. */
  174. dcdc_over_current_threshold_t OverCurrentThreshold; /*!< The threshold of over current detection. */
  175. dcdc_peak_current_threshold_t PeakCurrentThreshold; /*!< The threshold of peak current detection. */
  176. } dcdc_detection_config_t;
  177. /*!
  178. * @brief Configuration for the loop control.
  179. */
  180. typedef struct _dcdc_loop_control_config
  181. {
  182. bool enableCommonHysteresis; /*!< Enable hysteresis in switching converter common mode analog comparators.
  183. This feature will improve transient supply ripple and efficiency. */
  184. bool enableCommonThresholdDetection; /*!< Increase the threshold detection for common mode analog comparator. */
  185. #if defined(FSL_FEATURE_DCDC_HAS_SWITCHING_CONVERTER_DIFFERENTIAL_MODE) && \
  186. FSL_FEATURE_DCDC_HAS_SWITCHING_CONVERTER_DIFFERENTIAL_MODE
  187. bool enableDifferentialHysteresis; /*!< Enable hysteresis in switching converter differential mode analog
  188. comparators. This feature will improve transient supply ripple and
  189. efficiency. */
  190. bool enableDifferentialThresholdDetection; /*!< Increase the threshold detection for differential mode analog
  191. comparators. */
  192. #endif /* FSL_FEATURE_DCDC_HAS_SWITCHING_CONVERTER_DIFFERENTIAL_MODE */
  193. bool enableInvertHysteresisSign; /*!< Invert the sign of the hysteresis in DC-DC analog comparators. */
  194. bool enableRCThresholdDetection; /*!< Increase the threshold detection for RC scale circuit. */
  195. uint32_t enableRCScaleCircuit; /*!< Available range is 0~7. Enable analog circuit of DC-DC converter to respond
  196. faster under transient load conditions. */
  197. uint32_t complementFeedForwardStep; /*!< Available range is 0~7. Two's complement feed forward step in duty cycle in
  198. the switching DC-DC converter. Each time this field makes a transition from
  199. 0x0, the loop filter of the DC-DC converter is stepped once by a value
  200. proportional to the change. This can be used to force a certain control loop
  201. behavior, such as improving response under known heavy load transients. */
  202. } dcdc_loop_control_config_t;
  203. /*!
  204. * @brief Configuration for DCDC low power.
  205. */
  206. typedef struct _dcdc_low_power_config
  207. {
  208. #if !(defined(FSL_FEATURE_DCDC_HAS_NO_REG0_EN_LP_OVERLOAD_SNS) && FSL_FEATURE_DCDC_HAS_NO_REG0_EN_LP_OVERLOAD_SNS)
  209. bool enableOverloadDetection; /*!< Enable the overload detection in power save mode, if current is larger than the
  210. overloading threshold (typical value is 50 mA), DCDC will switch to the run mode
  211. automatically. */
  212. #endif /* FSL_FEATURE_DCDC_HAS_NO_REG0_EN_LP_OVERLOAD_SNS */
  213. bool enableAdjustHystereticValue; /*!< Adjust hysteretic value in low power from 12.5mV to 25mV. */
  214. dcdc_count_charging_time_period_t
  215. countChargingTimePeriod; /*!< The period of counting the charging times in power save mode. */
  216. dcdc_count_charging_time_threshold_t
  217. countChargingTimeThreshold; /*!< the threshold of the counting number of charging times during
  218. the period that lp_overload_freq_sel sets in power save mode. */
  219. } dcdc_low_power_config_t;
  220. /*!
  221. * @brief Configuration for DCDC internal regulator.
  222. */
  223. typedef struct _dcdc_internal_regulator_config
  224. {
  225. bool enableLoadResistor; /*!< control the load resistor of the internal regulator of DCDC, the load resistor is
  226. connected as default "true", and need set to "false" to disconnect the load
  227. resistor. */
  228. uint32_t feedbackPoint; /*!< Available range is 0~3. Select the feedback point of the internal regulator. */
  229. } dcdc_internal_regulator_config_t;
  230. /*!
  231. * @brief Configuration for min power setting.
  232. */
  233. typedef struct _dcdc_min_power_config
  234. {
  235. bool enableUseHalfFreqForContinuous; /*!< Set DCDC clock to half frequency for the continuous mode. */
  236. } dcdc_min_power_config_t;
  237. #if defined(DCDC_REG4_ENABLE_SP_MASK) && DCDC_REG4_ENABLE_SP_MASK
  238. /*!
  239. * @brief DCDC configuration in set point mode.
  240. */
  241. typedef struct _dcdc_setpoint_config
  242. {
  243. uint32_t enableDCDCMap; /*!< The setpoint map that enable the DCDC module. Should be the OR'ed value of @ref
  244. _dcdc_setpoint_map. */
  245. uint32_t enableDigLogicMap; /*!< The setpoint map that enable the DCDC dig logic. Should be the OR'ed value of @ref
  246. _dcdc_setpoint_map. */
  247. uint32_t lowpowerMap; /*!< The setpoint map that enable the DCDC Low powermode. Should be the OR'ed value of @ref
  248. _dcdc_setpoint_map. */
  249. uint32_t standbyMap; /*!< The setpoint map that enable the DCDC standby mode. Should be the OR'ed value of @ref
  250. _dcdc_setpoint_map. */
  251. uint32_t standbyLowpowerMap; /*!< The setpoint map that enable the DCDC low power mode, when the related setpoint is
  252. in standby mode.
  253. @ref _dcdc_setpoint_map. */
  254. uint8_t *buckVDD1P8TargetVoltage; /*!< Point to the array that store the target voltage level of VDD1P8 in buck
  255. mode. Note that the pointed array must have 16 elements. */
  256. uint8_t *buckVDD1P0TargetVoltage; /*!< Point to the array that store the target voltage level of VDD1P0 in buck
  257. mode. Note that the pointed array must have 16 elements. */
  258. uint8_t *standbyVDD1P8TargetVoltage; /*!< Point to the array that store the target voltage level of VDD1P8 in
  259. standby mode. Note that the pointed array must have 16 elements. */
  260. uint8_t *standbyVDD1P0TargetVoltage; /*!< Point to the array that store the target voltage level of VDD1P0 in
  261. standby mode. Note that the pointed array must have 16 elements. */
  262. } dcdc_setpoint_config_t;
  263. #endif /* DCDC_REG4_ENABLE_SP_MASK */
  264. #if defined(__cplusplus)
  265. extern "C" {
  266. #endif
  267. /*******************************************************************************
  268. * API
  269. ******************************************************************************/
  270. /*!
  271. * @name Initialization and deinitialization
  272. * @{
  273. */
  274. #if defined(FSL_FEATURE_DCDC_HAS_CTRL_REG) && FSL_FEATURE_DCDC_HAS_CTRL_REG
  275. /*!
  276. * @brief Enable the access to DCDC registers.
  277. *
  278. * @param base DCDC peripheral base address.
  279. * @param config Pointer to the configuration structure.
  280. */
  281. void DCDC_Init(DCDC_Type *base, dcdc_config_t *config);
  282. #else
  283. /*!
  284. * @brief Enable the access to DCDC registers.
  285. *
  286. * @param base DCDC peripheral base address.
  287. */
  288. void DCDC_Init(DCDC_Type *base);
  289. #endif /* FSL_FEATURE_DCDC_HAS_CTRL_REG */
  290. /*!
  291. * @brief Disable the access to DCDC registers.
  292. *
  293. * @param base DCDC peripheral base address.
  294. */
  295. void DCDC_Deinit(DCDC_Type *base);
  296. #if defined(FSL_FEATURE_DCDC_HAS_CTRL_REG) && FSL_FEATURE_DCDC_HAS_CTRL_REG
  297. /*!
  298. * brief Get the default setting for DCDC user configuration structure.
  299. *
  300. * This function initializes the user configuration structure to a default value. The default values are:
  301. * code
  302. * config->controlMode = kDCDC_StaticControl;
  303. * config->trimInputMode = kDCDC_SampleTrimInput;
  304. * config->enableDcdcTimeout = false;
  305. * config->enableSwitchingConverterOutput = false;
  306. * endcode
  307. *
  308. * param config Pointer to configuration structure. See to "dcdc_config_t"
  309. */
  310. void DCDC_GetDefaultConfig(DCDC_Type *base, dcdc_config_t *config);
  311. #endif /* FSL_FEATURE_DCDC_HAS_CTRL_REGp */
  312. /* @} */
  313. /*!
  314. * @name Status
  315. * @{
  316. */
  317. /*!
  318. * @brief Get DCDC status flags.
  319. *
  320. * @param base peripheral base address.
  321. * @return Mask of asserted status flags. See to "_dcdc_status_flags_t".
  322. */
  323. uint32_t DCDC_GetstatusFlags(DCDC_Type *base);
  324. /* @} */
  325. /*!
  326. * @name Misc control
  327. * @{
  328. */
  329. #if defined(FSL_FEATURE_DCDC_HAS_CTRL_REG) && FSL_FEATURE_DCDC_HAS_CTRL_REG
  330. /*!
  331. * @brief Make DCDC enter into low power modes.
  332. *
  333. * @param base DCDC peripheral base address.
  334. * @param mode DCDC low power mode selection. See to "_dcdc_low_power_mode"
  335. */
  336. void DCDC_EnterLowPowerMode(DCDC_Type *base, dcdc_low_power_mode_t mode);
  337. #endif /* FSL_FEATURE_DCDC_HAS_CTRL_REG */
  338. /*!
  339. * @brief Enable the output range comparator.
  340. *
  341. * The output range comparator is disabled by default.
  342. *
  343. * @param base DCDC peripheral base address.
  344. * @param enable Enable the feature or not.
  345. */
  346. static inline void DCDC_EnableOutputRangeComparator(DCDC_Type *base, bool enable)
  347. {
  348. if (enable)
  349. {
  350. base->REG0 &= ~DCDC_REG0_PWD_CMP_OFFSET_MASK;
  351. }
  352. else
  353. {
  354. base->REG0 |= DCDC_REG0_PWD_CMP_OFFSET_MASK;
  355. }
  356. }
  357. /*!
  358. * @brief Configure the DCDC clock source.
  359. *
  360. * @param base DCDC peripheral base address.
  361. * @param clockSource Clock source for DCDC. See to "dcdc_clock_source_t".
  362. */
  363. void DCDC_SetClockSource(DCDC_Type *base, dcdc_clock_source_t clockSource);
  364. /*!
  365. * @brief Get the default setting for detection configuration.
  366. *
  367. * The default configuration are set according to responding registers' setting when powered on.
  368. * They are:
  369. * @code
  370. * config->enableXtalokDetection = false;
  371. * config->powerDownOverVoltageDetection = true;
  372. * config->powerDownLowVlotageDetection = false;
  373. * config->powerDownOverCurrentDetection = true;
  374. * config->powerDownPeakCurrentDetection = true;
  375. * config->powerDownZeroCrossDetection = true;
  376. * config->OverCurrentThreshold = kDCDC_OverCurrentThresholdAlt0;
  377. * config->PeakCurrentThreshold = kDCDC_PeakCurrentThresholdAlt0;
  378. * @endcode
  379. *
  380. * @param config Pointer to configuration structure. See to "dcdc_detection_config_t"
  381. */
  382. void DCDC_GetDefaultDetectionConfig(dcdc_detection_config_t *config);
  383. /*!
  384. * @brief Configure the DCDC detection.
  385. *
  386. * @param base DCDC peripheral base address.
  387. * @param config Pointer to configuration structure. See to "dcdc_detection_config_t"
  388. */
  389. void DCDC_SetDetectionConfig(DCDC_Type *base, const dcdc_detection_config_t *config);
  390. /*!
  391. * @brief Get the default setting for low power configuration.
  392. *
  393. * The default configuration are set according to responding registers' setting when powered on.
  394. * They are:
  395. * @code
  396. * config->enableOverloadDetection = true;
  397. * config->enableAdjustHystereticValue = false;
  398. * config->countChargingTimePeriod = kDCDC_CountChargingTimePeriod8Cycle;
  399. * config->countChargingTimeThreshold = kDCDC_CountChargingTimeThreshold32;
  400. * @endcode
  401. *
  402. * @param config Pointer to configuration structure. See to "dcdc_low_power_config_t"
  403. */
  404. void DCDC_GetDefaultLowPowerConfig(dcdc_low_power_config_t *config);
  405. /*!
  406. * @brief Configure the DCDC low power.
  407. *
  408. * @param base DCDC peripheral base address.
  409. * @param config Pointer to configuration structure. See to "dcdc_low_power_config_t".
  410. */
  411. void DCDC_SetLowPowerConfig(DCDC_Type *base, const dcdc_low_power_config_t *config);
  412. /*!
  413. * @brief Reset current alert signal. Alert signal is generate by peak current detection.
  414. *
  415. * @param base DCDC peripheral base address.
  416. * @param enable Switcher to reset signal. True means reset signal. False means don't reset signal.
  417. */
  418. void DCDC_ResetCurrentAlertSignal(DCDC_Type *base, bool enable);
  419. /*!
  420. * @brief Set the bangap trim value to trim bandgap voltage.
  421. *
  422. * @param base DCDC peripheral base address.
  423. * @param trimValue The bangap trim value. Available range is 0U-31U.
  424. */
  425. static inline void DCDC_SetBandgapVoltageTrimValue(DCDC_Type *base, uint32_t trimValue)
  426. {
  427. base->REG1 &= ~DCDC_REG1_VBG_TRIM_MASK;
  428. base->REG1 |= DCDC_REG1_VBG_TRIM(trimValue);
  429. }
  430. /*!
  431. * @brief Get the default setting for loop control configuration.
  432. *
  433. * The default configuration are set according to responding registers' setting when powered on.
  434. * They are:
  435. * @code
  436. * config->enableCommonHysteresis = false;
  437. * config->enableCommonThresholdDetection = false;
  438. * config->enableInvertHysteresisSign = false;
  439. * config->enableRCThresholdDetection = false;
  440. * config->enableRCScaleCircuit = 0U;
  441. * config->complementFeedForwardStep = 0U;
  442. * @endcode
  443. *
  444. * @param config Pointer to configuration structure. See to "dcdc_loop_control_config_t"
  445. */
  446. void DCDC_GetDefaultLoopControlConfig(dcdc_loop_control_config_t *config);
  447. /*!
  448. * @brief Configure the DCDC loop control.
  449. *
  450. * @param base DCDC peripheral base address.
  451. * @param config Pointer to configuration structure. See to "dcdc_loop_control_config_t".
  452. */
  453. void DCDC_SetLoopControlConfig(DCDC_Type *base, const dcdc_loop_control_config_t *config);
  454. /*!
  455. * @brief Configure for the min power.
  456. *
  457. * @param base DCDC peripheral base address.
  458. * @param config Pointer to configuration structure. See to "dcdc_min_power_config_t".
  459. */
  460. void DCDC_SetMinPowerConfig(DCDC_Type *base, const dcdc_min_power_config_t *config);
  461. /*!
  462. * @brief Set the current bias of low power comparator.
  463. *
  464. * @param base DCDC peripheral base address.
  465. * @param biasVaule The current bias of low power comparator. Refer to "dcdc_comparator_current_bias_t".
  466. */
  467. static inline void DCDC_SetLPComparatorBiasValue(DCDC_Type *base, dcdc_comparator_current_bias_t biasVaule)
  468. {
  469. base->REG1 &= ~DCDC_REG1_LP_CMP_ISRC_SEL_MASK;
  470. base->REG1 |= DCDC_REG1_LP_CMP_ISRC_SEL(biasVaule);
  471. }
  472. #if (defined(FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT) && (FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT == 2))
  473. /*!
  474. * @brief Lock VDD 1P0 target voltage.
  475. *
  476. * @param base DCDC peripheral base address.
  477. */
  478. static inline void DCDC_LockVdd1p0TargetVoltage(DCDC_Type *base)
  479. {
  480. base->REG3 |= DCDC_REG3_VDD1P0CTRL_DISABLE_STEP_MASK;
  481. }
  482. /*!
  483. * @brief Lock VDD 1P8 target voltage.
  484. *
  485. * @param base DCDC peripheral base address.
  486. */
  487. static inline void DCDC_LockVdd1p8TargetVoltage(DCDC_Type *base)
  488. {
  489. base->REG3 |= DCDC_REG3_VDD1P8CTRL_DISABLE_STEP_MASK;
  490. }
  491. /*!
  492. * @brief Adjust the target voltage of VDD_SOC in run mode and low power mode.
  493. * @deprecated Do not use this function. It has been superceded by @ref DCDC_AdjustRunTargetVoltage
  494. * and @ref DCDC_AdjustLowPowerTargetVoltage
  495. *
  496. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  497. * stabled.
  498. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  499. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  500. *
  501. * @param base DCDC peripheral base address.
  502. * @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
  503. * @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
  504. * @param sel sel DCDC target voltage output selection. See to "_dcdc_voltage_output_sel".
  505. */
  506. void DCDC_AdjustTargetVoltage(DCDC_Type *base, uint32_t VDDRun, uint32_t VDDStandby, dcdc_voltage_output_sel_t sel);
  507. /*!
  508. * @brief Adjust the target voltage of VDD_SOC in run mode.
  509. *
  510. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  511. * stabled.
  512. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  513. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  514. *
  515. * @param base DCDC peripheral base address.
  516. * @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
  517. * @param sel sel DCDC target voltage output selection. See to "_dcdc_voltage_output_sel".
  518. */
  519. void DCDC_AdjustRunTargetVoltage(DCDC_Type *base, uint32_t VDDRun, dcdc_voltage_output_sel_t sel);
  520. /*!
  521. * @brief Adjust the target voltage of VDD_SOC in low power mode.
  522. *
  523. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  524. * stabled.
  525. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  526. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  527. *
  528. * @param base DCDC peripheral base address.
  529. * @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
  530. * @param sel sel DCDC target voltage output selection. See to "_dcdc_voltage_output_sel".
  531. */
  532. void DCDC_AdjustLowPowerTargetVoltage(DCDC_Type *base, uint32_t VDDStandby, dcdc_voltage_output_sel_t sel);
  533. #else
  534. /*!
  535. * @brief Lock target voltage.
  536. *
  537. * @param base DCDC peripheral base address.
  538. */
  539. static inline void DCDC_LockTargetVoltage(DCDC_Type *base)
  540. {
  541. base->REG3 |= DCDC_REG3_DISABLE_STEP_MASK;
  542. }
  543. /*!
  544. * @brief Adjust the target voltage of VDD_SOC in run mode and low power mode.
  545. * @deprecated Do not use this function. It has been superceded by @ref DCDC_AdjustRunTargetVoltage
  546. * and @ref DCDC_AdjustLowPowerTargetVoltage
  547. *
  548. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  549. * stabled.
  550. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  551. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  552. *
  553. * @param base DCDC peripheral base address.
  554. * @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
  555. * @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
  556. */
  557. void DCDC_AdjustTargetVoltage(DCDC_Type *base, uint32_t VDDRun, uint32_t VDDStandby);
  558. /*!
  559. * @brief Adjust the target voltage of VDD_SOC in run mode.
  560. *
  561. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  562. * stabled.
  563. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  564. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  565. *
  566. * @param base DCDC peripheral base address.
  567. * @param VDDRun Target value in run mode. 25 mV each step from 0x00 to 0x1F. 00 is for 0.8V, 0x1F is for 1.575V.
  568. */
  569. void DCDC_AdjustRunTargetVoltage(DCDC_Type *base, uint32_t VDDRun);
  570. /*!
  571. * @brief Adjust the target voltage of VDD_SOC in low power mode.
  572. *
  573. * This function is to adjust the target voltage of DCDC output. Change them and finally wait until the output is
  574. * stabled.
  575. * Set the target value of run mode the same as low power mode before entering power save mode, because DCDC will switch
  576. * back to run mode if it detects the current loading is larger than about 50 mA(typical value).
  577. *
  578. * @param base DCDC peripheral base address.
  579. * @param VDDStandby Target value in low power mode. 25 mV each step from 0x00 to 0x4. 00 is for 0.9V, 0x4 is for 1.0V.
  580. */
  581. void DCDC_AdjustLowPowerTargetVoltage(DCDC_Type *base, uint32_t VDDStandby);
  582. #endif /* FSL_FEATURE_DCDC_VDD_OUTPUT_COUNT */
  583. /*!
  584. * @brief Configure the DCDC internal regulator.
  585. *
  586. * @param base DCDC peripheral base address.
  587. * @param config Pointer to configuration structure. See to "dcdc_internal_regulator_config_t".
  588. */
  589. void DCDC_SetInternalRegulatorConfig(DCDC_Type *base, const dcdc_internal_regulator_config_t *config);
  590. /*!
  591. * @brief Enable/Disable to improve the transition from heavy load to light load. It is valid while zero
  592. * cross detection is enabled. If ouput exceeds the threshold, DCDC would return CCM from DCM.
  593. *
  594. * @param base DCDC peripheral base address.
  595. * @param enable Enable the feature or not.
  596. */
  597. static inline void DCDC_EnableImproveTransition(DCDC_Type *base, bool enable)
  598. {
  599. if (enable)
  600. {
  601. base->REG2 |= DCDC_REG2_DCM_SET_CTRL_MASK;
  602. }
  603. else
  604. {
  605. base->REG2 &= ~DCDC_REG2_DCM_SET_CTRL_MASK;
  606. }
  607. }
  608. /* @} */
  609. #if defined(DCDC_REG4_ENABLE_SP_MASK) && DCDC_REG4_ENABLE_SP_MASK
  610. /*!
  611. * @name Setpoint mode APIs
  612. */
  613. /*!
  614. * @brief Init DCDC module when the control mode selected as setpoint mode.
  615. *
  616. * @note The function should be invoked in the initial step to config the
  617. * DCDC via setpoint control mode.
  618. *
  619. * @param base DCDC peripheral base address.
  620. * @param config The pointer to the structure @ref dcdc_setpoint_config_t.
  621. */
  622. void DCDC_SetPointInit(DCDC_Type *base, const dcdc_setpoint_config_t *config);
  623. /*!
  624. * @brief Disable DCDC module when the control mode selected as setpoint mode.
  625. *
  626. * @param base DCDC peripheral base address.
  627. * @param setpointMap. The map of the setpoint to disable the DCDC module.
  628. * Should be the OR'ed value of _dcdc_setpoint_map.
  629. */
  630. static inline void DCDC_SetPointDeinit(DCDC_Type *base, uint32_t setpointMap)
  631. {
  632. base->REG4 &= ~setpointMap;
  633. }
  634. /* @} */
  635. #endif /* DCDC_REG4_ENABLE_SP_MASK */
  636. /*!
  637. * @name Application guideline
  638. * @{
  639. */
  640. /*!
  641. * @brief Boot DCDC into DCM(discontinous conduction mode).
  642. *
  643. * pwd_zcd=0x0;
  644. * pwd_cmp_offset=0x0;
  645. * dcdc_loopctrl_en_rcscale= 0x5;
  646. * DCM_set_ctrl=1'b1;
  647. *
  648. * @param base DCDC peripheral base address.
  649. */
  650. void DCDC_BootIntoDCM(DCDC_Type *base);
  651. /*!
  652. * @brief Boot DCDC into CCM(continous conduction mode).
  653. *
  654. * pwd_zcd=0x1;
  655. * pwd_cmp_offset=0x0;
  656. * dcdc_loopctrl_en_rcscale=0x3;
  657. *
  658. * @param base DCDC peripheral base address.
  659. */
  660. void DCDC_BootIntoCCM(DCDC_Type *base);
  661. /* @} */
  662. #if defined(__cplusplus)
  663. }
  664. #endif
  665. /* @} */
  666. #endif /* __FSL_DCDC_H__ */