写了一个枚举的简答测试例子:
#include<stdio.h>
typedef enum
{
LED1 = 1,
LED2 = 2,
LED3 = 3
}led_TypeDef;
//LED点亮函数
void LED_ON(led_TypeDef led)
{
switch(led)
{
case LED1:
printf("this is LED1 is on\r\n");
return;
case LED2:
printf("this is LED2 is on\r\n");
return;
case LED3:
printf("this is LED3 is on\r\n");
return;
}
}
//LED熄灭函数
void LED_OFF(led_TypeDef led)
{
switch(led)
{
case LED1:
printf("this is LED1 is off\r\n");
return;
case LED2:
printf("this is LED2 is off\r\n");
return;
case LED3:
printf("this is LED3 is off\r\n");
return;
}
}
int main(int argc,char*argv[])
{
LED_ON(LED2);
while(1);
}
|