mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
75 lines
2.3 KiB
C
75 lines
2.3 KiB
C
#include "bsp_port.h"
|
|
|
|
// 禁用JTAG引脚,保留SWD引脚
|
|
void Sys_DisableJTAGEnableSWD(void)
|
|
{
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); //开启AFIO时钟
|
|
GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE); //禁止JTAG功能
|
|
}
|
|
|
|
// PM 初始化
|
|
void BSP_PowerInit(void)
|
|
{
|
|
GPIO_InitTypeDef GPIO_InitStructure;
|
|
EXTI_InitTypeDef EXTI_InitStructure;
|
|
NVIC_InitTypeDef NVIC_InitStructure;
|
|
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE);
|
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_12|GPIO_Pin_13;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
|
GPIO_Init(GPIOB,&GPIO_InitStructure);
|
|
|
|
Power_PMD4(0); Power_3V3(0); Power_LCD(0);
|
|
|
|
// 唤醒/正在充电指示/充电完成
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13|GPIO_Pin_14;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
|
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
|
|
|
/* Configure one bit for preemption priority */
|
|
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
|
|
|
|
/* 配置P[A|B|C|D|E]0为中断源 */
|
|
NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQn;
|
|
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
|
|
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
|
|
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
|
NVIC_Init(&NVIC_InitStructure);
|
|
|
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
|
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
|
GPIO_Init(GPIOC,&GPIO_InitStructure);
|
|
|
|
GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource15);
|
|
EXTI_InitStructure.EXTI_Line = EXTI15_10_IRQn;
|
|
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
|
|
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; //下降沿中断
|
|
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
|
|
EXTI_Init(&EXTI_InitStructure);
|
|
}
|
|
|
|
void EXTI15_10_IRQHandler(void)
|
|
{
|
|
if(EXTI_GetITStatus(EXTI_Line15) != RESET)
|
|
{
|
|
EXTI_ClearITPendingBit(EXTI_Line15);
|
|
|
|
if(DevParam.RunPhase == 0)
|
|
{
|
|
BSP_Restart();
|
|
}
|
|
}
|
|
}
|
|
|
|
// mcu 重新启动
|
|
void BSP_Restart(void){
|
|
__set_FAULTMASK(1);
|
|
NVIC_SystemReset();
|
|
}
|
|
|
|
|
|
|