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

📄 main.c

📁 在EP9315下实现的基于IIC接口的实时时钟驱动
💻 C
字号:
/****************************************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"
char timeset[]={0x00,0x00,0x06,0x26,0x1,0x11,0x05};   //attention : time setting value should be BCD format 
int main(void)
{
    int fd,i;
    char rbuf[7];
    char sign = 1;
    printf("Begin to test fftiic drivers\n");
    fd=open("/dev/fftiic", O_RDWR);            
    if(fd==-1) {
       perror("open");
       exit(EXIT_FAILURE);
    }
    write(fd,timeset,sizeof(timeset));                 
    while(1)
    {
       read(fd,rbuf,7);   
       if(rbuf[1] == 2) break;
       if(rbuf[0] != sign) 
       {
          printf("Year      Month     Day       Week      Hour      Minutes   Second\n"); 
          for(i = 0;i<7;i++)
          {
             
             printf("%x         ",rbuf[6-i]);
             sign = rbuf[0];
          }
          printf("\n");
       }
       usleep(100);
    }
    if(close(fd)<0) {
       perror("close");
       exit(EXIT_FAILURE);
    }
    printf("finished FFT pwm test\n");
    exit(EXIT_SUCCESS);

}

⌨️ 快捷键说明

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