📄 led.c
字号:
/********************************************************************************\
\* MyLed.c V1.00 *\
\* Copyright 2004 by ThinkIT. *\
\* All rights reserved. ThinkIT Technology LTD. *\
\* Restricted rights to use, duplicate or disclose this code are *\
\* granted through contract. *\
\* Designed by: Zhihui Yang *\
\********************************************************************************/
/********************************************************************************\
\* The example introduces using technique for GPIO. It generates a certain
frequency pulse on pin GPIO10-GPIO13. LED2-LED5 will twinkle,if the routine runs correctly.*\
\********************************************************************************/
#include <csl.h>
#include <csl_gpio.h>
/********************************************************************************/
void Delay(unsigned int nDelay);
static GPIO_Handle hGpio;
/********************************************************************************/
/********************************************************************************/
main()
{
/* Initialize CSL,must when using CSL. */
CSL_init();
/* Set GPIO. */
hGpio = GPIO_open(GPIO_DEV0,GPIO_OPEN_RESET);
GPIO_reset(hGpio);
GPIO_pinEnable(hGpio,GPIO_PIN10);
GPIO_pinDirection(hGpio,GPIO_PIN10,GPIO_OUTPUT);
GPIO_pinEnable(hGpio,GPIO_PIN11);
GPIO_pinDirection(hGpio,GPIO_PIN11,GPIO_OUTPUT);
GPIO_pinEnable(hGpio,GPIO_PIN12);
GPIO_pinDirection(hGpio,GPIO_PIN12,GPIO_OUTPUT);
GPIO_pinEnable(hGpio,GPIO_PIN13);
GPIO_pinDirection(hGpio,GPIO_PIN13,GPIO_OUTPUT);
while(1)
{
GPIO_pinWrite(hGpio,GPIO_PIN10,0);
GPIO_pinWrite(hGpio,GPIO_PIN11,0);
GPIO_pinWrite(hGpio,GPIO_PIN12,0);
GPIO_pinWrite(hGpio,GPIO_PIN13,0);
Delay(200);
GPIO_pinWrite(hGpio,GPIO_PIN10,1);
GPIO_pinWrite(hGpio,GPIO_PIN11,1);
GPIO_pinWrite(hGpio,GPIO_PIN12,1);
GPIO_pinWrite(hGpio,GPIO_PIN13,1);
Delay(200);
}
}
void Delay(unsigned int nDelay)
{
int ii,jj,kk=0;
for ( ii=0;ii<nDelay;ii++ )
{
for ( jj=0;jj<1024;jj++ )
{
kk++;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -