20171228笔记-RTC芯片

1、DS1340型号RTC芯片的驱动问题

使用内核集成的AD1340 RTC芯片的驱动的时候,发现不能加载,更新内核后正常

系统调用代码例程如下

Main函数

  RTCfd = open ("/dev/rtc0", O_RDONLY);

  if (RTCfd == -1) {

     perror("/dev/rtc0");

     exit(1);

  }

/************************************************

读取rtc时间

 

**************************************************/ 

struct rtc_time ReadRTCTime(void) 

{

         int retval;

         struct rtc_time rtc_tm;

  /* Read the RTC time/date */

  retval = ioctl(RTCfd, RTC_RD_TIME, &rtc_tm);

  if (retval == -1) {

     perror("ioctl");

     exit(1);

  }

  fprintf(stderr, "Current RTC date/time is %4d-%02d-%02d,%02d:%02d:%02d.\n",

     rtc_tm.tm_year + 1900, rtc_tm.tm_mon + 1, rtc_tm.tm_mday,

      rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);

 

   return rtc_tm;

}

/************************************************

设置rtc时间

参数:*dt数据格式为"2006-4-20 20:30:30"

调用方法:

    char *pt="2006-4-20 20:30:30";

    SetSystemTime(pt);

**************************************************/ 

int SetRTCTime(char *dt) 

      struct rtc_time tm; 

         int retval;

         sscanf(dt, "%d-%d-%d %d:%d:%d", &tm.tm_year,&tm.tm_mon, &tm.tm_mday,&tm.tm_hour, &tm.tm_min, &tm.tm_sec); 

 

         tm.tm_year -=1900;

         tm.tm_mon -=1;

         printf("Set the RTC time\n");

         /* Set the RTC time/date */

         retval = ioctl(RTCfd, RTC_SET_TIME, &tm);

         if (retval == -1) {

                   perror("ioctl");

                   exit(1);

         }  

}

 

 

在驱动调用过程中,切记分开系统时间和RTC时钟,系统时间使用gettimeofday和settimeofday来调用。

 

2、修改设备树实现CAN0在liunux使用,CAN1在裸核中使用。裸核只需要打开can1的时钟即可(APER_CLK_CTRL寄存器(0xf800015c Bit1)和CAN_CLK_CTRL寄存器(0xf800012c Bit17))

 

修改前

/*&can0 {

         status = "okay";

};*/

 

&can1 {

         status = "okay";

};

修改后

&can0 {

         status = "okay";

};

 

/*&can1 {

         status = "okay";

};*/

 

 

 

3、find指令

find   -name april*                     在当前目录下查找以april开始的文件
find   -name   april*   fprint file        在当前目录下查找以april开始的文件,并把结果输出到file
find   -name ap* -o -name may*   查找以apmay开头的文件
find   /mnt   -name tom.txt   -ftype vfat   /mnt下查找名称为tom.txt且文件系统类型vfat的文件
find   /mnt   -name t.txt ! -ftype vfat   /mnt下查找名称为tom.txt且文件系统类型不为vfat的文件
find   /tmp   -name wa* -type l            /tmp下查找名为wa开头且类型为符号链接的文件
find   /home   -mtime   -2                 /home下查最近两天内改动过的文件
find /home    -atime -1                  1天之内被存取过的文件
find /home -mmin    +60                  /home下查60分钟前改动过的文件
find /home   -amin   +30                  查最近30分钟前被存取过的文件
find /home   -newer   tmp.txt             /home下查更新时间比tmp.txt近的文件或目录
find /home   -anewer   tmp.txt            /home下查存取时间比tmp.txt近的文件或目录
find   /home   -used   -2                  列出文件或目录被改动过之后,在2日内被存取过的文件或目录
find   /home   -user cnscn                列出/home目录内属于用户cnscn的文件或目录
find   /home   -uid   +501                  列出/home目录内用户的识别码大于501的文件或目录
find   /home   -group   cnscn              列出/home内组为cnscn的文件或目录
find   /home   -gid 501                   列出/home内组id501的文件或目录
find   /home   -nouser                    列出/home内不属于本地用户的文件或目录
find   /home   -nogroup                   列出/home内不属于本地组的文件或目录
find   /home    -name tmp.txt    -maxdepth   4   列出/home内的tmp.txt 查时深度最多为3
find   /home   -name tmp.txt   -mindepth   3   从第2层开始查
find   /home   -empty                     查找大小为0的文件或空目录
find   /home   -size   +512k                查大于512k的文件
find   /home   -size   -512k               查小于512k的文件
find   /home   -links   +2                查硬连接数大于2的文件或目录
find   /home   -perm   0700                查权限为700的文件或目录
find   /tmp   -name tmp.txt   -exec cat {} \;
find   /tmp   -name   tmp.txt   -ok   rm {} \;

find    /   -amin    -10     # 查找在系统中最后10分钟访问的文件
find    /   -atime   -2        # 查找在系统中最后48小时访问的文件
find    /   -empty             # 查找在系统中为空的文件或者文件夹
find    /   -group   cat        # 查找在系统中属于 groupcat的文件
find    /   -mmin   -5         # 查找在系统中最后5分钟里修改过的文件
find    /   -mtime   -1       #查找在系统中最后24小时里修改过的文件
find    /   -nouser           #查找在系统中属于作废用户的文件
find    /   -user    fred     #查找在系统中属于FRED这个用户的文件

 

 

4、修改设备名称在设备树中

 

 

开机打印信息

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值