| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- /****************************************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<MIN_PWR_LEVEL)
- {//电池电压小于335V 系统关机
- printf("VB_Low!shutdown\r\n");
- PWR_EN_LOW;
- Sleeping();
- }
- EncodeInit();
- BeepInit();
- OnOff_Init();
- MY_NVIC_Init();
- SysTick_Config(SystemCoreClock / 100);
- /* Initialize RTX and start init */
- os_sys_init_user(MainTask,1,stkMainTask,sizeof(stkMainTask));
- return (0);
- }
- /*********************************************************************************************************
- END FILE
- *********************************************************************************************************/
|