You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by da...@apache.org on 2021/03/24 19:09:03 UTC
[incubator-nuttx-apps] branch master updated: examples/oneshot:
fixed wrong constant and refactored
This is an automated email from the ASF dual-hosted git repository.
davids5 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new bf71741 examples/oneshot: fixed wrong constant and refactored
bf71741 is described below
commit bf71741452b60b58dca180fee1510cbb0ac7281b
Author: Sara Souza <sa...@espressif.com>
AuthorDate: Tue Mar 23 10:20:04 2021 -0300
examples/oneshot: fixed wrong constant and refactored
---
examples/oneshot/oneshot_main.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/examples/oneshot/oneshot_main.c b/examples/oneshot/oneshot_main.c
index 68b213a..6635ac6 100644
--- a/examples/oneshot/oneshot_main.c
+++ b/examples/oneshot/oneshot_main.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * examples/oneshot/oneshot_main.c
+ * apps/examples/oneshot/oneshot_main.c
*
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gn...@nuttx.org>
@@ -178,9 +178,10 @@ int main(int argc, FAR char *argv[])
return EXIT_FAILURE;
}
- maxus = (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000;
+ maxus = (uint64_t)ts.tv_sec * USEC_PER_SEC +
+ (uint64_t)ts.tv_nsec / NSEC_PER_USEC;
- printf("Maximum delay is %llu\n", maxus);
+ printf("Maximum delay is %" PRIu64 "\n", maxus);
/* Ignore the default signal action */
@@ -202,13 +203,12 @@ int main(int argc, FAR char *argv[])
printf("Starting oneshot timer with delay %lu microseconds\n",
usecs);
- start.pid = 0;
-
- secs = usecs / 1000000;
- usecs -= 1000000 * secs;
+ start.pid = 0;
+ secs = usecs / USEC_PER_SEC;
+ usecs -= USEC_PER_SEC * secs;
start.ts.tv_sec = secs;
- start.ts.tv_nsec = usecs * 1000;
+ start.ts.tv_nsec = usecs * NSEC_PER_USEC;
start.event.sigev_notify = SIGEV_SIGNAL;
start.event.sigev_signo = CONFIG_EXAMPLES_ONESHOT_SIGNO;
@@ -228,16 +228,16 @@ int main(int argc, FAR char *argv[])
start.ts.tv_sec = ts.tv_sec;
start.ts.tv_nsec = ts.tv_nsec;
- usecs -= maxus;
+ usecs -= maxus;
#if FUDGE_FACTOR > 0
if (usecs > FUDGE_FACTOR)
{
- usecs -= FUDGE_FACTOR;
+ usecs -= FUDGE_FACTOR;
}
else
{
- usecs = 0;
+ usecs = 0;
}
#endif
}