⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 leddrv_test.c

📁 华颐公司的以AT91RM9200为CPU的9200F 开发板在linux开发环境下的(不是基于ADS) LED,和DA驱动和测试程序的源代码
💻 C
字号:
/**************************************************************** Institue of Automation,Chinese Academy of Sciences* Beijing Hyesco Embedded System Co.,Ltd.* www.hyesco.com* File Name: * Description: PC14、PC15 Control* Author: ***************************************************************/#include <stdio.h>#include <string.h>#include <malloc.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>#include <signal.h>#define	DTime	50static void Delay(int);int main(void){	int fd,count;	int i=100;        unsigned long rgcon;		//以可读、写的方式打开设备文件	if((fd=open("/dev/led",O_RDWR))==-1)		{			perror("open error");			exit(1);		}		//循环i次	while(i--)		{    		printf("Beeper and BKlight\r\n");	    		    		//PC14、PC15均置为1		rgcon = 0x1 << 15 | 0x1 << 14;              	if((count=write(fd,(char *)&rgcon,4))!=4)			{			perror("write1 error");			exit(1);			}		Delay(DTime);		//PC14、PC15均清0                rgcon = 0;                if((count=write(fd,(char *)&rgcon,4))!=4)                	{                               perror("write1 error");                        exit(1);                	}                Delay(DTime);                }                	//关闭设备文件		close(fd);	return 0;}static void Delay(int x){	int i,j,k;	for(i=0;i<x;i++)		for(j=0;j<0xff;j++)			for(k=0;k<0xff;k++);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -