generated from hulk/gd32f4xx_template_cmake_vscode
Add PA11 power-hold output (PMOS self-latch keep-alive)
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
#include "pwr_hold.h"
|
||||
#include "gd32f4xx_rcu.h"
|
||||
#include "gd32f4xx_gpio.h"
|
||||
#include "board_config.h"
|
||||
|
||||
void pwr_hold_init(void) {
|
||||
/* 使能 GPIO 时钟,推挽输出高(PMOS 导通,维持供电) */
|
||||
rcu_periph_clock_enable(PWR_HOLD_RCU);
|
||||
gpio_mode_set(PWR_HOLD_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, PWR_HOLD_PIN);
|
||||
gpio_output_options_set(PWR_HOLD_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, PWR_HOLD_PIN);
|
||||
gpio_bit_set(PWR_HOLD_PORT, PWR_HOLD_PIN);
|
||||
}
|
||||
|
||||
void pwr_hold_on(void) {
|
||||
gpio_bit_set(PWR_HOLD_PORT, PWR_HOLD_PIN);
|
||||
}
|
||||
|
||||
void pwr_hold_off(void) {
|
||||
/* 软关机:置低后系统失电 */
|
||||
gpio_bit_reset(PWR_HOLD_PORT, PWR_HOLD_PIN);
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user