inline void Initialization_All(void) { init_outpin(); AdcInit(); GlobalTimerInit(); Button_Init(); init_meandr__gpio(); init_meandr_timer(); Init_Uart3(); //TIM3_IRQHandler(); NVIC_InitTypeDef NVIC_InitStructure_usart3; NVIC_InitStructure_usart3.NVIC_IRQChannel = USART3_IRQn; NVIC_InitStructure_usart3.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure_usart3.NVIC_IRQChannelPreemptionPriority = 1; NVIC_InitStructure_usart3.NVIC_IRQChannelCmd = ENABLE; NVIC_Init (&NVIC_InitStructure_usart3); USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); //state_err=2; //USART_ITConfig(USART3, USART_IT_ERR, ENABLE); USART_ITConfig(USART3, USART_IT_TC, DISABLE); // NVIC_conf(); display.a.port = GPIOH; display.b.port = GPIOC; display.c.port = GPIOE; display.d.port = GPIOE; display.e.port = GPIOE; display.f.port = GPIOE; display.g.port = GPIOB; display.common[0].port = GPIOC; display.common[1].port = GPIOC; display.common[2].port = GPIOH; display.dot.port = GPIOB; display.a.pin = GPIO_Pin_0; display.b.pin = GPIO_Pin_14; display.c.pin = GPIO_Pin_6; display.d.pin = GPIO_Pin_4; display.e.pin = GPIO_Pin_2; display.f.pin = GPIO_Pin_0; display.g.pin = GPIO_Pin_8; display.common[0].pin = GPIO_Pin_13; display.common[1].pin = GPIO_Pin_15; display.common[2].pin = GPIO_Pin_1; display.dot.pin = GPIO_Pin_6; DI_Init(&display); }
int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f4xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ //================= Initialisation pin et interruptions ============================= GPIO_Configuration(); NVIC_Configuration(); /* Interrupt Config SDIO*/ EXTILine0_Config(); // Interrupt PA0 Timer2_Config(); //Configure timer2 1[s] Init_Uart2(4800); Init_Uart3(4800); Init_SDCard(); //Mount sd card and use fat32 format fileUart2 = initialiserFile(); //Init fifo pile fileUart3 = initialiserFile(); //Init fifo pile while(1) /* Infinite loop */ { switch(etatBtBleu) { case START: enableUsartIt(); GPIO_SetBits(GPIOD, GPIO_Pin_12); //Turn on green led led_gr_blink = 1; //Activate the blink mod in an interruption writeHeader(head_txt2, file2_path); //header for the usart2 file writeHeader(head_txt3, file3_path); //header for the usart3 file etatBtBleu = RUN; break; case STOP: disableUsartIt(); //we will read the fifo pile so it's better to inibit usart interrupt led_gr_blink = 0; GPIO_ResetBits(GPIOD, GPIO_Pin_12); //green led off GPIO_SetBits(GPIOD, GPIO_Pin_15); //blue led on writeDynamicTabData(pullN(fileUart2, nbCaractUart2), nbCaractUart2, file2_path); //write all the fifo's uart2 data writeDynamicTabData(pullN(fileUart3, nbCaractUart3), nbCaractUart3, file3_path); //write all the fifo's uart3 data GPIO_ResetBits(GPIOD, GPIO_Pin_15); //blue led off nbCaractUart2 = 0; nbCaractUart3 = 0; etatBtBleu=WAIT; break; case RUN: //=========== write data when we have NB_CARACT_STOCK into the usart2 fifo pile ============= if(flag_fileUart2Ready) { flag_fileUart2Ready=0; writeDynamicTabData(pullN(fileUart2, NB_CARACT_STOCK), NB_CARACT_STOCK, file2_path); //write NB_CARACT_STOCK of uart2 data GPIO_ResetBits(GPIOD, GPIO_Pin_15); //blue led off } //=========== write data when we have NB_CARACT_STOCK into the usart3 fifo pile ============= if(flag_fileUart3Ready) { flag_fileUart3Ready = 0; writeDynamicTabData(pullN(fileUart3, NB_CARACT_STOCK), NB_CARACT_STOCK, file3_path); //write NB_CARACT_STOCK of uart3 data GPIO_ResetBits(GPIOD, GPIO_Pin_15); //blue led off } break; } } }