HPM SDK
HPMicro Software Development Kit
hpm_pcfg_drv.h File Reference
#include "hpm_common.h"
#include "hpm_pcfg_regs.h"

Go to the source code of this file.

Data Structures

struct  pcfg_irc24m_config_t
 

Macros

#define PCFG_CLOCK_GATE_MODE_ALWAYS_ON   (0x3UL)
 
#define PCFG_CLOCK_GATE_MODE_ALWAYS_OFF   (0x2UL)
 
#define PCFG_PERIPH_KEEP_CLOCK_ON(p)   (PCFG_CLOCK_GATE_MODE_ALWAYS_ON << (p))
 
#define PCFG_PERIPH_KEEP_CLOCK_OFF(p)   (PCFG_CLOCK_GATE_MODE_ALWAYS_OFF << (p))
 
#define PCFG_CLOCK_GATE_CONTROL_MASK(module, mode)    ((uint32_t) (mode) << ((module) << 1))
 

Enumerations

enum  pcfg_irc24m_reference_t {
  pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 , pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 ,
  pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 , pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 ,
  pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 , pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 ,
  pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1 , pcfg_irc24m_reference_32k = 0 , pcfg_irc24m_reference_24m_xtal = 1
}
 
enum  pcfg_dcdc_lp_current_limit_t {
  pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 , pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 ,
  pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 , pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 ,
  pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 , pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 ,
  pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1 , pcfg_dcdc_lp_current_limit_250ma = 0 , pcfg_dcdc_lp_current_limit_200ma = 1
}
 
enum  pcfg_dcdc_current_hys_t {
  pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 , pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 ,
  pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 , pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 ,
  pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 , pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 ,
  pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1 , pcfg_dcdc_current_hys_12_5mv = 0 , pcfg_dcdc_current_hys_25mv = 1
}
 
enum  pcfg_dcdc_mode_t {
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7 ,
  pcfg_dcdc_mode_off = 0 , pcfg_dcdc_mode_basic = 1 , pcfg_dcdc_mode_general = 3 , pcfg_dcdc_mode_expert = 7
}
 
enum  pcfg_pmc_periph_t {
  pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 , pcfg_pmc_periph_wdog = 12 ,
  pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 ,
  pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_fuse = 0 , pcfg_pmc_periph_ram = 2 ,
  pcfg_pmc_periph_vad = 4 , pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 ,
  pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_debug = 16 , pcfg_pmc_periph_fuse = 0 ,
  pcfg_pmc_periph_ram = 2 , pcfg_pmc_periph_vad = 4 , pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 ,
  pcfg_pmc_periph_timer = 10 , pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_debug = 16 ,
  pcfg_pmc_periph_fuse = 0 , pcfg_pmc_periph_ram = 2 , pcfg_pmc_periph_vad = 4 , pcfg_pmc_periph_gpio = 6 ,
  pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 , pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14 ,
  pcfg_pmc_periph_debug = 16 , pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 ,
  pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_vad = 16 , pcfg_pmc_periph_pmic_mem = 18 ,
  pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 , pcfg_pmc_periph_wdog = 12 ,
  pcfg_pmc_periph_uart = 14 , pcfg_pmc_periph_gpio = 6 , pcfg_pmc_periph_ioc = 8 , pcfg_pmc_periph_timer = 10 ,
  pcfg_pmc_periph_wdog = 12 , pcfg_pmc_periph_uart = 14
}
 
enum  pcfg_wakeup_src_t {
  pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_puart = (1 << 7) , pcfg_wakeup_src_ptimer = (1 << 8) , pcfg_wakeup_src_pwdg = (1 << 9) ,
  pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_wkup = (1 << 31) , pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_puart = (1 << 7) ,
  pcfg_wakeup_src_ptimer = (1 << 8) , pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_wkup = (1 << 31) ,
  pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_otp = (1 << 4) , pcfg_wakeup_src_puart = (1 << 7) , pcfg_wakeup_src_ptimer = (1 << 8) ,
  pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_monitor = (1 << 11) , pcfg_wakeup_src_psecurity = (1 << 12) ,
  pcfg_wakeup_src_bsecurity = (1 << 16) , pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_wbutn = (1 << 18) , pcfg_wakeup_src_rtc = (1 << 19) ,
  pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_otp = (1 << 4) , pcfg_wakeup_src_puart = (1 << 7) , pcfg_wakeup_src_ptimer = (1 << 8) ,
  pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_monitor = (1 << 11) , pcfg_wakeup_src_psecurity = (1 << 12) ,
  pcfg_wakeup_src_bsecurity = (1 << 16) , pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_wbutn = (1 << 18) , pcfg_wakeup_src_rtc = (1 << 19) ,
  pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_otp = (1 << 4) , pcfg_wakeup_src_puart = (1 << 7) , pcfg_wakeup_src_ptimer = (1 << 8) ,
  pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_monitor = (1 << 11) , pcfg_wakeup_src_psecurity = (1 << 12) ,
  pcfg_wakeup_src_bsecurity = (1 << 16) , pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_wbutn = (1 << 18) , pcfg_wakeup_src_rtc = (1 << 19) ,
  pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_vad = (1 << 5) , pcfg_wakeup_src_vad_wake = (1 << 6) , pcfg_wakeup_src_puart = (1 << 7) ,
  pcfg_wakeup_src_ptimer = (1 << 8) , pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_bsecurity = (1 << 16) ,
  pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_rtc = (1 << 19) , pcfg_wakeup_src_soc = (1 << 0) , pcfg_wakeup_src_puart = (1 << 7) ,
  pcfg_wakeup_src_ptimer = (1 << 8) , pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) , pcfg_wakeup_src_bsecurity = (1 << 16) ,
  pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_rtc = (1 << 19) , pcfg_wakeup_src_wkup = (1 << 31) , pcfg_wakeup_src_soc = (1 << 0) ,
  pcfg_wakeup_src_puart = (1 << 7) , pcfg_wakeup_src_ptimer = (1 << 8) , pcfg_wakeup_src_pwdg = (1 << 9) , pcfg_wakeup_src_pgpio = (1 << 10) ,
  pcfg_wakeup_src_bsecurity = (1 << 16) , pcfg_wakeup_src_bgpio = (1 << 17) , pcfg_wakeup_src_rtc = (1 << 19) , pcfg_wakeup_src_wkup = (1 << 31)
}
 
enum  { status_pcfg_ldo_out_of_range = MAKE_STATUS(status_group_pcfg, 1) }
 

Functions

static bool pcfg_bandgap_is_trimmed (PCFG_Type *ptr)
 check if bandgap is trimmed or not More...
 
static void pcfg_bandgap_reload_trim (PCFG_Type *ptr)
 bandgap reload trim value More...
 
static void pcfg_ldo2p5_turn_off (PCFG_Type *ptr)
 turn off LDO2P5 More...
 
static void pcfg_ldo2p5_turn_on (PCFG_Type *ptr)
 turn on LDO 2.5V More...
 
static bool pcfg_ldo2p5_is_stable (PCFG_Type *ptr)
 check if LDO 2.5V is stable More...
 
static bool pcfg_dcdc_is_stable (PCFG_Type *ptr)
 
static void pcfg_dcdc_set_mode (PCFG_Type *ptr, uint8_t mode)
 
static void pcfg_dcdc_set_lp_current_limit (PCFG_Type *ptr, pcfg_dcdc_lp_current_limit_t limit)
 set low power current limit More...
 
static bool pcfg_dcdc_is_power_loss (PCFG_Type *ptr)
 check if power loss flag is set More...
 
static void pcfg_dcdc_disable_over_voltage_prot (PCFG_Type *ptr)
 disable over voltage protection More...
 
static void pcfg_dcdc_ensable_over_voltage_prot (PCFG_Type *ptr)
 enable over voltage protection More...
 
static bool pcfg_dcdc_is_over_voltage (PCFG_Type *ptr)
 checkover voltage flag More...
 
static void pcfg_dcdc_disable_measure_current (PCFG_Type *ptr)
 disable current measurement More...
 
static void pcfg_dcdc_enable_measure_current (PCFG_Type *ptr)
 enable current measurement More...
 
static bool pcfg_dcdc_is_measure_current_valid (PCFG_Type *ptr)
 check if measured current is valid More...
 
static uint32_t pcfg_dcdc_get_start_time_in_cycle (PCFG_Type *ptr)
 get DCDC start time in number of 24MHz clock cycles More...
 
static uint32_t pcfg_dcdc_get_resume_time_in_cycle (PCFG_Type *ptr)
 get DCDC resume time in number of 24MHz clock cycles More...
 
static void pcfg_dcdc_set_start_time_in_cycle (PCFG_Type *ptr, uint32_t cycles)
 set DCDC start time in 24MHz clock cycles More...
 
static void pcfg_dcdc_set_resume_time_in_cycle (PCFG_Type *ptr, uint32_t cycles)
 set DCDC resuem time in 24MHz clock cycles More...
 
static void pcfg_dcdc_set_current_hys_range (PCFG_Type *ptr, pcfg_dcdc_current_hys_t range)
 set dcdc current hysteres range More...
 
static void pcfg_disable_power_trap (PCFG_Type *ptr)
 disable power trap More...
 
static void pcfg_enable_power_trap (PCFG_Type *ptr)
 enable power trap More...
 
static bool pcfg_is_power_trap_triggered (PCFG_Type *ptr)
 check if power trap is triggered More...
 
static void pcfg_clear_power_trap_trigger_flag (PCFG_Type *ptr)
 clear power trap trigger flag More...
 
static void pcfg_disable_dcdc_retention (PCFG_Type *ptr)
 disable dcdc retention More...
 
static void pcfg_enable_dcdc_retention (PCFG_Type *ptr)
 enable dcdc retention to retain soc sram data More...
 
static void pcfg_clear_wakeup_cause (PCFG_Type *ptr, uint32_t mask)
 clear wakeup cause flag More...
 
static uint32_t pcfg_get_wakeup_cause (PCFG_Type *ptr)
 get wakeup cause More...
 
static void pcfg_enable_wakeup_source (PCFG_Type *ptr, uint32_t mask)
 enable wakeup source More...
 
static void pcfg_disable_wakeup_source (PCFG_Type *ptr, uint32_t mask)
 disable wakeup source More...
 
static void pcfg_set_periph_clock_mode (PCFG_Type *ptr, uint32_t mode)
 set clock gate mode in vpmc domain More...
 
static void pcfg_update_periph_clock_mode (PCFG_Type *ptr, pcfg_pmc_periph_t periph, bool on)
 update clock gate mode in vpmc domain More...
 
static bool pcfg_irc24m_is_trimmed (PCFG_Type *ptr)
 check if irc24m is trimmed More...
 
static void pcfg_irc24m_reload_trim (PCFG_Type *ptr)
 reload irc24m trim value More...
 
void pcfg_irc24m_config_track (PCFG_Type *ptr, pcfg_irc24m_config_t *config)
 config irc24m track More...
 
hpm_stat_t pcfg_dcdc_set_lpmode_voltage (PCFG_Type *ptr, uint16_t mv)
 
hpm_stat_t pcfg_ldo2p5_set_voltage (PCFG_Type *ptr, uint16_t mv)
 
hpm_stat_t pcfg_dcdc_set_voltage (PCFG_Type *ptr, uint16_t mv)
 
hpm_stat_t pcfg_ldo1p1_set_voltage (PCFG_Type *ptr, uint16_t mv)
 
uint16_t pcfg_dcdc_get_current_level (PCFG_Type *ptr)