|
- #include "stm32f10x.h" //STM32頭文件
- #include "sys.h"
- #include "delay.h"
- #include "led.h"
- int main (void){//主程序
- RCC_Configuration(); //時(shí)鐘設(shè)置
- LED_Init();
- while(1){
-
- //方法1:
- GPIO_WriteBit(LEDPORT,LED1,(BitAction)(0)); //LED1接口輸出高電平1
- // GPIO_WriteBit(LEDPORT,LED1,(BitAction)(0)); //LED1接口輸出低電平0
-
-
- //方法2:
- // GPIO_WriteBit(LEDPORT,LED1,(BitAction)(1-GPIO_ReadOutputDataBit(LEDPORT,LED1))); //取反LED1
- // delay_ms(500); //延時(shí)1秒
- //方法3:
- // GPIO_SetBits(LEDPORT,LED1); //LED燈都為高電平(1)
- // delay_s(1); //延時(shí)1秒
- // GPIO_ResetBits(LEDPORT,LED1); //LED燈都為低電平(0)
- // delay_s(1); //延時(shí)1秒
- //方法4
- // GPIO_Write(LEDPORT,0x0001); //直接數(shù)值操作將變量值寫(xiě)入LED
- // delay_s(2); //延時(shí)1秒
- // GPIO_Write(LEDPORT,0x0000); //直接數(shù)值操作將變量值寫(xiě)入LED
- // delay_s(2); //延時(shí)1秒
- }
- }
- 【變量定義】
- u32 a; //定義32位無(wú)符號(hào)變量a
- u16 a; //定義16位無(wú)符號(hào)變量a
- u8 a; //定義8位無(wú)符號(hào)變量a
- vu32 a; //定義易變的32位無(wú)符號(hào)變量a
- vu16 a; //定義易變的 16位無(wú)符號(hào)變量a
- vu8 a; //定義易變的 8位無(wú)符號(hào)變量a
- uc32 a; //定義只讀的32位無(wú)符號(hào)變量a
- uc16 a; //定義只讀 的16位無(wú)符號(hào)變量a
- uc8 a; //定義只讀 的8位無(wú)符號(hào)變量a
- #define ONE 1 //宏定義
- delay_us(1); //延時(shí)1微秒
- delay_ms(1); //延時(shí)1毫秒
- delay_s(1); //延時(shí)1秒
- */
復(fù)制代碼
|
|