#include "stm32f4xx.h" #define LED1_PIN 10 #define LED2_PIN 11 #define LED3_PIN 12 #define LED4_PIN 13 #define LED_COMMON 1 // Anode: 1, catode: 0 __attribute__((optimize("O0"))) void delay(volatile int cnt) { while(cnt--); } int main(void) { RCC->AHB1ENR |= RCC_AHB1ENR_GPIOCEN; GPIOC->MODER |= (1U << (LED1_PIN * 2)); GPIOC->MODER |= (1U << (LED2_PIN * 2)); GPIOC->MODER |= (1U << (LED3_PIN * 2)); GPIOC->MODER |= (1U << (LED4_PIN * 2)); GPIOC->ODR |= (1U << LED4_PIN); while (1) { GPIOC->ODR ^= (1U << LED4_PIN) | (1U << LED1_PIN); delay(500000); GPIOC->ODR ^= (1U << LED1_PIN) | (1U << LED2_PIN); delay(500000); GPIOC->ODR ^= (1U << LED2_PIN) | (1U << LED3_PIN); delay(500000); GPIOC->ODR ^= (1U << LED3_PIN) | (1U << LED4_PIN); delay(500000); } }