9x25 PPS test 代码分析 2016.07.14
Posted liushuhe1990
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了9x25 PPS test 代码分析 2016.07.14相关的知识,希望对你有一定的参考价值。
9x25 PPS test 代码分析 2016.07.14
pps-tools-masterPpstest.c
main
find_source(char *path, pps_handle_t *handle, int *avail_mode)
open(path, O_RDWR);
time_pps_create(ret, handle);
ioctl(source, PPS_GETPARAMS, &dummy);
*handle = source;
time_pps_getcap(*handle, avail_mode);
ioctl(handle, PPS_GETCAP, mode);
time_pps_getparams(*handle, ¶ms);
ioctl(handle, PPS_GETPARAMS, &__ppsparams);
time_pps_setparams(*handle, ¶ms);
ioctl(handle, PPS_SETPARAMS, &__ppsparams);
while (1)
{ //loop, printing the most recent timestamp every second or so
fetch_source(i, &handle[i], &avail_mode[i])
if (*avail_mode & PPS_CANWAIT)
time_pps_fetch(*handle, PPS_TSFMT_TSPEC, &infobuf,&timeout);
ioctl(handle, PPS_FETCH, &__fdata);
else {
sleep(1);
time_pps_fetch(*handle, PPS_TSFMT_TSPEC, &infobuf,&timeout);
ioctl(handle, PPS_FETCH, &__fdata);
}
linux-2.6.39-at91driversppsPps.c
static const struct file_operations pps_cdev_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
.poll = pps_cdev_poll,
.fasync = pps_cdev_fasync,
.unlocked_ioctl = pps_cdev_ioctl,
.open = pps_cdev_open,
.release = pps_cdev_release,
};
pps_cdev_ioctl
case PPS_GETPARAMS:
dev_dbg(pps->dev, "PPS_GETPARAMS
");
copy_to_user(uarg, ¶ms, sizeof(struct pps_kparams))
case PPS_GETCAP:
dev_dbg(pps->dev, "PPS_GETCAP
");
put_user(pps->info.mode, iuarg);
case PPS_SETPARAMS:
dev_dbg(pps->dev, "PPS_SETPARAMS
");
copy_from_user(¶ms, uarg, sizeof(struct pps_kparams));
case PPS_FETCH: {
copy_from_user(&fdata, uarg, sizeof(struct pps_fdata));
wait_event_interruptible(pps->queue,ev != pps->last_ev);
wait_event_interruptible_timeout(pps->queue,ev != pps->last_ev,ticks);
copy_to_user(uarg, &fdata, sizeof(struct pps_fdata));
pps_cdev_poll
poll_wait(file, &pps->queue, wait);
p->qproc(filp, wait_address, p);
pps_register_cdev
cdev_init(&pps->cdev, &pps_cdev_fops);
cdev_add(&pps->cdev, devt, 1);
device_create(pps_class, pps->info.dev, devt, pps,
kobject_add
以上是关于9x25 PPS test 代码分析 2016.07.14的主要内容,如果未能解决你的问题,请参考以下文章