The PMIC driver provides API to control I2C based PMIC present in the board. It supports configuration of various features/modules in the PMIC. I2C controller is used to read/write to the PMIC registers. Refer to the corresponding PMIC datasheet for more details.
Features Supported
- Support enable/disable watchdog
- Watchdog in trigger and Q&A mode with interrupt/reset support upon failure
- GPIO configuration
- Thermal monitoring
- Voltage monitoring
SysConfig Features
- Note
- It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.
- Option to specify I2C address for the register pages
- Toggle watchdog functionality
- Watchdog mode selection
- Single/dual I2C communication mode selection
- Watchdog parameters configuration
- Warm reset option upon watchdog failure
Features NOT Supported
- ADC
- CRC check for read and write
Important Usage Guidelines
- Power cycle the board to restore the PMIC register configurations.
Example Usage
Include the below file to access the APIs
#include <board/pmic/pmic_i2c.h>
#define CONFIG_PMIC0 (0U)
#define MAIN_I2C (0U)
#define CONFIG_PMIC_NUM_INSTANCES (1U)
Pmic_CoreHandle_t gPmicCoreHandle[CONFIG_PMIC_NUM_INSTANCES];
Pmic_CoreCfg_t gPmicCoreCfg[CONFIG_PMIC_NUM_INSTANCES] =
{
{
.pmicDeviceType = PMIC_DEV_BURTON_TPS6522X,
.slaveAddr = 0x48,
.nvmSlaveAddr = 0x49,
.qaSlaveAddr = 0x12,
.i2c1Speed = PMIC_I2C_STANDARD_MODE,
.pFnPmicCommIoRead = &PMIC_i2cRead,
.pFnPmicCommIoWrite = &PMIC_i2cWrite,
.validParams = (PMIC_CFG_DEVICE_TYPE_VALID_SHIFT | PMIC_CFG_COMM_MODE_VALID_SHIFT | \
PMIC_CFG_SLAVEADDR_VALID_SHIFT | PMIC_CFG_QASLAVEADDR_VALID_SHIFT | \
PMIC_CFG_NVMSLAVEADDR_VALID_SHIFT | PMIC_CFG_COMM_IO_RD_VALID_SHIFT | \
PMIC_CFG_COMM_IO_WR_VALID_SHIFT | PMIC_CFG_I2C1_SPEED_VALID_SHIFT | \
PMIC_CFG_CRITSEC_START_VALID_SHIFT | PMIC_CFG_CRITSEC_STOP_VALID_SHIFT),
.instType = PMIC_MAIN_INST,
.commMode = PMIC_INTF_SINGLE_I2C,
},
};
{
{
.pmicCoreHandle = (Pmic_CoreHandle_t *)&gPmicCoreHandle[CONFIG_PMIC0],
},
};
{
{
},
};
uint32_t gPmicConfigNum = CONFIG_PMIC_NUM_INSTANCES;
Instance Open Example
gPmicHandle[CONFIG_PMIC0] =
NULL;
gPmicHandle[CONFIG_PMIC0] =
PMIC_open(CONFIG_PMIC0, &gPmicParams[CONFIG_PMIC0]);
if (!gPmicHandle[CONFIG_PMIC0])
{
}
Instance Close Example
GPIO pin configuration example
int32_t
status = PMIC_ST_SUCCESS;
Pmic_GpioCfg_t gpioCfg =
{
.pinDir = PMIC_GPIO_INPUT,
.pinFunc = PMIC_TPS6522X_GPIO_PINFUNC_GPIO6_NERR_MCU,
.pullCtrl = PMIC_GPIO_PULL_DOWN,
.deglitchEnable = PMIC_GPIO_DEGLITCH_ENABLE,
};
status = Pmic_gpioSetConfiguration(gPmicConfig[CONFIG_PMIC0].pmicCoreHandle, \
PMIC_TPS6522X_GPIO6_PIN, gpioCfg);
if (PMIC_ST_SUCCESS !=
status)
{
}
API
APIs for PMIC