#include "stm32f1xx.h"
int main(void) {
stmInit();
while (1) {
GPIOA->BSRR = (!(GPIOA->IDR & (1 << 2))) ? (1 << 3) : (1 << (3 + 16));
}
}
void stmInit(){
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN;
GPIOA->CRL &= ~(GPIO_CRL_MODE2 | GPIO_CRL_CNF2);
GPIOA->CRL |= (GPIO_CRL_CNF2_1);
GPIOA->ODR |= (1 << 2);
GPIOA->CRL &= ~(GPIO_CRL_MODE3 | GPIO_CRL_CNF3);
GPIOA->CRL |= (GPIO_CRL_MODE3_0);
}
Loading
stm32-bluepill
stm32-bluepill