Commit 98315967 authored by julien.delange's avatar julien.delange
Browse files

* PING example work with xenomai native, should fix

   now the delay_until function



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@2370 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 28c4ac1a
......@@ -17,6 +17,11 @@
#include <time.h>
#endif
#ifdef XENO_NATIVE
#include <native/timer.h>
#include <native/task.h>
#endif
typedef __po_hi_uint64_t __po_hi_time_t;
/*
......
......@@ -350,7 +350,12 @@ int __po_hi_create_generic_task (__po_hi_task_id id,
__po_hi_posix_create_thread (priority, stack_size, start_routine);
return (__PO_HI_SUCCESS);
#elif defined (XENO_NATIVE)
__po_hi_xenomai_create_thread (priority, stack_size, start_routine);
RT_TASK t;
t = __po_hi_xenomai_create_thread (priority, stack_size, start_routine);
if (rt_task_start (&(t), (void*)start_routine, NULL))
{
__DEBUGMSG ("ERROR when starting the task\n");
}
return (__PO_HI_SUCCESS);
#elif defined (RTEMS_PURE)
__po_hi_rtems_create_thread (priority, stack_size, start_routine);
......@@ -483,6 +488,15 @@ int __po_hi_task_delay_until (__po_hi_time_t time, __po_hi_task_id task)
pthread_mutex_unlock (&tasks[task].mutex);
return (ret);
#elif defined (XENO_NATIVE)
int ret;
ret = rt_task_sleep_until (time * 1000);
if (ret)
{
__DEBUGMSG ("[TASK] Error in rt_task_sleep_until, ret=%d\n", ret);
return (__PO_HI_ERROR_PTHREAD_COND);
}
return (__PO_HI_SUCCESS);
#endif
return (__PO_HI_UNAVAILABLE);
}
......
......@@ -70,7 +70,17 @@ int __po_hi_get_time (__po_hi_time_t* mytime)
tmp = _TOD_To_seconds (&current_time) * 1000000;
tmp += current_time.ticks * _TOD_Microseconds_per_tick;
mytime = tmp;
return (__PO_HI_SUCCESS);
#elif defined (XENO_NATIVE)
__po_hi_time_t tmp;
tmp = (__po_hi_time_t) (rt_timer_tsc2ns (rt_timer_read ()));
__DEBUGMSG ("TIMER value %llu\n", tmp);
tmp = tmp / 1000;
__DEBUGMSG ("TIMER value2 %llu\n", tmp);
*mytime = (__po_hi_time_t)tmp;
return (__PO_HI_SUCCESS);
#else
return (__PO_HI_UNAVAILABLE);
......@@ -155,6 +165,15 @@ int __po_hi_delay_until (__po_hi_time_t time)
return (ret);
#elif defined (RTEMS_PURE)
return (__PO_HI_UNAVAILABLE);
#elif defined (XENO_NATIVE)
int ret;
ret = rt_task_sleep_until (rt_timer_ns2tsc (time * 1000));
if (ret)
{
__DEBUGMSG ("[TASK] Error in rt_task_sleep_until, ret=%d, time=%llu\n", ret, time);
return (__PO_HI_ERROR_PTHREAD_COND);
}
return (__PO_HI_SUCCESS);
#else
return (__PO_HI_UNAVAILABLE);
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment