mirror of
https://github.com/apache/nuttx.git
synced 2026-08-27 20:30:38 +00:00
Fix grammatical error in Returned Value documentation comments: 'successfully register' → 'successfully registered' 'successfully initialize' → 'successfully initialized' Affected files (17 files, 19 occurrences): drivers/i2c/i2c_driver.c drivers/i2s/i2schar.c drivers/i3c/i3c_driver.c drivers/i3c/master.c drivers/motor/motor.c drivers/motor/stepper.c drivers/rc/lirc_dev.c drivers/sensors/gnss_uorb.c drivers/sensors/sensor.c (2 occurrences) drivers/spi/spi_driver.c drivers/timers/ptp_clock.c drivers/timers/ptp_clock_dummy.c drivers/video/mipidsi/mipi_dsi.h (2 occurrences) drivers/video/mipidsi/mipi_dsi_device.c drivers/video/mipidsi/mipi_dsi_device_driver.c drivers/video/mipidsi/mipi_dsi_host.c drivers/video/mipidsi/mipi_dsi_host_driver.c These are all comment-only changes with no functional impact. Signed-off-by: hanzj <hanzjian@zepp.com>
205 lines
6.9 KiB
C
205 lines
6.9 KiB
C
/****************************************************************************
|
|
* drivers/timers/ptp_clock_dummy.c
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright ownership. The
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
* "License"); you may not use this file except in compliance with the
|
|
* License. You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
* License for the specific language governing permissions and limitations
|
|
* under the License.
|
|
*
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Included Files
|
|
****************************************************************************/
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <nuttx/debug.h>
|
|
|
|
#include <nuttx/kmalloc.h>
|
|
#include <nuttx/timers/ptp_clock.h>
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Types
|
|
****************************************************************************/
|
|
|
|
struct ptp_clock_dummy_s
|
|
{
|
|
struct ptp_lowerhalf_s lower;
|
|
};
|
|
|
|
/****************************************************************************
|
|
* Private Function Prototypes
|
|
****************************************************************************/
|
|
|
|
static int ptp_clock_dummy_adjfine(FAR struct ptp_lowerhalf_s *lower,
|
|
long scaled_ppm);
|
|
static int ptp_clock_dummy_adjphase(FAR struct ptp_lowerhalf_s *lower,
|
|
int32_t phase);
|
|
static int ptp_clock_dummy_adjtime(FAR struct ptp_lowerhalf_s *lower,
|
|
int64_t delta);
|
|
static int ptp_clock_dummy_gettime(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct timespec *ts,
|
|
FAR struct ptp_system_timestamp *sts);
|
|
static int ptp_clock_dummy_getcrosststamp(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct system_device_crosststamp *cts);
|
|
static int ptp_clock_dummy_settime(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR const struct timespec *ts);
|
|
static int ptp_clock_dummy_getres(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct timespec *res);
|
|
|
|
/****************************************************************************
|
|
* Private Data
|
|
****************************************************************************/
|
|
|
|
static const struct ptp_ops_s g_ptp_clock_dummy_ops =
|
|
{
|
|
ptp_clock_dummy_adjfine, /* adjfine */
|
|
ptp_clock_dummy_adjphase, /* adjphase */
|
|
ptp_clock_dummy_adjtime, /* adjtime */
|
|
ptp_clock_dummy_gettime, /* gettime */
|
|
ptp_clock_dummy_getcrosststamp, /* getcroasststamp */
|
|
ptp_clock_dummy_settime, /* settime */
|
|
ptp_clock_dummy_getres, /* getres */
|
|
};
|
|
|
|
/****************************************************************************
|
|
* Private Functions
|
|
****************************************************************************/
|
|
|
|
static int ptp_clock_dummy_adjfine(FAR struct ptp_lowerhalf_s *lower,
|
|
long scaled_ppm)
|
|
{
|
|
ptpinfo("ptp_clock_dummy_adjfine ppm:%ld\n", scaled_ppm);
|
|
return 0;
|
|
}
|
|
|
|
static int ptp_clock_dummy_adjphase(FAR struct ptp_lowerhalf_s *lower,
|
|
int32_t phase)
|
|
{
|
|
ptpinfo("ptp_clock_dummy_adjphase phase:%"PRIi32"\n", phase);
|
|
return 0;
|
|
}
|
|
|
|
static int ptp_clock_dummy_adjtime(FAR struct ptp_lowerhalf_s *lower,
|
|
int64_t delta)
|
|
{
|
|
ptpinfo("ptp_clock_dummy_adjtime delta:%"PRIi64"\n", delta);
|
|
return 0;
|
|
}
|
|
|
|
static int ptp_clock_dummy_gettime(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct timespec *ts,
|
|
FAR struct ptp_system_timestamp *sts)
|
|
{
|
|
clock_gettime(CLOCK_REALTIME, ts);
|
|
|
|
if (sts != NULL)
|
|
{
|
|
sts->pre_ts.tv_sec = ts->tv_sec;
|
|
sts->pre_ts.tv_nsec = ts->tv_nsec;
|
|
sts->post_ts.tv_sec = ts->tv_sec;
|
|
sts->post_ts.tv_nsec = ts->tv_nsec;
|
|
}
|
|
|
|
ptpinfo("ptp_clock_dummy_gettime sec:%jd, nsec:%ld\n",
|
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
ptp_clock_dummy_getcrosststamp(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct system_device_crosststamp *cts)
|
|
{
|
|
struct timespec ts;
|
|
|
|
if (cts == NULL)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
|
|
clock_systime_timespec(&ts);
|
|
cts->device.tv_sec = ts.tv_sec;
|
|
cts->device.tv_nsec = ts.tv_nsec;
|
|
|
|
clock_gettime(CLOCK_REALTIME, &ts);
|
|
cts->realtime.tv_sec = ts.tv_sec;
|
|
cts->realtime.tv_nsec = ts.tv_nsec;
|
|
|
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
cts->monoraw.tv_sec = ts.tv_sec;
|
|
cts->monoraw.tv_nsec = ts.tv_sec;
|
|
|
|
ptpinfo("ptp_clock_dummy_getcrosststamp sec:%jd, nsec:%ld\n",
|
|
(intmax_t)ts.tv_sec, ts.tv_nsec);
|
|
return 0;
|
|
}
|
|
|
|
static int ptp_clock_dummy_settime(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR const struct timespec *ts)
|
|
{
|
|
ptpinfo("ptp_clock_dummy_settime sec:%jd, nsec:%ld\n",
|
|
(intmax_t)ts->tv_sec, ts->tv_nsec);
|
|
return 0;
|
|
}
|
|
|
|
static int ptp_clock_dummy_getres(FAR struct ptp_lowerhalf_s *lower,
|
|
FAR struct timespec *res)
|
|
{
|
|
res->tv_sec = 0;
|
|
res->tv_nsec = 1;
|
|
return 0;
|
|
}
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: ptp_clock_dummy_initialize
|
|
*
|
|
* Description:
|
|
* This function will initialize dummy ptp device driver for test.
|
|
*
|
|
* Input Parameters:
|
|
* devno - The user specifies number of device. ex: /dev/ptpX.
|
|
*
|
|
* Returned Value:
|
|
* OK if the driver was successfully initialized; A negated errno value is
|
|
* returned on any failure.
|
|
*
|
|
****************************************************************************/
|
|
|
|
int ptp_clock_dummy_initialize(int devno)
|
|
{
|
|
FAR struct ptp_clock_dummy_s *priv;
|
|
|
|
/* Allocate the upper-half data structure */
|
|
|
|
priv = kmm_zalloc(sizeof(struct ptp_clock_dummy_s));
|
|
if (!priv)
|
|
{
|
|
ptperr("ERROR: Allocation failed\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
priv->lower.ops = &g_ptp_clock_dummy_ops;
|
|
|
|
return ptp_clock_register(&priv->lower, 1000000, devno);
|
|
}
|