STM32F7xx外设驱动1-led(寄存器)
//源文件 void LedPhyConfig() { RCC->AHB1ENR |= (1<<1); //使能GPIOB //LD1 GPIOB->MODER |= (1<<0*2); //输出模式 GPIOB->OTYPER &= ~(1<<0); //推挽 GPIOB->OSPEEDR |= (1<<0*2); //High speed //LD2 GPIOB->MODER |= (1<<7*2); //输出模式 GPIOB->OTYPER &= ~(1<<7); //推挽 GPIOB->OSPEEDR |= (1<<7*2); //High speed //LD3 GPIOB->MODER |= (1<<14*2); //输出模式 GPIOB->OTYPER &= ~(1<<14); //推挽 GPIOB->OSPEEDR |= (1<<14*2); //High speed LD1_OFF;LD2_OFF;LD3_OFF; } //头文件 /***************************** LED*************************************/ #define LD1_ON (GPIOB->ODR |= (1<<0)) #define LD1_OFF (GPIOB->ODR &= ~(1<<0)) #define LD1_TURN (GPIOB->IDR &(1<<0)?LD1_OFF:LD1_ON) #define LD2_ON (GPIOB->ODR |= (1<<7)) #define LD2_OFF (GPIOB->ODR &= ~(1<<7)) #define LD2_TURN (GPIOB->IDR &(1<<7)?LD2_OFF:LD2_ON) #define LD3_ON (GPIOB->ODR |= (1<<14)) #define LD3_OFF (GPIOB->ODR &= ~(1<<14)) #define LD3_TURN (GPIOB->IDR &(1<<14)?LD3_OFF:LD3_ON) void LedPhyConfig(void); /**********************************************************************/