/****************************************Copyright (c)**************************************************** ** ** **--------------File Info--------------------------------------------------------------------------------- ** File name: main.c ** Descriptions: ** **-------------------------------------------------------------------------------------------------------- ** Created by: ** Created date: ** Version: ** Descriptions: ** **-------------------------------------------------------------------------------------------------------- ** Modified by: ** Modified date: ** Version: ** Descriptions: ** *********************************************************************************************************/ #define THIS_FILE_ID 1 /* Includes ------------------------------------------------------------------*/ #include "includes.h" void MY_NVIC_Init() { NVIC_InitTypeDef NVIC_InitStructure; NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); RunMake(THIS_FILE_ID); //串口1 NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RunMake(THIS_FILE_ID); //串口2 NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RunMake(THIS_FILE_ID); //串口2 NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); RunMake(THIS_FILE_ID); //DMA中断设置 ///////////////////// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority= 1; NVIC_InitStructure.NVIC_IRQChannelSubPriority= 1; NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE; NVIC_InitStructure.NVIC_IRQChannel= EXTI1_IRQn; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel= EXTI2_IRQn; NVIC_Init(&NVIC_InitStructure); NVIC_InitStructure.NVIC_IRQChannel= EXTI9_5_IRQn; NVIC_Init(&NVIC_InitStructure); } #if 0 /* id1, id2 will contain task identifications at run-time. */ OS_TID id1, id2; /* Forward declaration of tasks. */ __task void task1 (void); __task void task2 (void); __task void task1 (void){ int ct=0; /* Obtain own system task identification number. */ id1 = os_tsk_self(); printf("task1 run!\r\n"); /* Create task2 and obtain its task identification number. */ //id2 = os_tsk_create (task2, 0); for (;;) { /* ... place code for task1 activity here ... */ printf("[task1]tick=%d\r\n",ct++); /* Signal to task2 that task1 has completed. */ // os_evt_set(0x0004, id2); /* Wait for completion of task2 activity. */ /* 0xFFFF makes it wait without timeout. */ /* 0x0004 represents bit 2. */ //os_evt_wait_or(0x0004, 0xFFFF); /* Wait for 50 ms before restarting task1 activity. */ os_dly_wait(200); } } __task void task2 (void) { int ct=0; printf("task2 run!\r\n"); for (;;) { printf("[task2]tick=%d\r\n",ct++); /* Wait for completion of task1 activity. */ /* 0xFFFF makes it wait without timeout. */ /* 0x0004 represents bit 2. */ os_evt_wait_or(0x0004, 0xFFFF); /* Wait for 20 ms before starting task2 activity. */ os_dly_wait(50); /* ... place code for task2 activity here ... */ /* Signal to task1 that task2 has completed. */ os_evt_set(0x0004, id1); } } #endif /********************************************************************************************************** main() **********************************************************************************************************/ int main (void) { int Vbat; IWDG_Configuration(500); PowerCtrlInit(); Uart1Init(); Uart2Init(); Uart3Init(); GPSInit(); KeyInit(); SpeakerInit(); MicrophoneInit(); ADCInit(); Vbat=-1; while(Vbat<0) Vbat=GetVbat(); if(Vbat