[rtems-libbsd commit] DELAY(): Use rtems_counter_delay_nanoseconds()

Sebastian Huber sebh at rtems.org
Wed Sep 30 14:07:12 UTC 2015


Module:    rtems-libbsd
Branch:    master
Commit:    556a07ca4426f7da288425dd42a98112a77b54f2
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=556a07ca4426f7da288425dd42a98112a77b54f2

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Sep 30 16:06:22 2015 +0200

DELAY(): Use rtems_counter_delay_nanoseconds()

---

 rtemsbsd/rtems/rtems-bsd-delay.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/rtemsbsd/rtems/rtems-bsd-delay.c b/rtemsbsd/rtems/rtems-bsd-delay.c
index a698117..1faa926 100644
--- a/rtemsbsd/rtems/rtems-bsd-delay.c
+++ b/rtemsbsd/rtems/rtems-bsd-delay.c
@@ -7,11 +7,11 @@
  */
 
 /*
- * Copyright (c) 2009, 2010 embedded brains GmbH.  
+ * Copyright (c) 2009, 2015 embedded brains GmbH
  * All rights reserved.
  *
  *  embedded brains GmbH
- *  Obere Lagerstr. 30
+ *  Dornierstr. 4
  *  82178 Puchheim
  *  Germany
  *  <rtems at embedded-brains.de>
@@ -40,24 +40,14 @@
 
 #include <machine/rtems-bsd-kernel-space.h>
 
-#include <rtems/bsd/sys/param.h>
 #include <rtems/bsd/sys/types.h>
 #include <sys/systm.h>
-#include <sys/kernel.h>
+#include <rtems/counter.h>
 
 void
 DELAY(int usec)
 {
-	rtems_status_code sc = RTEMS_SUCCESSFUL;
-
-	/* FIXME: Integer conversion */
-	rtems_interval ticks =
-		((rtems_interval) usec * (rtems_interval) hz) / 1000000;
-
-	if (ticks == 0) {
-		ticks = 1;
-	}
-
-	sc = rtems_task_wake_after(ticks);
-	BSD_ASSERT(sc == RTEMS_SUCCESSFUL);
+	uint32_t ns = 1000 * (uint32_t)usec;
+	BSD_ASSERT((uint32_t)usec <= UINT32_MAX / 1000);
+	rtems_counter_delay_nanoseconds(ns);
 }



More information about the vc mailing list