generated from hulk/gd32f4xx_template_cmake_vscode
Add PA11 power-hold output (PMOS self-latch keep-alive)
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "command.h"
|
||||
#include "ntc.h"
|
||||
#include "led.h"
|
||||
#include "pwr_hold.h"
|
||||
#include <stdio.h>
|
||||
#include "board_config.h"
|
||||
|
||||
@@ -25,6 +26,9 @@
|
||||
*/
|
||||
int main(void)
|
||||
{
|
||||
/* 电源保持脚最先初始化:上电立即拉高 PA11 维持 PMOS 导通(先于一切外设) */
|
||||
pwr_hold_init();
|
||||
|
||||
led_init();
|
||||
|
||||
systick_config();
|
||||
|
||||
@@ -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