/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ RCC_ClocksTypeDef RCC_Clocks; /* SysTick end of count event each 1ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); /* Initialize LEDs mounted on EVAL board */ STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Put LED3 on */ STM_EVAL_LEDOn(LED3); /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Configure EXTI Line13 (connected to PC13 pin) in interrupt mode */ EXTILine13_Config(); while (1) { /* Generate software interrupt: simulate a falling edge applied on EXTI0 line */ EXTI_GenerateSWInterrupt(EXTI_Line13); Delay(500); } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f4xx.c file */ /* Initialize LEDs mounted on EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Configure EXTI Line13/15 (connected to PG13/15 pin) in interrupt mode according to EVAL used */ EXTILine13_15_Config(); /* Generate software interrupt: simulate a falling edge applied on EXTI0 line */ EXTI_GenerateSWInterrupt(EXTI_Line0); while (1) { } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /*##-1- Initialize LEDs mounted on EVAL board ##############################*/ BSP_LED_Init(LED1); BSP_LED_Init(LED2); /*##-2- Configure EXTI Line0 (connected to PA0 pin) in interrupt mode ######*/ EXTILine0_Config(); /*##-3- Configure EXTI Line15 (connected to PG15 pin) in interrupt mode ####*/ EXTILine15_10_Config(); /* Infinite loop */ while (1) { } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* This sample code shows how to use STM32F4xx GPIO HAL API to toggle PG6, PG7, PG10, and PG12 IOs (connected to LED1, LED2, LED3 and LED4 on STM324x9I-EVAL board) in an infinite loop. To proceed, 3 steps are required: */ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure the system clock */ SystemClock_Config(); /* -1- Initialize LEDs mounted on EVAL board */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); /* -2- Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* -3- Configure EXTI Line13 (connected to PC13 pin) in interrupt mode */ EXTILine13_15_Config(); while (1) { } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* This sample code shows how to use STM32F4xx GPIO HAL API to toggle PD12, PD13, PD14, and PD14 IOs (connected to LED4, LED3, LED5 and LED6 on STM32F401C-DISCO board (MB1115B)) in an infinite loop. To proceed, 3 steps are required: */ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* Configure LED3, LED4, LED5 and LED6 */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); BSP_LED_Init(LED5); BSP_LED_Init(LED6); /* Configure the system clock to 84 MHz */ SystemClock_Config(); /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Infinite loop */ while (1) { } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* This sample code shows how to use STM32F4xx GPIO HAL API to toggle PG13 IOs (connected to LED3 on STM32F429i-Discovery board) in an infinite loop. To proceed, 3 steps are required: */ /* STM32F4xx HAL library initialization: - Configure the Flash prefetch, instruction and Data caches - Configure the Systick to generate an interrupt each 1 msec - Set NVIC Group Priority to 4 - Global MSP (MCU Support Package) initialization */ HAL_Init(); /* -1- Initialize LEDs mounted on Discovery board */ BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* -2- Configure the system clock */ SystemClock_Config(); /* -3- Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /*##-1- Initialize the LCD #################################################*/ /* Initialize the LCD */ BSP_LCD_Init(); /* Initialise the LCD Layers */ BSP_LCD_LayerDefaultInit(1, LCD_FRAME_BUFFER); /* Gleich bleibende Einstellenungen am LCD-Display */ /* Set LCD Foreground Layer */ BSP_LCD_SelectLayer(1); BSP_LCD_SetFont(&LCD_DEFAULT_FONT); /* Clear the LCD */ BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_Clear(LCD_COLOR_WHITE); /* Set the LCD Text Color */ BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); /* Display LCD messages */ BSP_LCD_DisplayStringAt(0, 10, (uint8_t*)"GOLF CART", CENTER_MODE); BSP_LCD_SetFont(&Font16); BSP_LCD_DisplayStringAt(0, 35, (uint8_t*)"v in km/h", CENTER_MODE); /* Infinite loop */ while (1) { if (uAenderung) { GeschwindigkeitAufLCD(uAktuelleGeschwindigkeit_zehntelkmh); uAenderung = 0; } } }
int main(void) { /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Generate software interrupt: simulate a rising edge applied on EXTI0 line */ /* GPIOD Periph clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOD, ENABLE); /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode GPIOA_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1; GPIOA_InitStructure.GPIO_Mode = GPIO_Mode_IN; GPIOA_InitStructure.GPIO_OType = GPIO_OType_PP; //GPIOA_InitStructure.GPIO_Speed = GPIO_Speed_2MHz; GPIOA_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIOA_InitStructure);*/ time=100; while (1) { /* while(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)) {time=time+10; Delay (10);} while(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_1)) {if (time>20,time=time-10); else Delay (10);} */ GPIO_SetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_15); Delay (time); GPIO_ResetBits(GPIOD, GPIO_Pin_14|GPIO_Pin_15); Delay (time); } }
/** * @brief Main program * @param None * @retval None */ 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 */ /* Initialize LEDs mounted on STM32F4-Discovery board */ STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Generate software interrupt: simulate a rising edge applied on EXTI0 line */ EXTI_GenerateSWInterrupt(EXTI_Line0); while (1) { } }
int main(void) { ///-----Inicjalizacja funkcji---- SystemInit(); DELAY_Init(); LCD_Init(); DAC_Conf(); EXTILine0_Config(); EXTILine3_Config(); Timer(); LCD_Clear(); LCD_GoTo(0,0); LCD_SendText("Probkowanie co:"); LCD_GoTo(1,0); LCD_SendInt(z); DAC_Cmd(DAC_Channel_1, ENABLE); //wlacz przetwornik while (1) { int timerValue = TIM_GetCounter(TIM2); //sprawdzanie wartosci timera if(timerValue >=z-1) { TIM_ClearITPendingBit(TIM3, TIM_IT_Update); DAC_SetChannel1Data(DAC_Align_12b_R, k); k++; if(k >= 4000) { k=0; } } } }
/** * @brief Main program * @param None * @retval None */ int main(void) { /* This sample code shows how to use STM32F3xx CEC HAL API to transmit and * receive data. The device is set in waiting to receive mode and sends * messages when the evaluation board buttons are pushed by the user */ /* STM32F3xx HAL library initialization: - Configure the Flash prefetch - Systick timer is configured by default as source of time base, but user can eventually implement his proper time base source (a general purpose timer for example or other time source), keeping in mind that Time base duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and handled in milliseconds basis. - Set NVIC Group Priority to 4 - Low Level Initialization */ HAL_Init(); /* Configure the system clock to 72 MHz */ SystemClock_Config(); /* LED and button-triggered interruptions initialization */ /* -1- Initialize LEDs mounted on EVAL board */ BSP_LED_Init(LED1); BSP_LED_Init(LED2); BSP_LED_Init(LED3); BSP_LED_Init(LED4); /* -2- Configure EXTI Line0 (connected to PA0 pin) in Interrupt mode */ /* Do basically the same as BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_EXTI); */ EXTILine0_Config(); /* -3- Configure EXTI Line2 (connected to PA2 pin) in interrupt mode */ /* Do basically the same as BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI); */ EXTILine2_TSC_Config(); /* -4- Configure EXTI Line9-5 (connected to PE6 pin) in interrupt mode */ /* Do basically the same as BSP_PB_Init(BUTTON_SEL, BUTTON_MODE_EXTI); */ EXTILine9_5_Config(); /* -5- Configure EXTI Line15-10 (connected to PF10 pin) in interrupt mode */ /* Do basically the same as BSP_PB_Init(JOY_UP, BUTTON_MODE_EXTI); */ EXTILine15_10_Config(); /* CEC device initialization */ #if defined (DEVICE_1) DestinationAddress = DEVICE_ADDRESS_2; /* follower address */ #elif defined (DEVICE_2) DestinationAddress = DEVICE_ADDRESS_1; /* follower address */ #endif /* -6- CEC configuration (transfer will take place in Interrupt mode) */ hcec.Instance = CEC; /* Deinitialize CEC to reinitialize from scratch */ HAL_CEC_DeInit(&hcec); /* IP configuration */ CEC_Config(&hcec); /* -7- CEC transfer general variables initialization */ ReceivedFrame = 0; StartSending = 0; NbOfReceivedBytes = 0; CEC_FlushRxBuffer(); /* Test start */ /* Enter infinite reception loop: the CEC device is set in * waiting to receive mode. * The CEC "background" state is HAL_CEC_STATE_STANDBY_RX. * Upon any message reception or transmission, the CEC * comes back to that state. * It is up to the user to define exit conditions in modifying * accordingly the RX, TX or Error callback functions. */ HAL_CEC_Receive_IT(&hcec, (uint8_t *)&Tab_Rx); while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY) { /* if no reception has occurred and no error has been detected, * transmit a message if the user has pushed a button */ if( (StartSending == 1) && (ReceivedFrame == 0)) { HAL_CEC_Transmit_IT(&hcec, DestinationAddress, (uint8_t *)&Tab_Tx, TxSize); /* loop until TX ends or TX error reported */ while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_STANDBY_RX); StartSending = 0; } /* if a frame has been received */ if (ReceivedFrame == 1) { if (Tab_Rx[1] == 0x44) /* Test on the opcode value */ { /* Receive command is equal to Volume Up(Button Up) */ if (Tab_Rx[2] == 0x41) /* Test on the operand value */ { BSP_LED_On(LED1); BSP_LED_On(LED2); BSP_LED_On(LED3); BSP_LED_On(LED4); } else if (Tab_Rx[2] == 0x42) /* Receive command is equal to Volume Down(Button Down) */ { BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); } } else if (Tab_Rx[1] == 0x46) /* Test on the opcode value */ { BSP_LED_On(LED1); BSP_LED_On(LED2); BSP_LED_Off(LED3); BSP_LED_Off(LED4); } else if (Tab_Rx[1] == 0x9F) /* Test on the opcode value */ { BSP_LED_Off(LED1); BSP_LED_Off(LED2); BSP_LED_On(LED3); BSP_LED_On(LED4); } ReceivedFrame = 0; } else if (ReceivedFrame == 2) /* means CEC error detected */ { /* Turn on LED3 */ BSP_LED_On(LED3); ReceivedFrame = 0; } } /* while (HAL_CEC_GetState(&hcec) != HAL_CEC_STATE_READY) */ return 0; }
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; } } }
/** * @brief Main program * @param None * @retval None */ 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 */ NVIC_InitTypeDef NVIC_InitStructure; EXTI_InitTypeDef EXTI_InitStructure; LEDGpio_Init(); EXTILine0_Config(); EXTILine6_Config(); uart_init(); /* Output a message on Hyperterminal using printf function */ printf("\n\r *********************** RTC Hardware Calendar Example ***********************\n\r"); if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2) { /* RTC configuration */ RTC_Config(); /* Configure the RTC data register and RTC prescaler */ RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv; RTC_InitStructure.RTC_SynchPrediv = SynchPrediv; RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24; /* Check on RTC init */ if (RTC_Init(&RTC_InitStructure) == ERROR) { printf("\n\r /!\\***** RTC Prescaler Config failed ********/!\\ \n\r"); } /* Configure the time register */ RTC_TimeRegulate(); } else { /* Check if the Power On Reset flag is set */ if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) { printf("\r\n Power On Reset occurred....\n\r"); } /* Check if the Pin Reset flag is set */ else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET) { printf("\r\n External Reset occurred....\n\r"); } printf("\n\r No need to configure RTC....\n\r"); /* Enable the PWR clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); /* Allow access to RTC */ PWR_BackupAccessCmd(ENABLE); /* Wait for RTC APB registers synchronisation */ RTC_WaitForSynchro(); /* Clear the RTC Alarm Flag */ RTC_ClearFlag(RTC_FLAG_ALRAF); /* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */ EXTI_ClearITPendingBit(EXTI_Line17); /* Display the RTC Time and Alarm */ RTC_TimeShow(); RTC_AlarmShow(); } // /* Configure the external interrupt "WAKEUP", "KEY" and "TAMPER" buttons */ // STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); // STM_EVAL_PBInit(BUTTON_TAMPER , BUTTON_MODE_EXTI); // STM_EVAL_PBInit(BUTTON_WAKEUP , BUTTON_MODE_EXTI); // // /* Configure LEDx */ // STM_EVAL_LEDInit(LED1); // STM_EVAL_LEDInit(LED2); // // /* Turn LED1 ON */ // STM_EVAL_LEDOn(LED2); /* RTC Alarm A Interrupt Configuration */ /* EXTI configuration *********************************************************/ EXTI_ClearITPendingBit(EXTI_Line17); EXTI_InitStructure.EXTI_Line = EXTI_Line17; EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure); /* Enable the RTC Alarm Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = RTC_Alarm_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); while (1) { } }
/** * @brief Main program. * @param None * @retval None */ 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 */ /* SysTick end of count event each 10ms */ RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); LIS302DL_Reset(); /* SET USER Key */ /* Configure EXTI Line0 (connected to PA0 pin) in interrupt mode */ EXTILine0_Config(); /* Initialize the LCD */ STM32f4_Discovery_LCD_Init(); LCD_Clear(LCD_COLOR_WHITE); LCD_SetTextColor(LCD_COLOR_BLUE); DCMI_Control_IO_Init(); LCD_DisplayStringLine(LINE(2), " Camera Init.."); /* OV9655 Camera Module configuration */ if (DCMI_OV9655Config() == 0x00) { LCD_DisplayStringLine(LINE(2), " "); LCD_SetDisplayWindow(0, 0, 320, 240); LCD_WriteRAM_Prepare(); /* Start Image capture and Display on the LCD *****************************/ /* Enable DMA transfer */ DMA_Cmd(DMA2_Stream1, ENABLE); /* Enable DCMI interface */ DCMI_Cmd(ENABLE); /* Start Image capture */ DCMI_CaptureCmd(ENABLE); /*init the picture count*/ init_picture_count(); KeyPressFlg = 0; while (1) { /* Insert 100ms delay */ Delay(100); if (KeyPressFlg) { KeyPressFlg = 0; /* press user KEY take a photo */ if (capture_Flag == ENABLE) { DCMI_CaptureCmd(DISABLE); capture_Flag = DISABLE; Capture_Image_TO_Bmp(); LCD_SetDisplayWindow(0, 0, 320, 240); LCD_WriteRAM_Prepare(); DCMI_CaptureCmd(ENABLE); capture_Flag = ENABLE; } } } } else { LCD_SetTextColor(LCD_COLOR_RED); LCD_DisplayStringLine(LINE(2), "Camera Init.. fails"); LCD_DisplayStringLine(LINE(4), "Check the Camera HW "); LCD_DisplayStringLine(LINE(5), " and try again "); /* Go to infinite loop */ while (1); } }