/* * Read switches and use the data to set LEDs of the EduBase board. * * The four LEDs are: * LED3 - PB7 * LED2 - PB6 * LED1 - PB5 * LED0 - PB4 * * The four switches are: * SW2 - PC11 * SW3 - PC10 * SW4 - PC9 * SW5 - PC8 */ #include "stm32f4xx.h" void delayMs(int n); int main(void) { RCC->AHB1ENR |= 2; /* enable GPIOB clock */ RCC->AHB1ENR |= 4; /* enable GPIOC clock */ GPIOB->MODER &= ~0x0000ff00; /* clear pin mode */ GPIOB->MODER |= 0x00005500; /* set pins to output mode */ GPIOC->MODER &= ~0x00FF0000; /* clear pin mode */ while (1) { /* Read port C bits 11-8, shift them 4 bit right, * write them to port B bits 7-4. */ GPIOB->ODR = GPIOC->IDR >> 4; } }