/** * @brief Main program. * @param None * @retval None */ int main( void ) { /* At this stage the microcontroller clock setting is already configured to 120 MHz, this is done through SystemInit() function which is called from startup file (startup_stm32f2xx.S) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f2xx.c file */ /* USART Configuration */ DebugComPort_Init(); /* Initialize buttons */ STM_EVAL_PBInit( BUTTON_WAKEUP, BUTTON_MODE_EXTI ); STM_EVAL_PBInit( BUTTON_TAMPER, BUTTON_MODE_EXTI ); STM_EVAL_PBInit( BUTTON_KEY , BUTTON_MODE_EXTI ); STM_EVAL_PBInit( BUTTON_RIGHT , BUTTON_MODE_EXTI ); /* Initialize SPI */ STM_EVAL_SPI_Init(); printf("\ntest tracing from embedded code\n"); /* Handle buttons */ xTaskCreate( HandleButtons_task, (const signed char* const)"BTN", configMINIMAL_STACK_SIZE, NULL, BTN_TASK_PRIO, NULL ); /* Start scheduler */ vTaskStartScheduler(); /* We should never get here as control is now taken by the scheduler */ for(;;); }
static void prvSetupHardware( void ) { /* Ensure that all 4 interrupt priority bits are used as the pre-emption priority. */ NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); /* Initialise the LEDs. */ vParTestInitialise(); /* Initialise the joystick inputs. */ STM_EVAL_PBInit( BUTTON_UP, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_DOWN, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_LEFT, BUTTON_MODE_GPIO ); STM_EVAL_PBInit( BUTTON_RIGHT, BUTTON_MODE_GPIO ); /* The select button in the middle of the joystick is configured to generate an interrupt. The Eval board library will configure the interrupt priority to be the lowest priority available so the priority need not be set here explicitly. It is important that the priority is equal to or below that set by the configMAX_SYSCALL_INTERRUPT_PRIORITY value set in FreeRTOSConfig.h. */ STM_EVAL_PBInit( BUTTON_SEL, BUTTON_MODE_EXTI ); /* Initialize the LCD */ STM32L152_LCD_Init(); LCD_Clear( Blue ); LCD_SetBackColor( Blue ); LCD_SetTextColor( White ); LCD_DisplayStringLine( Line0, " www.FreeRTOS.org" ); }
/** * @brief This function configures the system to enter Stop mode for * current consumption measurement purpose. * STOP Mode * ========= * - Regulator in LP mode * - LSI, HSI and HSE OFF * - No IWDG * - Current Consumption ~0.5uA * - Wakeup using EXTI Line (Key Button PA.00) * @param None * @retval None */ void StopMode_Measure(void) { /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOH | RCC_AHBPeriph_GPIOF | RCC_AHBPeriph_GPIOG, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOH, &GPIO_InitStructure); GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); /* Disable GPIOs clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOH | RCC_AHBPeriph_GPIOF | RCC_AHBPeriph_GPIOG, DISABLE); /* Configure Key Button*/ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); /* Wait Until Key button pressed */ while(STM_EVAL_PBGetState(BUTTON_KEY) == RESET) { } /* Wait Until Key button pressed */ while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET) { } /* Configure Key Button*/ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); /* Enable Ultra low power mode */ PWR_UltraLowPowerCmd(ENABLE); /* Enter Stop Mode */ PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI); /* Initialize LED1 on STM32L152-EVAL board */ STM_EVAL_LEDInit(LED1); /* Infinite loop */ while (1) { /* Toggle The LED1 */ STM_EVAL_LEDToggle(LED1); /* Inserted Delay */ for(index = 0; index < 0x5FF; index++); } }
void STM_EVAL_JOYInit(void) { STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_GPIO); }
/** * @brief Main program. * @param None * @retval None */ void main(void) { /* CLK configuration -------------------------------------------*/ CLK_Config(); /* Init TIM2 to generate 1 ms time base update interrupt */ TimingDelay_Init(); /* Enable Interrupts */ enableInterrupts(); /* Initialize LEDs mounted on STM8L152X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Turn on LED1 and LED3 */ STM_EVAL_LEDOn(LED1); STM_EVAL_LEDOn(LED3); /* Initialize push-buttons mounted on STM8L152X-EVAL board */ STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI); /* Init the Eval board LCD */ STM8_EVAL_LCD_Init(); /* Clear LCD */ LCD_Clear(); /* Enable general interrupts */ enableInterrupts(); LCD_SetCursorPos(LCD_LINE1, 0); LCD_Print(" System Clock "); LCD_SetCursorPos(LCD_LINE2, 0); LCD_Print(" Source: HSE "); while (1) { /* Toggle LED2 and LED4 */ STM_EVAL_LEDToggle(LED2); STM_EVAL_LEDToggle(LED4); /* Insert a delay */ Delay(10); /* Toggle LED1 and LED3 */ STM_EVAL_LEDToggle(LED1); STM_EVAL_LEDToggle(LED3); /* Insert a delay */ Delay(10); } }
/** * @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. */ /* Initialize the LCD */ LCD_Init(); /* Clear the LCD */ LCD_Clear(White); /* Set the LCD Back Color */ LCD_SetBackColor(Blue); /* Set the LCD Text Color */ LCD_SetTextColor(White); /* Displays MESSAGE1 on line 0 */ LCD_DisplayStringLine(LINE(0), (uint8_t *)MESSAGE1); /* RTC configuration */ RTC_Config(); /* Set the LCD Text Color */ LCD_SetTextColor(Red); /* Displays a rectangle on the LCD */ LCD_DrawRect(80, 290, 25, 240 ); /* Configure the external interrupt "KEY", "WAKEUP" and "TAMPER" buttons */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI); /* Configure RTC alarm A register to generate 8 interrupts per 1 Second */ RTC_AlarmConfig(); /* set LCD Font */ LCD_SetFont(&Font12x12); /* Set the LCD Back Color */ LCD_SetBackColor(White); /* Set the LCD Text Color */ LCD_SetTextColor(Black); /* Displays MESSAGE2 and MESSAGE3 on the LCD */ LCD_DisplayStringLine(LINE(18), (uint8_t *)MESSAGE2); LCD_DisplayStringLine(LINE(19), (uint8_t *)MESSAGE3); /* Infinite loop */ while (1) {} }
/** * @brief Main program. * @param None * @retval None */ void main(void) { /* Initialize LED1 and LED2 mounted on STM8L152X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); /* Initialize Key and Joystick down push-buttons mounted on STM8L152X-EVAL board */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI); /* enable interrupts */ enableInterrupts(); /* Check if the MCU has resumed from WWDG reset */ if (RST_GetFlagStatus(RST_FLAG_WWDGF) != RESET) { /* WWDGF flag set */ /* Toggle LED1 */ for (Index = 7; Index != 0; Index--) { STM_EVAL_LEDToggle(LED1); Delay(0x7FFF); } /* Clear WWDGF Flag */ RST_ClearFlag(RST_FLAG_WWDGF); } /* WWDG Configuration */ WWDG_Config(); while (1) { /* Check if WWDG counter refresh is allowed in Allowed window */ if (AllowedRefresh != DISABLE) { /* get WWDG counter value */ /* wait until WWDG counter becomes lower than window value */ while ((WWDG_GetCounter() & 0x7F) > WINDOW_VALUE); /* Refresh WWDG counter during allowed window so no MCU reset will occur */ WWDG_SetCounter(COUNTER_INIT); } /* Check if WWDG counter refresh is allowed in non Allowed window */ if (NonAlowedRefresh != DISABLE) { /* wait until WWDG counter becomes higher than window value */ while ((WWDG_GetCounter() & 0x7F) < WINDOW_VALUE); /* Refresh WWDG counter during non allowed window so MCU reset will occur */ WWDG_SetCounter(COUNTER_INIT); } /* Toggle LED2 */ STM_EVAL_LEDToggle(LED2); Delay(0x6FFF); } }
/** * @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_stm32l1xx_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32l1xx.c file */ /* Initialize Leds mounted on STM32L1xx-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Initialize the KEY and SEL buttons mounted on STM32L1xx-EVAL board */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_EXTI); /* TIM configuration -------------------------------------------------------*/ TIM_Config(); while (1) { /* Wait until KEY button is pressed. */ while(STM_EVAL_PBGetState(BUTTON_KEY) == RESET) { } while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET) { } /* This instruction raises the execution priority to 0. This prevents all exceptions with configurable priority from activating, other than through the HardFault fault escalation mechanism. */ __disable_irq(); /* Turn LED4 ON */ STM_EVAL_LEDOn(LED4); /* Wait until KEY button is pressed. */ while(STM_EVAL_PBGetState(BUTTON_KEY) == RESET) { } while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET) { } /* This instruction will allow all exceptions with configurable priority to be activated. */ __enable_irq(); /* Turn LED4 OFF */ STM_EVAL_LEDOff(LED4); } }
/** * @brief Configure GPIO for buttons available on the evaluation board * @param None * @retval None */ static void GPIO_Config(void) { /* Configure GPIO used to drive the joystick JOYSTICK_UP --> PB6 JOYSTICK_DOWN --> PB7 JOYSTICK_RIGHT --> PB5 */ STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_EXTI); }
/** * @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 */ /* NVIC configuration ------------------------------------------------------*/ NVIC_Config(); /* Initialize LEDs mounted on EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); /* Initialize the KEY/Tamper and Wakeup buttons mounted on EVAL board */ STM_EVAL_PBInit(BUTTON_KEY_TAMPER, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI); /* Configure the SysTick Handler Priority: Preemption priority and subpriority */ NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !ubPreemptionPriorityValue, 0)); while (1) { if(ubPreemptionOccurred != 0) { /* Toggle LED1 */ STM_EVAL_LEDToggle(LED1); /* Insert delay Time */ Delay(0x5FFFF); /* Toggle LED2 */ STM_EVAL_LEDToggle(LED2); Delay(0x5FFFF); /* Toggle LED3 */ STM_EVAL_LEDToggle(LED3); Delay(0x5FFFF); /* Toggle LED4 */ STM_EVAL_LEDToggle(LED4); Delay(0x5FFFF); } } }
/** * @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_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ /* Initialize LED1..LED4, Key and Wakeup Buttons mounted on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI); /* Configure one bit for preemption priority */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1); /* Enable the WAKEUP_BUTTON_EXTI_IRQn Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = WAKEUP_BUTTON_EXTI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PreemptionPriorityValue; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Enable the KEY_BUTTON_EXTI_IRQn Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = KEY_BUTTON_EXTI_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /* Configure the SysTick Handler Priority: Preemption priority and subpriority */ NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !PreemptionPriorityValue, 0)); while (1) { if(PreemptionOccured != FALSE) { STM_EVAL_LEDToggle(LED1); Delay(0x5FFFF); STM_EVAL_LEDToggle(LED2); Delay(0x5FFFF); STM_EVAL_LEDToggle(LED3); Delay(0x5FFFF); STM_EVAL_LEDToggle(LED4); Delay(0x5FFFF); } } }
/** * @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_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ /* NVIC configuration ------------------------------------------------------*/ NVIC_Config(); /* Initialize LED1..LED4, Key and Sel Joystick Buttons mounted on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); STM_EVAL_PBInit(BUTTON_WAKEUP, BUTTON_MODE_EXTI); /* Configure the SysTick Handler Priority: Preemption priority and subpriority */ NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), !PreemptionPriorityValue, 0)); while (1) { if(PreemptionOccured != 0) { /* Toggel The lED1 */ STM_EVAL_LEDToggle(LED1); /* Insert delay Time */ Delay(0x5FFFF); STM_EVAL_LEDToggle(LED2); Delay(0x5FFFF); STM_EVAL_LEDToggle(LED3); Delay(0x5FFFF); STM_EVAL_LEDToggle(LED4); Delay(0x5FFFF); } } }
/** * @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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* LCD Display init */ Display_Init(); /* Key button and Tamper button configuration */ #ifdef USE_STM320518_EVAL STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); #else STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO); #endif /* USE_STM320518_EVAL */ /* Configures LED1 GPIO */ STM_EVAL_LEDInit(LED1); /* Configure ADC1 */ ADC_Config(); /* Configure TIM3 */ TIM_Config(); /* Infinite loop */ while (1) { /* Press Key button for STM320518_EVAL and Tamper button for STM32072B_EVAL to get the converted data */ #ifdef USE_STM320518_EVAL while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET); #else while(STM_EVAL_PBGetState(BUTTON_TAMPER) != RESET); #endif /* USE_STM320518_EVAL */ /* Get ADC1 converted data */ ADC1ConvertedValue =ADC_GetConversionValue(ADC1); /* Compute the voltage */ ADC1ConvertedVoltage = (ADC1ConvertedValue *3300)/0xFFF; /* Display converted data on the LCD */ Display(); } }
/** * @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); /* Initialize Key Button mounted on EVAL board */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); /* RTC configuration */ RTC_Config(); /* Turn on LED1 */ STM_EVAL_LEDOn(LED1); /* Enable WKUP pin */ PWR_WakeUpPinCmd(ENABLE); /* Configure the SysTick to generate an interrupt each 250 ms */ SysTick_Configuration(); while (1) { } }
/** @brief button interrupt initialization */ void pushbutton_init (void) { /* Initialize USER Buttons with interrupt capability */ // Pressing the button causes an interrupt STM_EVAL_PBInit (BUTTON_USER, BUTTON_MODE_EXTI); }
int main( void ) { #ifdef DEBUG //debug(); #endif prvSetupHardware(); /* Initialize LEDs and User Button available on STM32F3-Discovery board */ STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); STM_EVAL_LEDInit(LED7); STM_EVAL_LEDInit(LED8); STM_EVAL_LEDInit(LED9); STM_EVAL_LEDInit(LED10); STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI); xTaskCreate( DemoTask, ( signed char * ) "demo", configMINIMAL_STACK_SIZE * 2, NULL, 0, NULL ); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ for( ;; ); }
int main(void) { RCC_ClocksTypeDef RCC_Clocks; /* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/ STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 10); USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &VIDEO_cb, &USR_cb); 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_stm32f10x_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f10x.c file */ /* Initialize LED1 and Key Button mounted on STM3210X-EVAL board */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); /* Check if the system has resumed from WWDG reset */ if (RCC_GetFlagStatus(RCC_FLAG_WWDGRST) != RESET) { /* WWDGRST flag set */ /* Turn on LED1 */ STM_EVAL_LEDOn(LED1); /* Clear reset flags */ RCC_ClearFlag(); } else { /* WWDGRST flag is not set */ /* Turn off LED1 */ STM_EVAL_LEDOff(LED1); } /* NVIC configuration */ NVIC_Configuration(); /* WWDG configuration */ /* Enable WWDG clock */ RCC_APB1PeriphClockCmd(RCC_APB1Periph_WWDG, ENABLE); /* On Value line devices, WWDG clock counter = (PCLK1 (24MHz)/4096)/8 = 732 Hz (~1366 æs) */ /* On other devices, WWDG clock counter = (PCLK1(36MHz)/4096)/8 = 1099 Hz (~910 æs) */ WWDG_SetPrescaler(WWDG_Prescaler_8); /* Set Window value to 65 */ WWDG_SetWindowValue(65); /* On Value line devices, Enable WWDG and set counter value to 127, WWDG timeout = ~1366 æs * 64 = 87.42 ms */ /* On other devices, Enable WWDG and set counter value to 127, WWDG timeout = ~910 æs * 64 = 58.25 ms */ WWDG_Enable(127); /* Clear EWI flag */ WWDG_ClearFlag(); /* Enable EW interrupt */ WWDG_EnableIT(); 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_stm32l1xx_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32l1xx.c file */ /* LCD GLASS Configuration */ LCD_Glass_Config(); /* ADC1 configuration: channel (18 or 31) and channel (5 or 1b) */ ADC_Config(); /* Configure the STM32L1XX-EVAL KEY Push button */ STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI); #ifdef USE_STM32L152D_EVAL /* Set VALUEUNIT_MILLIAMPERE */ LCD_GLASS_ValueUnitConfig(VALUEUNIT_MILLIAMPERE); #endif /* TIM2 Configuration */ TIM2_Config(); /* Request LCD RAM update */ LCD_UpdateDisplayRequest(); 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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* Configure LED3 */ STM_EVAL_LEDInit(LED3); /* Configure Systick */ SysTick_Configuration(); /* Turn ON LED3 */ STM_EVAL_LEDOn(LED3); /* Configures User button */ STM_EVAL_PBInit(BUTTON_USER,BUTTON_MODE_GPIO); /* Configure RTC clock source and prescaler */ RTC_Config(); /* Wait till User button is pressed */ while(STM_EVAL_PBGetState(BUTTON_USER) == RESET); /* Enter STANDBY mode, RTC Alarm within 3 second or an external RESET will wake-up the system from STANDBY */ EnterSTANDBYMode(); while(1) {} }
/*-----------------------------------------------------------*/ void prvSetupHardware(void) { // Set the Vector Table base address at 0x08000000 NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); // Configure LED IOs as output push-pull // Initialize LEDs on STM32F4_Discovery board prvLED_Config(GPIO); // Configure User button pin (PA0) as external interrupt -> modes switching STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI); // LCD pin init //prvLCD_Config(); // Initialize LCD LED PWM. Timer initialization included //prvLCDLED_Config(); // Keyboard init with interupts //prvKeyboard_Config(); /* //Set pins for communication with external chips prvADC_GPIO_Config(); //i2c prvPGA_GPIO_Config(); //spi //Translator Output Enable conf and set it to 'enable' prvSerialOE_Config(); */ // Configure LIS302 in order to produce data used for TIM4 reconfiguration and LED control // prvMEMS_Config(); }
static void init(void) { STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); r3dfb_init(); LCD_SetColors(0x0000, 0xffff); LCD_SetFont(&Font8x8); itoa(meshes[mesh].count / 3, info_str, 10); strcat(info_str, " tris"); r3d_viewport(1, 1, R3DFB_PIXEL_WIDTH - 1, R3DFB_PIXEL_HEIGHT - 1); r3d_backface_culling = R3D_ENABLE; r3d_primitive_winding = windings[mesh]; projection = mat4_perspective(60.0f, (float)R3DFB_PIXEL_WIDTH / (float)R3DFB_PIXEL_HEIGHT, 0.5f, 5.0f); view = mat4_lookat(vec3(0.0f, 0.25f, 1.5f), vec3(0.0f, 0.0f, 0.0f), vec3(0.0f, 1.0f, 0.0f)); L3GD20_InitTypeDef L3GD20_InitStructure; L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE; L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1; L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE; L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4; L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous; L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB; L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_250; L3GD20_Init(&L3GD20_InitStructure); L3GD20_FilterConfigTypeDef L3GD20_FilterStructure; L3GD20_FilterStructure.HighPassFilter_Mode_Selection = L3GD20_HPM_NORMAL_MODE_RES; L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0; L3GD20_FilterConfig(&L3GD20_FilterStructure); L3GD20_FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE); }
/** * @brief USBH_USR_Init * Displays the message on LCD for host lib initialization * @param None * @retval None */ void USBH_USR_Init(void) { static uint8_t startup = 0; if(startup == 0 ) { startup = 1; /* Configure the LEDs */ STM_EVAL_LEDInit(LED1); STM_EVAL_LEDInit(LED2); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED4); STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); #ifdef USE_STM3210C_EVAL STM3210C_LCD_Init(); #else STM322xG_LCD_Init(); #endif LCD_LOG_Init(); #ifdef USE_USB_OTG_HS LCD_LOG_SetHeader(" USB OTG HS HID Host"); #else LCD_LOG_SetHeader(" USB OTG FS HID Host"); #endif LCD_UsrLog("> USB Host library started.\n"); LCD_LOG_SetFooter (" USB Host Library v2.0.0" ); } }
/** * @brief This function configures the system to enter Standby mode for * current consumption measurement purpose. * STANDBY Mode * ============ * - IWDG and LSI OFF * - Current Consumption ~0.3uA * - Wakeup using WakeUp Pin 1 (PA.00) * @param None * @retval None */ void StandbyMode_Measure(void) { /* Configure Key Button*/ STM_EVAL_PBInit(BUTTON_KEY,BUTTON_MODE_GPIO); /* Wait Until Key button pressed */ while(STM_EVAL_PBGetState(BUTTON_KEY) == RESET) { } /* Wait Until Key button pressed */ while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET) { } /* Enable Ultra low power mode */ PWR_UltraLowPowerCmd(ENABLE); /* Clear PWR WakeUp flag */ PWR_ClearFlag(PWR_FLAG_WU); /* Enable WKUP pin 1 */ PWR_WakeUpPinCmd(PWR_WakeUpPin_1, ENABLE); /* Request to enter STANDBY mode */ PWR_EnterSTANDBYMode(); /* Infinite loop */ 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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* I2S peripheral Configuration */ I2S_Config(); /* Enable the Tamper button */ STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO); /* Initialize the LEDs */ STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED1); #if defined (I2S_MASTER_TRANSMITTER) while (STM_EVAL_PBGetState(BUTTON_TAMPER) != RESET) {} /* Enable the I2S1 TX Interrupt */ SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE); /* Enable the I2S */ I2S_Cmd(SPI1, ENABLE); while(TxIdx < 32); #elif defined (I2S_SLAVE_RECEIVER) /* Enable the I2S1 RXNE Interrupt */ SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_RXNE, ENABLE); /* Enable the I2S */ I2S_Cmd(SPI1, ENABLE); /* Wait the end of communication */ while (RxIdx < 32); /* Check if the data transmitted from Master Board and received by Slave Board are the same */ TransferStatus = Buffercmp(I2S_Buffer_Rx, (uint16_t*)I2S_Buffer_Tx, 32); if (TransferStatus == PASSED) /* successful transfer */ { /* Green Led On */ STM_EVAL_LEDOn(LED1); STM_EVAL_LEDOff(LED3); } else /* unsuccessful transfer */ { /* Red Led On */ STM_EVAL_LEDOn(LED3); STM_EVAL_LEDOff(LED1); } #endif /* Infinite loop */ while (1) {} }
int main(void) { RCC_ClocksTypeDef RCC_Clocks; /* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/ STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO); STM_EVAL_LEDInit(LED4); STM_EVAL_LEDInit(LED3); STM_EVAL_LEDInit(LED5); STM_EVAL_LEDInit(LED6); RCC_GetClocksFreq(&RCC_Clocks);//test EVAL_AUDIO_Init(OUTPUT_DEVICE_HEADPHONE, 86, I2S_AudioFreq_16k);//init speaker (optional) USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &AUDIO_cb, &USR_cb); simple_rec_start();//initialise MIC and start capture data from MIC EVAL_AUDIO_Play((uint16_t*)(&audiodata[0]),MIC_FILTER_RESULT_LENGTH*2*2);//play data to speaker (optional) while(1) { asm("nop"); } }
int main(void) { SysTick_Config(SystemCoreClock/1000); STM_EVAL_LEDInit(LED3); // Oranzova STM_EVAL_LEDInit(LED4); // Zelena STM_EVAL_LEDInit(LED5); // Cervena STM_EVAL_LEDInit(LED6); // Modra STM_EVAL_LEDOn(LEDG); Delay(1000); STM_EVAL_LEDOff(LEDG); Init_Measure(); Init_Comunication(); init_output(); timer_init(); STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI); USART_SendString(USART6, "\nSwitching Power Source Welcome\n"); while(1) { if((Time-Last_Blink > 75) && output){ STM_EVAL_LEDToggle(LEDB); Last_Blink=Time; }else if(Time-Last_Blink > 75){ STM_EVAL_LEDOn(LEDB); } loop++; f = loop/(Time/1000); } }
/** * @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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* Configure Systick */ SysTick_Configuration(); /* Configures the KEY button */ STM_EVAL_PBInit(BUTTON_KEY,BUTTON_MODE_GPIO); /* Configure LED3 */ STM_EVAL_LEDInit(LED3); while(STM_EVAL_PBGetState(BUTTON_KEY) != RESET); /* Configure RTC clock source and prescaler */ RTC_Config(); 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_stm32f0xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ /* Initialize Led and KEY Button mounted on STM320518-EVAL */ STM_EVAL_LEDInit(LED3); STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI); while (1) { if(LowPowerMode == 1) { /* Turn Off LED3 */ STM_EVAL_LEDOff(LED3); /* Request to enter WFI mode */ __WFI(); LowPowerMode = 0; } Delay(0xFFFFF); STM_EVAL_LEDToggle(LED3); } }
/*-----------------------------------------------------------*/ void prvSetupHardware( void ) { /* Set the Vector Table base address at 0x08000000 */ NVIC_SetVectorTable( NVIC_VectTab_FLASH, 0x0 ); NVIC_PriorityGroupConfig( NVIC_PriorityGroup_4 ); /* Configure LED IOs as output push-pull */ /* Initialize LEDs on STM32F4_Discovery board */ //prvLED_Config(GPIO); /* Configure User button pin (PA0) as external interrupt -> modes switching */ STM_EVAL_PBInit(BUTTON_USER,BUTTON_MODE_EXTI); /* Configuration of Timer4 to control LEDs based on MEMS data */ //prvTIM4_Config(); /* Configure LIS302 in order to produce data used for TIM4 reconfiguration and LED control */ prvMEMS_Config(); RCC_Configuration(); GPIO_Configuration(); TIM_Configuration(); USART_Configuration(); prvGRYO_Config(); }