libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.

Defined Constants and Types for the STM32G4xx Power Control More...

Collaboration diagram for PWR Defines:

Modules

 PVD level selection
 

Macros

#define PWR_CR1   MMIO32(POWER_CONTROL_BASE + 0x00)
 
#define PWR_CR2   MMIO32(POWER_CONTROL_BASE + 0x04)
 
#define PWR_CR3   MMIO32(POWER_CONTROL_BASE + 0x08)
 
#define PWR_CR4   MMIO32(POWER_CONTROL_BASE + 0x0C)
 
#define PWR_CR5   MMIO32(POWER_CONTROL_BASE + 0x80)
 
#define PWR_SR1   MMIO32(POWER_CONTROL_BASE + 0x10)
 
#define PWR_SR2   MMIO32(POWER_CONTROL_BASE + 0x14)
 
#define PWR_SCR   MMIO32(POWER_CONTROL_BASE + 0x18)
 
#define PWR_PORT_A   MMIO32(POWER_CONTROL_BASE + 0x20)
 
#define PWR_PORT_B   MMIO32(POWER_CONTROL_BASE + 0x28)
 
#define PWR_PORT_C   MMIO32(POWER_CONTROL_BASE + 0x30)
 
#define PWR_PORT_D   MMIO32(POWER_CONTROL_BASE + 0x38)
 
#define PWR_PORT_E   MMIO32(POWER_CONTROL_BASE + 0x40)
 
#define PWR_PORT_F   MMIO32(POWER_CONTROL_BASE + 0x48)
 
#define PWR_PORT_G   MMIO32(POWER_CONTROL_BASE + 0x50)
 
#define PWR_PUCR(pwr_port)   MMIO32((pwr_port) + 0x00)
 
#define PWR_PDCR(pwr_port)   MMIO32((pwr_port) + 0x04)
 
#define PWR_CR1_LPR   (1 << 14)
 
#define PWR_CR1_VOS_SHIFT   9
 
#define PWR_CR1_VOS_MASK   0x3
 
#define PWR_CR1_VOS_RANGE_1   1
 
#define PWR_CR1_VOS_RANGE_2   2
 
#define PWR_CR1_DBP   (1 << 8)
 
#define PWR_CR1_LPMS_SHIFT   0
 
#define PWR_CR1_LPMS_MASK   0x07
 
#define PWR_CR1_LPMS_STOP_0   0
 
#define PWR_CR1_LPMS_STOP_1   1
 
#define PWR_CR1_LPMS_STOP_2   2
 
#define PWR_CR1_LPMS_STANDBY   3
 
#define PWR_CR1_LPMS_SHUTDOWN   4
 
#define PWR_CR2_PVMEN2   (1 << 7)
 
#define PWR_CR2_PVMEN1   (1 << 6)
 
#define PWR_CR2_PLS_SHIFT   1
 
#define PWR_CR2_PLS_MASK   0x07
 
#define PWR_CR2_PVDE   (1 << 0)
 
#define PWR_CR3_EIWUL   (1 << 15)
 
#define PWR_CR3_UCPD1_DBDIS   (1 << 14)
 
#define PWR_CR3_UCPD1_STDBY   (1 << 13)
 
#define PWR_CR3_APC   (1 << 10)
 
#define PWR_CR3_RRS   (1 << 8)
 
#define PWR_CR3_EWUP5   (1 << 4)
 
#define PWR_CR3_EWUP4   (1 << 3)
 
#define PWR_CR3_EWUP3   (1 << 2)
 
#define PWR_CR3_EWUP2   (1 << 1)
 
#define PWR_CR3_EWUP1   (1 << 0)
 
#define PWR_CR4_VBRS   (1 << 9)
 
#define PWR_CR4_VBE   (1 << 8)
 
#define PWR_CR4_WP5   (1 << 4)
 
#define PWR_CR4_WP4   (1 << 3)
 
#define PWR_CR4_WP3   (1 << 2)
 
#define PWR_CR4_WP2   (1 << 1)
 
#define PWR_CR4_WP1   (1 << 0)
 
#define PWR_CR5_R1MODE_SHIFT   8
 
#define PWR_CR5_R1MODE_MASK   0x1
 
#define PWR_CR5_R1MODE_BOOST   0
 
#define PWR_CR5_R1MODE_NORMAL   1
 
#define PWR_CR5_R1MODE   (PWR_CR5_R1MODE_MASK << PWR_CR5_R1MODE_SHIFT)
 
#define PWR_SR1_WUFI   (1 << 15)
 
#define PWR_SR1_SBF   (1 << 8)
 
#define PWR_SR1_WUF5   (1 << 4)
 
#define PWR_SR1_WUF4   (1 << 3)
 
#define PWR_SR1_WUF3   (1 << 2)
 
#define PWR_SR1_WUF2   (1 << 1)
 
#define PWR_SR1_WUF1   (1 << 0)
 
#define PWR_SR2_PVMO2   (1 << 15)
 
#define PWR_SR2_PVMO1   (1 << 14)
 
#define PWR_SR2_PVDO   (1 << 11)
 
#define PWR_SR2_VOSF   (1 << 10)
 
#define PWR_SR2_REGLPF   (1 << 9)
 
#define PWR_SR2_REGLPS   (1 << 8)
 
#define PWR_SCR_CSBF   (1 << 8)
 
#define PWR_SCR_CWUF5   (1 << 4)
 
#define PWR_SCR_CWUF4   (1 << 3)
 
#define PWR_SCR_CWUF3   (1 << 2)
 
#define PWR_SCR_CWUF2   (1 << 1)
 
#define PWR_SCR_CWUF1   (1 << 0)
 

Enumerations

enum  pwr_vos_scale { PWR_SCALE1 = PWR_CR1_VOS_RANGE_1 , PWR_SCALE2 = PWR_CR1_VOS_RANGE_2 }
 

Functions

void pwr_set_vos_scale (enum pwr_vos_scale scale)
 
void pwr_disable_backup_domain_write_protect (void)
 Disable Backup Domain Write Protection. More...
 
void pwr_enable_backup_domain_write_protect (void)
 Re-enable Backup Domain Write Protection. More...
 
void pwr_set_low_power_mode_selection (uint32_t lpms)
 Select the low power mode used in deep sleep. More...
 
void pwr_enable_power_voltage_detect (uint32_t pvd_level)
 Enable Power Voltage Detector. More...
 
void pwr_disable_power_voltage_detect (void)
 Disable Power Voltage Detector. More...
 
void pwr_enable_boost (void)
 Enable Boost Mode. More...
 
void pwr_disable_boost (void)
 Disable Boost Mode. More...
 

Detailed Description

Defined Constants and Types for the STM32G4xx Power Control

Version
1.0.0
Author
© 2016 Benjamin Levine benja.nosp@m.min@.nosp@m.jesco.nosp@m..kar.nosp@m.oo.co.nosp@m..uk
© 2019 Guillaume Revaillot g.rev.nosp@m.aill.nosp@m.ot@gm.nosp@m.ail..nosp@m.com
© 2020 Ben Brewer ben.b.nosp@m.rewe.nosp@m.r@cod.nosp@m.ethi.nosp@m.nk.co.nosp@m..uk
Date
29 July 2020

LGPL License Terms libopencm3 License

Macro Definition Documentation

◆ PWR_CR1

#define PWR_CR1   MMIO32(POWER_CONTROL_BASE + 0x00)

Definition at line 51 of file g4/pwr.h.

◆ PWR_CR1_DBP

#define PWR_CR1_DBP   (1 << 8)

Definition at line 80 of file g4/pwr.h.

◆ PWR_CR1_LPMS_MASK

#define PWR_CR1_LPMS_MASK   0x07

Definition at line 83 of file g4/pwr.h.

◆ PWR_CR1_LPMS_SHIFT

#define PWR_CR1_LPMS_SHIFT   0

Definition at line 82 of file g4/pwr.h.

◆ PWR_CR1_LPMS_SHUTDOWN

#define PWR_CR1_LPMS_SHUTDOWN   4

Definition at line 88 of file g4/pwr.h.

◆ PWR_CR1_LPMS_STANDBY

#define PWR_CR1_LPMS_STANDBY   3

Definition at line 87 of file g4/pwr.h.

◆ PWR_CR1_LPMS_STOP_0

#define PWR_CR1_LPMS_STOP_0   0

Definition at line 84 of file g4/pwr.h.

◆ PWR_CR1_LPMS_STOP_1

#define PWR_CR1_LPMS_STOP_1   1

Definition at line 85 of file g4/pwr.h.

◆ PWR_CR1_LPMS_STOP_2

#define PWR_CR1_LPMS_STOP_2   2

Definition at line 86 of file g4/pwr.h.

◆ PWR_CR1_LPR

#define PWR_CR1_LPR   (1 << 14)

Definition at line 73 of file g4/pwr.h.

◆ PWR_CR1_VOS_MASK

#define PWR_CR1_VOS_MASK   0x3

Definition at line 76 of file g4/pwr.h.

◆ PWR_CR1_VOS_RANGE_1

#define PWR_CR1_VOS_RANGE_1   1

Definition at line 77 of file g4/pwr.h.

◆ PWR_CR1_VOS_RANGE_2

#define PWR_CR1_VOS_RANGE_2   2

Definition at line 78 of file g4/pwr.h.

◆ PWR_CR1_VOS_SHIFT

#define PWR_CR1_VOS_SHIFT   9

Definition at line 75 of file g4/pwr.h.

◆ PWR_CR2

#define PWR_CR2   MMIO32(POWER_CONTROL_BASE + 0x04)

Definition at line 52 of file g4/pwr.h.

◆ PWR_CR2_PLS_MASK

#define PWR_CR2_PLS_MASK   0x07

Definition at line 96 of file g4/pwr.h.

◆ PWR_CR2_PLS_SHIFT

#define PWR_CR2_PLS_SHIFT   1

Definition at line 95 of file g4/pwr.h.

◆ PWR_CR2_PVDE

#define PWR_CR2_PVDE   (1 << 0)

Definition at line 110 of file g4/pwr.h.

◆ PWR_CR2_PVMEN1

#define PWR_CR2_PVMEN1   (1 << 6)

Definition at line 93 of file g4/pwr.h.

◆ PWR_CR2_PVMEN2

#define PWR_CR2_PVMEN2   (1 << 7)

Definition at line 92 of file g4/pwr.h.

◆ PWR_CR3

#define PWR_CR3   MMIO32(POWER_CONTROL_BASE + 0x08)

Definition at line 53 of file g4/pwr.h.

◆ PWR_CR3_APC

#define PWR_CR3_APC   (1 << 10)

Definition at line 117 of file g4/pwr.h.

◆ PWR_CR3_EIWUL

#define PWR_CR3_EIWUL   (1 << 15)

Definition at line 114 of file g4/pwr.h.

◆ PWR_CR3_EWUP1

#define PWR_CR3_EWUP1   (1 << 0)

Definition at line 123 of file g4/pwr.h.

◆ PWR_CR3_EWUP2

#define PWR_CR3_EWUP2   (1 << 1)

Definition at line 122 of file g4/pwr.h.

◆ PWR_CR3_EWUP3

#define PWR_CR3_EWUP3   (1 << 2)

Definition at line 121 of file g4/pwr.h.

◆ PWR_CR3_EWUP4

#define PWR_CR3_EWUP4   (1 << 3)

Definition at line 120 of file g4/pwr.h.

◆ PWR_CR3_EWUP5

#define PWR_CR3_EWUP5   (1 << 4)

Definition at line 119 of file g4/pwr.h.

◆ PWR_CR3_RRS

#define PWR_CR3_RRS   (1 << 8)

Definition at line 118 of file g4/pwr.h.

◆ PWR_CR3_UCPD1_DBDIS

#define PWR_CR3_UCPD1_DBDIS   (1 << 14)

Definition at line 115 of file g4/pwr.h.

◆ PWR_CR3_UCPD1_STDBY

#define PWR_CR3_UCPD1_STDBY   (1 << 13)

Definition at line 116 of file g4/pwr.h.

◆ PWR_CR4

#define PWR_CR4   MMIO32(POWER_CONTROL_BASE + 0x0C)

Definition at line 54 of file g4/pwr.h.

◆ PWR_CR4_VBE

#define PWR_CR4_VBE   (1 << 8)

Definition at line 128 of file g4/pwr.h.

◆ PWR_CR4_VBRS

#define PWR_CR4_VBRS   (1 << 9)

Definition at line 127 of file g4/pwr.h.

◆ PWR_CR4_WP1

#define PWR_CR4_WP1   (1 << 0)

Definition at line 133 of file g4/pwr.h.

◆ PWR_CR4_WP2

#define PWR_CR4_WP2   (1 << 1)

Definition at line 132 of file g4/pwr.h.

◆ PWR_CR4_WP3

#define PWR_CR4_WP3   (1 << 2)

Definition at line 131 of file g4/pwr.h.

◆ PWR_CR4_WP4

#define PWR_CR4_WP4   (1 << 3)

Definition at line 130 of file g4/pwr.h.

◆ PWR_CR4_WP5

#define PWR_CR4_WP5   (1 << 4)

Definition at line 129 of file g4/pwr.h.

◆ PWR_CR5

#define PWR_CR5   MMIO32(POWER_CONTROL_BASE + 0x80)

Definition at line 55 of file g4/pwr.h.

◆ PWR_CR5_R1MODE

#define PWR_CR5_R1MODE   (PWR_CR5_R1MODE_MASK << PWR_CR5_R1MODE_SHIFT)

Definition at line 141 of file g4/pwr.h.

◆ PWR_CR5_R1MODE_BOOST

#define PWR_CR5_R1MODE_BOOST   0

Definition at line 139 of file g4/pwr.h.

◆ PWR_CR5_R1MODE_MASK

#define PWR_CR5_R1MODE_MASK   0x1

Definition at line 138 of file g4/pwr.h.

◆ PWR_CR5_R1MODE_NORMAL

#define PWR_CR5_R1MODE_NORMAL   1

Definition at line 140 of file g4/pwr.h.

◆ PWR_CR5_R1MODE_SHIFT

#define PWR_CR5_R1MODE_SHIFT   8

Definition at line 137 of file g4/pwr.h.

◆ PWR_PDCR

#define PWR_PDCR (   pwr_port)    MMIO32((pwr_port) + 0x04)

Definition at line 69 of file g4/pwr.h.

◆ PWR_PORT_A

#define PWR_PORT_A   MMIO32(POWER_CONTROL_BASE + 0x20)

Definition at line 60 of file g4/pwr.h.

◆ PWR_PORT_B

#define PWR_PORT_B   MMIO32(POWER_CONTROL_BASE + 0x28)

Definition at line 61 of file g4/pwr.h.

◆ PWR_PORT_C

#define PWR_PORT_C   MMIO32(POWER_CONTROL_BASE + 0x30)

Definition at line 62 of file g4/pwr.h.

◆ PWR_PORT_D

#define PWR_PORT_D   MMIO32(POWER_CONTROL_BASE + 0x38)

Definition at line 63 of file g4/pwr.h.

◆ PWR_PORT_E

#define PWR_PORT_E   MMIO32(POWER_CONTROL_BASE + 0x40)

Definition at line 64 of file g4/pwr.h.

◆ PWR_PORT_F

#define PWR_PORT_F   MMIO32(POWER_CONTROL_BASE + 0x48)

Definition at line 65 of file g4/pwr.h.

◆ PWR_PORT_G

#define PWR_PORT_G   MMIO32(POWER_CONTROL_BASE + 0x50)

Definition at line 66 of file g4/pwr.h.

◆ PWR_PUCR

#define PWR_PUCR (   pwr_port)    MMIO32((pwr_port) + 0x00)

Definition at line 68 of file g4/pwr.h.

◆ PWR_SCR

#define PWR_SCR   MMIO32(POWER_CONTROL_BASE + 0x18)

Definition at line 58 of file g4/pwr.h.

◆ PWR_SCR_CSBF

#define PWR_SCR_CSBF   (1 << 8)

Definition at line 164 of file g4/pwr.h.

◆ PWR_SCR_CWUF1

#define PWR_SCR_CWUF1   (1 << 0)

Definition at line 169 of file g4/pwr.h.

◆ PWR_SCR_CWUF2

#define PWR_SCR_CWUF2   (1 << 1)

Definition at line 168 of file g4/pwr.h.

◆ PWR_SCR_CWUF3

#define PWR_SCR_CWUF3   (1 << 2)

Definition at line 167 of file g4/pwr.h.

◆ PWR_SCR_CWUF4

#define PWR_SCR_CWUF4   (1 << 3)

Definition at line 166 of file g4/pwr.h.

◆ PWR_SCR_CWUF5

#define PWR_SCR_CWUF5   (1 << 4)

Definition at line 165 of file g4/pwr.h.

◆ PWR_SR1

#define PWR_SR1   MMIO32(POWER_CONTROL_BASE + 0x10)

Definition at line 56 of file g4/pwr.h.

◆ PWR_SR1_SBF

#define PWR_SR1_SBF   (1 << 8)

Definition at line 146 of file g4/pwr.h.

◆ PWR_SR1_WUF1

#define PWR_SR1_WUF1   (1 << 0)

Definition at line 151 of file g4/pwr.h.

◆ PWR_SR1_WUF2

#define PWR_SR1_WUF2   (1 << 1)

Definition at line 150 of file g4/pwr.h.

◆ PWR_SR1_WUF3

#define PWR_SR1_WUF3   (1 << 2)

Definition at line 149 of file g4/pwr.h.

◆ PWR_SR1_WUF4

#define PWR_SR1_WUF4   (1 << 3)

Definition at line 148 of file g4/pwr.h.

◆ PWR_SR1_WUF5

#define PWR_SR1_WUF5   (1 << 4)

Definition at line 147 of file g4/pwr.h.

◆ PWR_SR1_WUFI

#define PWR_SR1_WUFI   (1 << 15)

Definition at line 145 of file g4/pwr.h.

◆ PWR_SR2

#define PWR_SR2   MMIO32(POWER_CONTROL_BASE + 0x14)

Definition at line 57 of file g4/pwr.h.

◆ PWR_SR2_PVDO

#define PWR_SR2_PVDO   (1 << 11)

Definition at line 157 of file g4/pwr.h.

◆ PWR_SR2_PVMO1

#define PWR_SR2_PVMO1   (1 << 14)

Definition at line 156 of file g4/pwr.h.

◆ PWR_SR2_PVMO2

#define PWR_SR2_PVMO2   (1 << 15)

Definition at line 155 of file g4/pwr.h.

◆ PWR_SR2_REGLPF

#define PWR_SR2_REGLPF   (1 << 9)

Definition at line 159 of file g4/pwr.h.

◆ PWR_SR2_REGLPS

#define PWR_SR2_REGLPS   (1 << 8)

Definition at line 160 of file g4/pwr.h.

◆ PWR_SR2_VOSF

#define PWR_SR2_VOSF   (1 << 10)

Definition at line 158 of file g4/pwr.h.

Enumeration Type Documentation

◆ pwr_vos_scale

Enumerator
PWR_SCALE1 
PWR_SCALE2 

Definition at line 173 of file g4/pwr.h.

Function Documentation

◆ pwr_disable_backup_domain_write_protect()

void pwr_disable_backup_domain_write_protect ( void  )

Disable Backup Domain Write Protection.

This allows backup domain registers to be changed. These registers are write protected after a reset.

Definition at line 57 of file pwr.c.

References PWR_CR1, and PWR_CR1_DBP.

◆ pwr_disable_boost()

void pwr_disable_boost ( void  )

Disable Boost Mode.

Definition at line 116 of file pwr.c.

References PWR_CR5, and PWR_CR5_R1MODE.

Referenced by rcc_clock_setup_pll().

Here is the caller graph for this function:

◆ pwr_disable_power_voltage_detect()

void pwr_disable_power_voltage_detect ( void  )

Disable Power Voltage Detector.

Definition at line 100 of file pwr.c.

References PWR_CR2.

◆ pwr_enable_backup_domain_write_protect()

void pwr_enable_backup_domain_write_protect ( void  )

Re-enable Backup Domain Write Protection.

This protects backup domain registers from inadvertent change.

Definition at line 66 of file pwr.c.

References PWR_CR1.

◆ pwr_enable_boost()

void pwr_enable_boost ( void  )

Enable Boost Mode.

Definition at line 108 of file pwr.c.

References PWR_CR5.

Referenced by rcc_clock_setup_pll().

Here is the caller graph for this function:

◆ pwr_enable_power_voltage_detect()

void pwr_enable_power_voltage_detect ( uint32_t  pvd_level)

Enable Power Voltage Detector.

Parameters
[in]pvd_levelPower Voltage Detector Falling Threshold voltage PVD level selection.

Definition at line 88 of file pwr.c.

References PWR_CR2, PWR_CR2_PLS_MASK, PWR_CR2_PLS_SHIFT, and PWR_CR2_PVDE.

◆ pwr_set_low_power_mode_selection()

void pwr_set_low_power_mode_selection ( uint32_t  lpms)

Select the low power mode used in deep sleep.

Parameters
lpmslow power mode pwr_cr1_lpms

Definition at line 75 of file pwr.c.

References PWR_CR1, PWR_CR1_LPMS_MASK, and PWR_CR1_LPMS_SHIFT.

◆ pwr_set_vos_scale()

void pwr_set_vos_scale ( enum pwr_vos_scale  scale)

Definition at line 43 of file pwr.c.

References PWR_CR1, PWR_CR1_VOS_MASK, and PWR_CR1_VOS_SHIFT.

Referenced by rcc_clock_setup_pll().

Here is the caller graph for this function: