Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stm32f4xx.h"
- #include "stm32f4xx_gpio.h"
- #include "stm32f4xx_rcc.h"
- void init()
- {
- GPIO_InitTypeDef GPIO_InitStruct;
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
- GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
- GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT; // we want the pins to be an output
- GPIO_InitStruct.GPIO_Speed = GPIO_Speed_100MHz; // this sets the GPIO modules clock speed
- GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; // this sets the pin type to push / pull (as opposed to open drain)
- GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; // this sets the pullup / pulldown resistors to be inactive
- GPIO_Init(GPIOA, &GPIO_InitStruct);
- }
- void blink()
- {
- GPIOA->ODR++;
- }
- void main()
- {
- init();
- while(1)
- {
- blink();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement