1 /* 2 * Copyright 2016 Freescale Semiconductor, Inc. 3 * Copyright 2016 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 */ 8 9 #ifndef _FSL_PF3000_H_ 10 #define _FSL_PF3000_H_ 11 12 /******************************************************************************* 13 * Includes 14 ******************************************************************************/ 15 #include <stdint.h> 16 #include <stdbool.h> 17 18 /******************************************************************************* 19 * Definitions 20 ******************************************************************************/ 21 22 /*! @brief PF3000 Default I2C address. */ 23 #define PF3000_DEFAULT_I2C_ADDR 0x08U 24 25 /*! @brief Define the PMIC Register Memory Map of PF3000. */ 26 /*! Functional page. */ 27 #define PF3000_DEVICE_ID 0x00U 28 #define PF3000_SILICON_REV 0x03U 29 #define PF3000_FAB_ID 0x04U 30 #define PF3000_SW_INT_STAT0 0x05U 31 #define PF3000_SW_INT_MASK0 0x06U 32 #define PF3000_SW_INT_SENSE0 0x07U 33 #define PF3000_SW_INT_STAT1 0x08U 34 #define PF3000_SW_INT_MASK1 0x09U 35 #define PF3000_SW_INT_SENSE1 0x0AU 36 #define PF3000_SW_INT_STAT3 0x0EU 37 #define PF3000_SW_INT_MASK3 0x0FU 38 #define PF3000_SW_INT_SENSE3 0x10U 39 #define PF3000_SW_INT_STAT4 0x11U 40 #define PF3000_SW_INT_MASK4 0x12U 41 #define PF3000_SW_INT_SENSE4 0x13U 42 #define PF3000_COIN_CTRL 0x1AU 43 #define PF3000_PWR_CTRL 0x1BU 44 #define PF3000_MEMA 0x1CU 45 #define PF3000_MEMB 0x1DU 46 #define PF3000_MEMC 0x1EU 47 #define PF3000_MEMD 0x1FU 48 #define PF3000_SW1A_VOLT 0x20U 49 #define PF3000_SW1A_STBY 0x21U 50 #define PF3000_SW1A_OFF 0x22U 51 #define PF3000_SW1A_MODE 0x23U 52 #define PF3000_SW1A_CONF 0x24U 53 #define PF3000_SW1B_VOLT 0x2EU 54 #define PF3000_SW1B_STBY 0x2FU 55 #define PF3000_SW1B_OFF 0x30U 56 #define PF3000_SW1B_MODE 0x31U 57 #define PF3000_SW1B_CONF 0x32U 58 #define PF3000_SW2_VOLT 0x35U 59 #define PF3000_SW2_STBY 0x36U 60 #define PF3000_SW2_OFF 0x37U 61 #define PF3000_SW2_MODE 0x38U 62 #define PF3000_SW2_CONF 0x39U 63 #define PF3000_SW3_VOLT 0x3CU 64 #define PF3000_SW3_STBY 0x3DU 65 #define PF3000_SW3_OFF 0x3EU 66 #define PF3000_SW3_MODE 0x3FU 67 #define PF3000_SW3_CONF 0x40U 68 #define PF3000_SWBST_CTRL 0x66U 69 #define PF3000_LDOG_CTRL 0x69U 70 #define PF3000_VREFDDR_CTRL 0x6AU 71 #define PF3000_VSNVS_CTRL 0x6BU 72 #define PF3000_VLDO1_CTRL 0x6CU 73 #define PF3000_VLDO2_CTRL 0x6DU 74 #define PF3000_VCC_SD_CTRL 0x6EU 75 #define PF3000_V33_CTRL 0x6FU 76 #define PF3000_VLDO3_CTRL 0x70U 77 #define PF3000_VLDO4_CTRL 0x71U 78 #define PF3000_PAGE_REGISTER 0x7FU 79 80 /*! Extended page 1. (Only list some registers) */ 81 #define PF3000_OTP_SW1x_CONFIG 0xA2U 82 #define PF3000_OTP_SW2_VOLT 0xACU 83 84 /*! @brief PF3000 Operating Status definition. */ 85 typedef enum _pf3000_operating_status 86 { 87 kPF3000_OperatingStatusSystemOn = 0x0U, /* Indicates the state machine is in On Status. */ 88 kPF3000_OperatingStatusStandby = 0x1U, /* Indicates the state machine is in Standby Status. */ 89 kPF3000_OperatingStatusOff = 0x2U, /* Indicates the state machine is in Off Status. */ 90 kPF3000_OperatingStatusSleep = 0x3U, /* Indicates the state machine is in Sleep Status. */ 91 kPF3000_OperatingStatusCoinCell = 0x4U, /* Indicates the state machine is in Coin Cell Status. */ 92 } pf3000_operating_status_t; 93 94 /*! @brief PF3000 Sub-Module definition. */ 95 typedef enum _pf3000_module 96 { 97 kPF3000_ModuleSwitch1A = 0x0U, /* Switch1A Sub-Module Identifier. */ 98 kPF3000_ModuleSwitch1B = 0x1U, /* Switch1B Sub-Module Identifier. */ 99 kPF3000_ModuleSwitch2 = 0x2U, /* Switch2 Sub-Module Identifier. */ 100 kPF3000_ModuleSwitch3 = 0x3U, /* Switch3 Sub-Module Identifier. */ 101 kPF3000_ModuleSwitchBoost = 0x4U, /* SwitchBoost Sub-Module Identifier. */ 102 kPF3000_ModuleLdo1 = 0x5U, /* LDO1 Sub-Module Identifier. */ 103 kPF3000_ModuleLdo2 = 0x6U, /* LDO2 Sub-Module Identifier. */ 104 kPF3000_ModuleLdo3 = 0x7U, /* LDO3 Sub-Module Identifier. */ 105 kPF3000_ModuleLdo4 = 0x8U, /* LDO4 Sub-Module Identifier. */ 106 kPF3000_ModuleVcc_sd = 0x9U, /* VCC_SD Sub-Module Identifier. */ 107 kPF3000_ModuleV33 = 0xaU, /* V33 Sub-Module Identifier. */ 108 kPF3000_ModuleVsnvs = 0xbU, /* VSNVS Sub-Module Identifier. */ 109 kPF3000_ModuleVrefDdr = 0xcU, /* VREFDDR Sub-Module Identifier. */ 110 } pf3000_module_t; 111 112 /*! @brief PF3000 Interrupt Source definition. */ 113 enum _pf3000_interrupt_source 114 { 115 kPF3000_IntSrcPwrOn = 0x1U, /* Power on. */ 116 kPF3000_IntSrcLowVoltage = 0x2U, /* Low-voltage. */ 117 kPF3000_IntSrcTherm110 = 0x4U, /* Die temperature crosses 110C interrupt source. */ 118 kPF3000_IntSrcTherm120 = 0x8U, /* Die temperature crosses 120C interrupt source. */ 119 kPF3000_IntSrcTherm125 = 0x10U, /* Die temperature crosses 125C interrupt source. */ 120 kPF3000_IntSrcTherm130 = 0x20U, /* Die temperature crosses 130C interrupt source. */ 121 122 kPF3000_IntSrcSw1aCurrentLimit = 0x1U << 8U, /* Switch1A current limit interrupt source. */ 123 kPF3000_IntSrcSw1bCurrentLimit = 0x2U << 8U, /* Switch1B current limit interrupt source. */ 124 kPF3000_IntSrcSw2CurrentLimit = 0x8U << 8U, /* Switch2 current limit interrupt source. */ 125 kPF3000_IntSrcSw3CurrentLimit = 0x10U << 8U, /* Switch3 current limit interrupt source. */ 126 127 kPF3000_IntSrcSwBstCurrentLimit = 0x1U << 16U, /* Switch Boost current limit interrupt source. */ 128 kPF3000_IntSrcVpwrVoltageLimit = 0x4U << 16U, /* VPWR overvoltage interrupt source. */ 129 kPF3000_IntSrcOtpAutoFuseDone = 0x40U << 16U, /* OTP auto fuse blow interrupt source. */ 130 kPF3000_IntSrcOtpError = 0x80U << 16U, /* OTP error interrupt source. */ 131 132 kPF3000_IntSrcLdo1CurrentLimit = 0x1U << 24U, /* LDO1 current limit interrupt source. */ 133 kPF3000_IntSrcLdo2CurrentLimit = 0x2U << 24U, /* LDO2 current limit interrupt source. */ 134 kPF3000_IntSrcVcc_sdCurrentLimit = 0x4U << 24U, /* VCC_SD current limit interrupt source. */ 135 kPF3000_IntSrcV33CurrentLimit = 0x8U << 24U, /* V33 current limit interrupt source. */ 136 kPF3000_IntSrcLdo3CurrentLimit = 0x10U << 24U, /* LDO3 current limit interrupt source. */ 137 kPF3000_IntSrcLdo4CurrentLimit = 0x20U << 24U, /* LDO4 current limit interrupt source. */ 138 }; 139 140 /*! @brief PF3000 Off Mode definition. */ 141 typedef enum _pf3000_switch_off_mode 142 { 143 kPF3000_OffModeAfterTurnOff = 0x0U, /* OFF mode entered after a turn-off event. */ 144 kPF3000_SleepModeAfterTurnOff = 0x1U, /* Sleep mode entered after a turn-off event. */ 145 } pf3000_off_mode_t; 146 147 /*! @brief PF3000 Switch Mode Control . */ 148 typedef enum _pf3000_switch_mode 149 { 150 kPF3000_SwitchModeOffOff = 0x0U, /* Off in normal mode, Off in Standby mode. */ 151 kPF3000_SwitchModePwmOff = 0x1U, /* PWM in normal mode, Off in Standby mode. */ 152 kPF3000_SwitchModePfmOff = 0x3U, /* PFM in normal mode, Off in Standby mode. */ 153 kPF3000_SwitchModeApsOff = 0x4U, /* APS in normal mode, Off in Standby mode. */ 154 kPF3000_SwitchModePwmPwm = 0x5U, /* PWM in normal mode, PWM in Standby mode. */ 155 kPF3000_SwitchModePwmAps = 0x6U, /* PWM in normal mode, APS in Standby mode. */ 156 kPF3000_SwitchModeApsAps = 0x8U, /* APS in normal mode, APS in Standby mode. */ 157 kPF3000_SwitchModeApsPfm = 0xCU, /* APS in normal mode, PFM in Standby mode. */ 158 kPF3000_SwitchModePwmPfm = 0xDU, /* PWM in normal mode, PFM in Standby mode. */ 159 } pf3000_switch_mode_t; 160 161 /*! @brief PF3000 Switch DVS Speed Attribute definition. */ 162 typedef enum _pf3000_switch_dvs_speed 163 { 164 kPF3000_SwitchDvsSpeed_25mVPer2us = 0x0U, /* Switch DVS rate at 25mV/2us. */ 165 kPF3000_SwitchDvsSpeed_25mVPer4us = 0x1U, /* Switch DVS rate at 25mV/4us. */ 166 } pf3000_switch_dvs_speed_t; 167 168 /*! @brief PF3000 Switch Phase Clock definition. */ 169 typedef enum _pf3000_switch_phase_clock 170 { 171 kPF3000_SwitchPhaseClock_0 = 0x0U, /* Switch phase clock 0 degree. */ 172 kPF3000_SwitchPhaseClock_90 = 0x1U, /* Switch phase clock 90 degree. */ 173 kPF3000_SwitchPhaseClock_180 = 0x2U, /* Switch phase clock 180 degree. */ 174 kPF3000_SwitchPhaseClock_270 = 0x3U, /* Switch phase clock 270 degree. */ 175 } pf3000_switch_phase_clock_t; 176 177 /*! @brief PF3000 Switch Frequency definition. */ 178 typedef enum _pf3000_switch_frequency 179 { 180 kPF3000_SwitchFrequency_1M = 0x0U, /* Switch Frequency 1MHz. */ 181 kPF3000_SwitchFrequency_2M = 0x1U, /* Switch Frequency 2MHz. */ 182 kPF3000_SwitchFrequency_4M = 0x2U, /* Switch Frequency 4MHz. */ 183 } pf3000_switch_phase_frequency_t; 184 185 /*! @brief PF3000 Switch Current Limit Attribute definition. */ 186 typedef enum _pf3000_switch_current_limit 187 { 188 kPF3000_SwitchCurrentLimit_2A75 = 0x0U, /* Switch Current Limit: Typical current limit of 2.75A. */ 189 kPF3000_SwitchCurrentLimit_2A = 0x1U, /* Switch Current Limit: Typical current limit of 2A. */ 190 } pf3000_switch_current_limit_t; 191 192 /*! @brief PF3000 Switch Attribute Structure definition. */ 193 typedef struct _pf3000_switch_attribute 194 { 195 pf3000_off_mode_t offMode; /* Switch Off Mode Selection. */ 196 pf3000_switch_mode_t mode; /* Switch Mode Selection. */ 197 pf3000_switch_dvs_speed_t dvsSpeed; /* Switch DVS Speed Selection. */ 198 pf3000_switch_phase_clock_t phaseClock; /* Switch Phase Clock Selection. */ 199 pf3000_switch_phase_frequency_t frequency; /* Switch Phase Frequency Selection. */ 200 pf3000_switch_current_limit_t currentLimit; /* Switch Current Limit Selection. */ 201 } pf3000_switch_attribute_t; 202 203 /*! @brief PF3000 Switch Boost mode definition. */ 204 typedef enum _pf3000_switch_boost_mode 205 { 206 kPF3000_SwitchBoostModeOff = 0x0U, /* Switch Boost is in Off mode. */ 207 kPF3000_SwitchBoostModePfm = 0x1U, /* Switch Boost is in PFM mode. */ 208 kPF3000_SwitchBoostModeAuto = 0x2U, /* Switch Boost is in AUTO mode. */ 209 kPF3000_SwitchBoostModeAps = 0x3U, /* Switch Boost is in APS mode. */ 210 } pf3000_switch_boost_mode_t; 211 212 /*! @brief PF3000 Switch Boost Attribute Structure definition. */ 213 typedef struct _pf3000_switch_boost_attribute 214 { 215 pf3000_switch_boost_mode_t standbyMode; /* LDO Off Mode Selection. */ 216 pf3000_switch_boost_mode_t normalMode; /* LDO Standby Enable. */ 217 } pf3000_switch_boost_attribute_t; 218 219 /*! @brief PF3000 LDO standby mode enable. */ 220 typedef enum _pf3000_ldo_standby_on_off 221 { 222 kPF3000_LdoOnDuringStandby = 0x0U, /* LDO is ON during standby mode. */ 223 kPF3000_LdoOffDuringStandby = 0x1U, /* LDO is OFF during standby mode. */ 224 } pf3000_ldo_standby_on_off_t; 225 226 /*! @brief PF3000 LDO Attribute Structure definition. */ 227 typedef struct _pf3000_ldo_attribute 228 { 229 pf3000_off_mode_t offMode; /* LDO Off Mode Selection. */ 230 bool enableLowPower; /* LDO Low Power enable. */ 231 pf3000_ldo_standby_on_off_t standbyOnOff; /* LDO Standby Enable. */ 232 } pf3000_ldo_attribute_t; 233 234 /*! @brief PF3000 Coin Cell Charging Voltage Attribute definition. */ 235 typedef enum _pf3000_coin_cell_charging_voltage 236 { 237 kPF3000_CoinCellChargingVoltage_2V5 = 0x0U, /* Coin cell charger charging voltage 2.5V. */ 238 kPF3000_CoinCellChargingVoltage_2V7 = 0x1U, /* Coin cell charger charging voltage 2.7V. */ 239 kPF3000_CoinCellChargingVoltage_2V8 = 0x2U, /* Coin cell charger charging voltage 2.8V. */ 240 kPF3000_CoinCellChargingVoltage_2V9 = 0x3U, /* Coin cell charger charging voltage 2.9V. */ 241 kPF3000_CoinCellChargingVoltage_3V0 = 0x4U, /* Coin cell charger charging voltage 3.0V. */ 242 kPF3000_CoinCellChargingVoltage_3V1 = 0x5U, /* Coin cell charger charging voltage 3.1V. */ 243 kPF3000_CoinCellChargingVoltage_3V2 = 0x6U, /* Coin cell charger charging voltage 3.2V. */ 244 kPF3000_CoinCellChargingVoltage_3V3 = 0x7U, /* Coin cell charger charging voltage 3.3V. */ 245 } pf3000_coin_cell_charging_voltage_t; 246 247 /*! @brief PF3000 Coin Cell Attribute Structure definition. */ 248 typedef struct _pf3000_coin_cell_attribute 249 { 250 bool enableCoinCellCharger; /* Enable Coin Cell Charger. */ 251 pf3000_coin_cell_charging_voltage_t coinCellChargingVoltage; /* Vsnvs Coin Cell Charging Voltage Selection. */ 252 } pf3000_coin_cell_attribute_t; 253 254 /*! @brief PF3000 Standby Active Polarity definition. */ 255 typedef enum _pf3000_standby_polarity 256 { 257 kPF3000_StandbyPolActiveHigh = 0x0U, /* Standby pin input active high. */ 258 kPF3000_StandbyPolActiveLow = 0x1U, /* Standby pin input active low. */ 259 } pf3000_standby_polarity_t; 260 261 /*! @brief PF3000 Standby Delay Time definition. */ 262 typedef enum _pf3000_standby_delay 263 { 264 kPF3000_StandbyDelay_None = 0x0U, /* No additional delay. */ 265 kPF3000_StandbyDelay_1x32kHzCycle = 0x1U, /* 1 x 32kHz cycle additional delay. */ 266 kPF3000_StandbyDelay_2x32kHzCycle = 0x2U, /* 2 x 32kHz cycle additional delay. */ 267 kPF3000_StandbyDelay_3x32kHzCycle = 0x3U, /* 3 x 32kHz cycle additional delay. */ 268 } pf3000_standby_delay_t; 269 270 /*! @brief PF3000 Standby Pad Attribute Structure definition. */ 271 typedef struct _pf3000_standby_attribute 272 { 273 pf3000_standby_polarity_t standbyPolarity; /* Standby Active Polarity Selection. */ 274 pf3000_standby_delay_t standbyDelay; /* Select delay of Standby pin (after synchronization). */ 275 } pf3000_standby_attribute_t; 276 277 /*! @brief PF3000 Power On Pad Debounce Time definition. */ 278 typedef enum _pf3000_power_on_debounce 279 { 280 kPF3000_PowerOnDebounce_TurnOn0msFall31ms25Rise31ms25 = 0x0U, /* Power On Pad Debounce: 0ms turn on; 281 31.25ms falling edge; 31.25ms rising edge. */ 282 kPF3000_PowerOnDebounce_TurnOn31ms25msFall31ms25Rise31ms25 = 0x1U, /* Power On Pad Debounce: 31.25ms turn on; 283 31.25ms falling edge; 31.25ms rising edge. */ 284 kPF3000_PowerOnDebounce_TurnOn125msFall125ms25Rise31ms25 = 0x2U, /* Power On Pad Debounce: 125ms turn on; 285 125ms falling edge; 31.25ms rising edge. */ 286 kPF3000_PowerOnDebounce_TurnOn750msFall750ms25Rise31ms25 = 0x3U, /* Power On Pad Debounce: 750ms turn on; 287 750ms falling edge; 31.25ms rising edge. */ 288 } pf3000_power_on_debounce_t; 289 290 /*! @brief PF3000 PWRON Pad Attribute Structure definition. */ 291 typedef struct _pf3000_power_on_attribute 292 { 293 pf3000_power_on_debounce_t debounce; /* Power On Pad Debounce Time Selection. */ 294 bool longPressAllowOffMode; /* Allow OFF mode after PWRON held low for 4 seconds. */ 295 bool longPressRestart; /* Enables restart of system when PWRON held low for 4 seconds. */ 296 } pf3000_power_on_attribute_t; 297 298 /*! @brief PF3000 SW1A SW1B mode selection. */ 299 typedef enum _pf3000_switch1_mode 300 { 301 kPF3000_SW1SinglePhase = 0x0U, /* Switch 1 A/B Single Phase. */ 302 kPF3000_SW1IndependentMode = 0x3U, /* Switch 1A and 1B Independent mode */ 303 } pf3000_switch1_mode_t; 304 305 /*! @brief PF3000 SW2 voltage range. */ 306 typedef enum _pf3000_switch2_range 307 { 308 kPF3000_SW2LowVoltRange = 0x0U, /* Switch 1 A/B Single Phase. */ 309 kPF3000_SW2HighVoltRange = 0x1U, /* Switch 1A and 1B Independent mode */ 310 } pf3000_switch2_range_t; 311 312 /*! @brief PF3000 Handle definition. */ 313 typedef struct _pf3000_handle 314 { 315 /* Pointer to the user-defined I2C Send Data function. */ 316 bool (*I2C_SendFunc)( 317 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *txBuff, uint8_t txBuffSize); 318 /* Pointer to the user-defined I2C Receive Data function. */ 319 bool (*I2C_ReceiveFunc)( 320 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 321 /* The I2C Slave Address Read From OTP. */ 322 uint8_t slaveAddress; 323 /* VSD_VSEL. */ 324 bool vccsdVsel; 325 /* SW1A SW1B mode selection. */ 326 pf3000_switch1_mode_t switch1Mode; 327 /* SW2 voltage range. */ 328 pf3000_switch2_range_t switch2Range; 329 } pf3000_handle_t; 330 331 /*! @brief PF3000 Configuration Structure definition. */ 332 typedef struct _pf3000_config 333 { 334 /* Pointer to the user-defined I2C Send Data function. */ 335 bool (*I2C_SendFunc)( 336 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *txBuff, uint8_t txBuffSize); 337 /* Pointer to the user-defined I2C Receive Data function. */ 338 bool (*I2C_ReceiveFunc)( 339 uint8_t deviceAddress, uint32_t subAddress, uint8_t subAddressSize, uint8_t *rxBuff, uint8_t rxBuffSize); 340 341 /* The PF3000 I2C Slave Address. */ 342 uint8_t slaveAddress; 343 /* Short-circuit protection enable. */ 344 bool enableRegSCP; 345 /* VSD_VSEL. */ 346 bool vccsdVsel; 347 } pf3000_config_t; 348 349 /*! 350 * @addtogroup pf3000 351 * @{ 352 */ 353 354 /******************************************************************************* 355 * API 356 ******************************************************************************/ 357 #if defined(__cplusplus) 358 extern "C" { 359 #endif 360 361 /*! 362 * @name Initialization function 363 * @{ 364 */ 365 366 /*! 367 * @brief Gets the default configuration structure. 368 * 369 * This function initializes the PF3000 configuration structure to default values. The default 370 * values are as follows. 371 * @code 372 * pf3000Config->I2C_SendFunc = NULL; 373 * pf3000Config->I2C_ReceiveFunc = NULL; 374 * pf3000Config->slaveAddress = PF3000_DEFAULT_I2C_ADDR; 375 * pf3000Config->enableRegSCP = true; 376 * pf3000Config->vccsdVsel = 0U; 377 * @endcode 378 * @param config Pointer to the PF3000 configuration structure. 379 */ 380 void PF3000_GetDefaultConfig(pf3000_config_t *config); 381 382 /*! 383 * @brief Initializes a PF3000 instance. 384 * 385 * This function initializes the PF3000 module with user-defined settings. 386 * This example shows how to set up the pf3000_config_t parameters and how 387 * to call the PF3000_Init function by passing in these parameters. 388 * @code 389 * pf3000_config_t pf3000Config; 390 * pf3000Config.I2C_SendFunc = APP_I2C_SendFunc; 391 * pf3000Config.I2C_ReceiveFunc = APP_I2C_ReceiveFunc; 392 * pf3000Config.slaveAddress = PF3000_DEFAULT_I2C_ADDR; 393 * @endcode 394 * 395 * @param handle PF3000 Handle. 396 * @param config Pointer to the user-defined configuration structure. 397 */ 398 void PF3000_Init(pf3000_handle_t *handle, const pf3000_config_t *config); 399 /* @} */ 400 401 /*! 402 * @name Basic register access functions 403 * @{ 404 */ 405 406 /*! 407 * @brief Write the value to register of PF3000. 408 * 409 * @param handle Pointer to a valid PF3000 instance structure. 410 * @param reg variable store address of register. 411 * @param val variable store value which is written to PF3000. 412 * @return true if success or false if error. 413 */ 414 bool PF3000_WriteReg(pf3000_handle_t *handle, uint8_t reg, uint8_t val); 415 416 /*! 417 * @brief Read the value of register in PF3000. 418 * 419 * @param handle Pointer to a valid PF3000 instance structure. 420 * @param reg variable store address of register. 421 * @param val pointer store return value. 422 * @return true if success or false if error. 423 */ 424 bool PF3000_ReadReg(pf3000_handle_t *handle, uint8_t reg, uint8_t *val); 425 426 /*! 427 * @brief Modify some bits in the register in PF3000. 428 * @param handle Pointer to a valid PF3000 instance structure. 429 * @param reg variable store address of register. 430 * @param mask The mask code for the bits want to write. The bit you want to write should be 1. 431 * @param val Value needs to write into the register. 432 * @return true if success or false if error. 433 */ 434 bool PF3000_ModifyReg(pf3000_handle_t *handle, uint8_t reg, uint8_t mask, uint8_t val); 435 436 /*! 437 * @brief Dump the register content in PF3000. 438 * @param handle Pointer to a valid PF3000 instance structure. 439 * @param page The page of the register in. 440 * @param reg The address of the first register to dump. 441 * @param buffer The buffer to store the dumped content. 442 * @param size The count of registers to dump. 443 * @return true if success or false if error. 444 */ 445 bool PF3000_DumpReg(pf3000_handle_t *handle, uint8_t page, uint8_t reg, uint8_t *buffer, uint8_t size); 446 447 /* @} */ 448 449 /*! 450 * @name Interrupts 451 * @{ 452 */ 453 454 /*! 455 * @brief Enables PF3000 interrupts according to the provided interrupt source mask. 456 * 457 * This function enables the PF3000 interrupts according to the provided interrupt source. 458 * The interrupt source mask is a logical OR of enumeration members: 459 * see @ref _pf3000_interrupt_source all interrupt sources; 460 * 461 * @param handle Pointer to a valid PF3000 instance structure. 462 * @param source Logic ORed interrupt sources of selected interrupt category to enable. 463 */ 464 void PF3000_EnableInterrupts(pf3000_handle_t *handle, uint32_t source); 465 466 /*! 467 * @brief Disable PF3000 interrupts according to the provided interrupt source mask. 468 * 469 * This function disables the PF3000 interrupts according to the provided interrupt source. 470 * The interrupt source mask is a logical OR of enumeration members: 471 * see @ref _pf3000_interrupt_source all interrupt sources; 472 * 473 * @param handle Pointer to a valid PF3000 instance structure. 474 * @param source Logic ORed interrupt sources of selected interrupt category to disable. 475 */ 476 void PF3000_DisableInterrupts(pf3000_handle_t *handle, uint32_t source); 477 478 /*! 479 * @brief Get interrupt flags of selected interrupt category. 480 * 481 * This function gets all interrupt flags of selected interrupt. 482 * The flags are returned as the logical OR value of the corresponding interrupt source: 483 * see @ref _pf3000_interrupt_source all interrupt sources; 484 * 485 * @param handle Pointer to a valid PF3000 instance structure. 486 * @return status flags which are ORed by the enumerators in the corresponding interrupt source. 487 */ 488 uint32_t PF3000_GetInterruptStatus(pf3000_handle_t *handle); 489 490 /*! 491 * @brief Clear interrupt flags of selected interrupt category. 492 * 493 * This function clears all interrupt flags of selected interrupt. 494 * The interrupt source mask is a logical OR of enumeration members: 495 * see @ref _pf3000_interrupt_source all interrupt sources; 496 * 497 * @param handle Pointer to a valid PF3000 instance structure. 498 * @param source Logic ORed interrupt sources of selected interrupt category to clear. 499 */ 500 void PF3000_ClearInterruptStatus(pf3000_handle_t *handle, uint32_t source); 501 /* @} */ 502 503 /*! 504 * @name Regulator control functions 505 * @{ 506 */ 507 508 /*! 509 * @brief Enable/Disable the output of selected regulator. 510 * 511 * This function is used to enable/disable the output of selected regulator 512 * enumerated in @ref pf3000_module_t. 513 * For PF3000, LDO1, LDO2, LDO3, LDO4, VCC_SD, V33 and VREFDDE can be enabled or disabled. 514 * 515 * @param handle Pointer to a valid PF3000 instance structure. 516 * @param module Sub-modules in PF3000 device. 517 * @param enable Set true to enable regulator, set false to disable regulator. 518 */ 519 void PF3000_EnableRegulator(pf3000_handle_t *handle, pf3000_module_t module, bool enable); 520 /*! 521 * @brief Query the output state of selected regulator. 522 * 523 * This function is used to query the output state of selected regulator 524 * enumerated in @ref pf3000_module_t. 525 * For PF3000, LDO1, LDO2, LDO3, LDO4, VCC_SD, V33 and VREFDDE can queried. 526 * For other regulators, they are always enabled. 527 * 528 * @param handle Pointer to a valid PF3000 instance structure. 529 * @param module Sub-modules in PF3000 device. 530 * @return true if regulator is enabled, false if regulator is disabled. 531 */ 532 bool PF3000_IsRegulatorEnabled(pf3000_handle_t *handle, pf3000_module_t module); 533 /*! 534 * @brief Set the output voltage of selected regulator. 535 * 536 * This function is used to set the output voltage of selected regulator 537 * enumerated in @ref pf3000_module_t under selected operating status 538 * enumerated in @ref pf3000_operating_status_t. The output state of 539 * the regulators will change automatically once the operating status 540 * changed. 541 * Note that, voltage of VSNVS and VREFDDR can't be set. 542 * VSNVS is fixed in 3.0V, while VREFDDR is at one half the input voltage. 543 * And 544 * 545 * @param handle Pointer to a valid PF3000 instance structure. 546 * @param module Sub-modules in PF3000 device. 547 * @param status The operating status of PF3000 to set. 548 * Note that, status is only useful for SW1A, SW1B, SW2 and SW3. 549 * For other regulator, status is not used. 550 * @param voltage The output voltage in uV to set. 551 */ 552 void PF3000_SetRegulatorOutputVoltage(pf3000_handle_t *handle, 553 pf3000_module_t module, 554 pf3000_operating_status_t status, 555 uint32_t voltage); 556 /*! 557 * @brief Query the output voltage of selected regulator. 558 * 559 * This function is used to query the output voltage of selected regulator 560 * enumerated in @ref pf3000_module_t under selected operating status 561 * enumerated in @ref pf3000_operating_status_t. 562 * Note that, voltage of VREFDDR can't be set. It's one half the input voltage. 563 * 564 * @param handle Pointer to a valid PF3000 instance structure. 565 * @param module Sub-modules in PF3000 device. 566 * @param status The operating status of PF3000 to set. 567 * Note that, status is only useful for SW1A, SW1B, SW2 and SW3. 568 * For other regulator, status is not used. 569 * @return voltage The output voltage in uV of selected regulator. 570 */ 571 uint32_t PF3000_GetRegulatorOutputVoltage(pf3000_handle_t *handle, 572 pf3000_module_t module, 573 pf3000_operating_status_t status); 574 /*! 575 * @brief Set the attributes of selected Buck Switch. 576 * 577 * This function is used to set the attributes of Buck Switch regulator. 578 * All the available attributes for Switch are listed in 579 * @ref pf3000_switch_attribute_t. 580 * 581 * @param handle Pointer to a valid PF3000 instance structure. 582 * @param module Sub-modules in PF3000 device. 583 * @param attribute Pointer to the Switch Attribute structure to set. 584 */ 585 void PF3000_SetSwitchAttribute(pf3000_handle_t *handle, 586 pf3000_module_t module, 587 const pf3000_switch_attribute_t *attribute); 588 /*! 589 * @brief Set the attributes of Switch Boost. 590 * 591 * This function is used to set the attributes of Switch Boost regulator. 592 * All the available attributes for Switch Boost are listed in 593 * @ref pf3000_switch_boost_attribute_t. 594 * 595 * @param handle Pointer to a valid PF3000 instance structure. 596 * @param attribute Pointer to the Switch Boost Attribute structure to set. 597 */ 598 void PF3000_SetSwitchBoostAttribute(pf3000_handle_t *handle, const pf3000_switch_boost_attribute_t *attribute); 599 /*! 600 * @brief Set the attributes of selected LDO. 601 * 602 * This function is used to set the attributes of LDO regulator. 603 * All the available attributes for LDO regulator are listed in 604 * @ref pf3000_ldo_attribute_t. 605 * 606 * @param handle Pointer to a valid PF3000 instance structure. 607 * @param module Sub-modules in PF3000 device. 608 * @param attribute Pointer to the LDO Attribute structure to set. 609 */ 610 void PF3000_SetLdoAttribute(pf3000_handle_t *handle, pf3000_module_t module, const pf3000_ldo_attribute_t *attribute); 611 /*! 612 * @brief Set the attributes of Coin Cell. 613 * 614 * This function is used to set the attributes of Coin Cell. 615 * All the available attributes for Coin Cell are listed in 616 * @ref pf3000_coin_cell_attribute_t. 617 * 618 * @param handle Pointer to a valid PF3000 instance structure. 619 * @param attribute Pointer to the Coin Cell Attribute structure to set. 620 */ 621 void PF3000_SetCoinCellAttribute(pf3000_handle_t *handle, const pf3000_coin_cell_attribute_t *attribute); 622 /*! 623 * @brief Set the attributes of Standby Pad. 624 * 625 * This function is used to set the attributes of Standby Pad. 626 * All the available attributes for Standby Pad are listed in 627 * @ref pf3000_standby_attribute_t. 628 * 629 * @param handle Pointer to a valid PF3000 instance structure. 630 * @param attribute Pointer to the Standby Pad Attribute structure to set. 631 */ 632 void PF3000_SetStandbyPadAttribute(pf3000_handle_t *handle, const pf3000_standby_attribute_t *attribute); 633 /*! 634 * @brief Set the attributes of PowerOn Pad. 635 * 636 * This function is used to set the attributes of PowerOn Pad. 637 * All the available attributes for PowerOn Pad are listed in 638 * @ref pf3000_power_on_attribute_t. 639 * 640 * @param handle Pointer to a valid PF3000 instance structure. 641 * @param attribute Pointer to the PowerOn Pad Attribute structure to set. 642 */ 643 void PF3000_SetPwrOnPadAttibute(pf3000_handle_t *handle, const pf3000_power_on_attribute_t *attribute); 644 /* @} */ 645 646 #if defined(__cplusplus) 647 } 648 #endif 649 650 /*! @} */ 651 652 #endif /* _FSL_PF3000_H_ */ 653 654 /******************************************************************************* 655 * EOF 656 ******************************************************************************/ 657