我试图在按下用户按钮时打开 LED
我想我已经启用了正确的外围时钟和正确的寄存器。按钮位于端口位 0
这是我的代码......任何帮助都会很棒。对不起,如果它有点简单,我还在学习董事会。
int main (void)
{
RCC->AHB1ENR=0x9;
GPIOA->MODER = 0x00000002;
GPIOD->MODER = 0x55000000;
GPIOD->OTYPER = 0;
GPIOD->OSPEEDR = 0;
GPIOD->PUPDR = 0;
GPIOA->PUPDR = 0;
GPIOA->OTYPER = 0;
GPIOA->OSPEEDR = 0;
while(1)
{
if(GPIOA->IDR == 0x0001){
GPIOD->ODR = 0xF000;
}
else{
GPIOD->ODR = 0;
}
}
}