串口打印 重连也不好用 估计toms被打破了
Conn 1 - Int 28
Connected..
Update 1 - Int 6
Update 1 - Int a
RSSI -34 dB CoRun at EXTI
n 1
RSSI -34 dB Conn 1
RSSI -34 dB Conn 1
Disconnected.. Reason:8
Advertising..
/***********************************
peripheral.c 启动或停止电机
static void performPeriodicTask(void)
{
GPIO_WriteBit(GPIOB, GPIO_Pin_6, Bit_RESET);
GPIO_WriteBit(GPIOC, GPIO_Pin_6, (i == 0) ? (i = Bit_SET) : (i = Bit_RESET));
}
/********************************************
peripheral_main.c
void EXTI4_INT_INIT(void)
{
内嵌运放的输出为高电平就启动中断
EXTI_InitTypeDef EXTI_InitStructure = {0};
NVIC_InitTypeDef NVIC_InitStructure = {0};
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO , ENABLE);
/* GPIOA ----> EXTI_Line0 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource4);
EXTI_InitStructure.EXTI_Line = EXTI_Line4;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
int main(void)
{
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
Delay_Init();
#ifdef DEBUG
USART_Printf_Init( 115200 );
#endif
PRINT("%s\n", VER_LIB);
//NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
GPIO_INIT();
OPA2_Init();
EXTI4_INT_INIT();
WCHBLE_Init();
HAL_Init();
GAPRole_PeripheralInit();
Peripheral_Init();
Main_Circulation();
}
中断
void EXTI4_IRQHandler(void)
{
if(EXTI_GetITStatus(EXTI_Line4)!=RESET)
{
printf("Run at EXTI\r\n");
EXTI_ClearITPendingBit(EXTI_Line4); /* Clear Flag */
}
}