Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f4_discovery.h"
- /**
- * @brief Main program
- * @param None
- * @retval None
- */
- int main(void){
- //Start the device clock
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
- //Init the Device Structure
- GPIO_InitTypeDef leds;
- leds.GPIO_Pin = 0xF000;
- leds.GPIO_Mode = GPIO_Mode_OUT;
- leds.GPIO_Speed = GPIO_Speed_2MHz;
- leds.GPIO_OType = GPIO_OType_PP;
- leds.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOD, &leds);
- //Start the device(= button) clock
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
- //Init the device(=button) structure
- GPIO_InitTypeDef button;
- button.GPIO_Pin = GPIO_Pin_0;
- button.GPIO_Mode = GPIO_Mode_IN;
- button.GPIO_Speed = GPIO_Speed_2MHz;
- button.GPIO_OType = GPIO_OType_PP;
- button.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOD, &button);
- //Delay util
- volatile uint32_t d = 0x01000000;
- //Temper calc
- volatile uint16_t calc = (uint16_t)1;
- while (1){
- if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_0)){
- GPIO_ResetBits(GPIOD, 0xF000);
- GPIO_SetBits(GPIOD, GPIO_Pin_12*calc);
- while(d--);
- d = 0x01000000;
- calc *= 2;
- }
- if(calc>9) calc = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement