main.c

来自「fft的工业级的EP9315的开发板的所有驱动程序」· C语言 代码 · 共 50 行

C
50
字号
/****************************************Copyright (c)**************************************************
**                                     研    发    部
**                              http://www.FFTChina.com
**-----------------------------------------文件信息-----------------------------------------------------
**文   件   名: cantest.c
**创   建   人: 
**最后修改日期: 2005年6月30日
**描        述:  
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
/* to produce a pwm of 100khz(10us)and 20% duty cycle with system clock of 14.7456Mhz
   
   Caculate Pwmtermcnt (14.7456M/0.1M) -1 = 146.456 
   Caculate PwmDutyCycle 0.2*(146.456+1)-1= 28.4912

*/  
#include "stdio.h"
#include "stdlib.h"
#include "sys/types.h"
#include "sys/stat.h"
#include "fcntl.h"
int main(void)
{
    int fd,i;
    char rbuf[7];
    char sign = 1;
    unsigned int cmd=0x12; 
    unsigned int time = 50;
    printf("Begin to test fftled drivers\n");
    fd=open("/dev/fftled", O_RDWR);            
    if(fd==-1) {
       perror("open");
       exit(EXIT_FAILURE);
    }
    while(time --)
    {    
       ioctl(fd,cmd,0);
       cmd=~cmd;
       usleep(200000);
    }
    if(close(fd)<0) {
       perror("close");
       exit(EXIT_FAILURE);
    }
    printf("finished FFT led test\n");
    exit(EXIT_SUCCESS);

}

⌨️ 快捷键说明

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