首页 > 其他分享 >STM32F6xx外设驱动1-led(寄存器)nulceo144

STM32F6xx外设驱动1-led(寄存器)nulceo144

时间:2022-11-12 11:44:42浏览次数:59  
标签:led 1OSPEEDR 1ODR 1MODER 1OTYPER 1IDR nulceo144 STM32F6xx

//源文件
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);
/**********************************************************************/

  

标签:led,1OSPEEDR,1ODR,1MODER,1OTYPER,1IDR,nulceo144,STM32F6xx
From: https://www.cnblogs.com/lum0126/p/16883373.html

相关文章