野火STM32学习(6)
生活随笔
收集整理的這篇文章主要介紹了
野火STM32学习(6)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
編寫置位/復位函數
#ifndef __STM32F4XX_GPIO_H #define __STM32F4XX_GPIO_H#include "stm32f4xx.h"#define GPIO_Pin_0 (1<<0) #define GPIO_Pin_1 (1<<1) #define GPIO_Pin_2 (1<<2) #define GPIO_Pin_3 (1<<3) #define GPIO_Pin_4 (1<<4) #define GPIO_Pin_5 (1<<5) #define GPIO_Pin_6 (1<<6) #define GPIO_Pin_7 (1<<7) #define GPIO_Pin_8 (1<<8) #define GPIO_Pin_9 (1<<9) #define GPIO_Pin_10 (1<<10) #define GPIO_Pin_11 (1<<11) #define GPIO_Pin_12 (1<<12) #define GPIO_Pin_13 (1<<13) #define GPIO_Pin_14 (1<<14) #define GPIO_Pin_15 (1<<15)void GPIO_SetBits( GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin ); void GPIO_ResetBits( GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin );#endif /* __STM32F4XX_GPIO_H */ #include "stm32f4xx_gpio.h"void GPIO_SetBits( GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin ){GPIOx->BSRRL = GPIO_Pin;}void GPIO_ResetBits( GPIO_TypeDef * GPIOx , uint16_t GPIO_Pin ){GPIOx->BSRRH = GPIO_Pin;} #include "stm32f4xx.h" #include "stm32f4xx_gpio.h"int main(void){/* 打開GPIOE的時鐘 */RCC_AHB1ENR |= (1<<4); //寫入1/* GPIOE配置為輸出 */GPIOE->MODER &= ~(0X03<<(2*3)); //清0GPIOE->MODER |= (0X01<<(2*3)); //寫入1/* PE3輸出低電平 */GPIO_ResetBits(GPIOE, GPIO_Pin_3); }void SystemInit(void){}置位/復位函數實際上與操作ODR寄存器相似,置位寫1,復位寫0
總結
以上是生活随笔為你收集整理的野火STM32学习(6)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AsciiDoc 相关资源
- 下一篇: 雾里看花 QingCloud AppCe