|
From: <jmk...@us...> - 2003-08-04 06:00:28
|
Update of /cvsroot/emc/rtapi/examples/timertask
In directory sc8-pr-cvs1:/tmp/cvs-serv30223/examples/timertask
Modified Files:
timertask.c
Log Message:
RTLinux version now uses new API, everything builds, only timertask is tested
Index: timertask.c
===================================================================
RCS file: /cvsroot/emc/rtapi/examples/timertask/timertask.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** timertask.c 2 Aug 2003 19:37:18 -0000 1.5
--- timertask.c 4 Aug 2003 06:00:25 -0000 1.6
***************
*** 11,20 ****
static rtapi_task_handle timer_task; /* the task */
static int timer_count = 0; /* the output variable */
! enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
enum { TIMER_STACKSIZE = 1024 }; /* how big the stack is */
static void timer_code( int arg )
{
while (1) {
/* a simple counter... */
timer_count++;
--- 11,23 ----
static rtapi_task_handle timer_task; /* the task */
static int timer_count = 0; /* the output variable */
! enum { TIMER_PERIOD_NSEC = 1000000 }; /* timer period, in nanoseconds */
! enum { TASK_PERIOD_NSEC = 1000000 }; /* task period, in nanoseconds */
enum { TIMER_STACKSIZE = 1024 }; /* how big the stack is */
static void timer_code( int arg )
{
+
while (1) {
+
/* a simple counter... */
timer_count++;
***************
*** 42,46 ****
/* set the base timer period */
retval = rtapi_clock_set_period(TIMER_PERIOD_NSEC);
! rtapi_print( "timertask init: rtapi_clock_set_period returned %d\n", retval );
/* set the task priority to lowest, since we only have one task */
--- 45,53 ----
/* set the base timer period */
retval = rtapi_clock_set_period(TIMER_PERIOD_NSEC);
! if ( retval != RTAPI_SUCCESS ) {
! /* See rtapi.h for the error codes returned */
! rtapi_print( "timertask init: rtapi_clock_set_period returned %d\n", retval );
! return -1;
! }
/* set the task priority to lowest, since we only have one task */
***************
*** 50,56 ****
/* the address of the pointer needs to be passed rather than it's value */
retval = rtapi_task_new( &timer_task );
if ( retval != RTAPI_SUCCESS ) {
/* See rtapi.h for the error codes returned */
- rtapi_print( "timertask init: rtapi_task_new returned %d\n", retval );
return -1;
}
--- 57,63 ----
/* the address of the pointer needs to be passed rather than it's value */
retval = rtapi_task_new( &timer_task );
+
if ( retval != RTAPI_SUCCESS ) {
/* See rtapi.h for the error codes returned */
return -1;
}
***************
*** 58,65 ****
/* the third arg is an abitrary int that is passed to the timer task
on the first iterration */
retval = rtapi_task_start( timer_task, timer_code,
0, timer_prio,
TIMER_STACKSIZE,
! TIMER_PERIOD_NSEC, RTAPI_NO_FP );
if ( retval != RTAPI_SUCCESS ) {
rtapi_print("timertask init: rtapi_task_start returned %d\n", retval );
--- 65,73 ----
/* the third arg is an abitrary int that is passed to the timer task
on the first iterration */
+
retval = rtapi_task_start( timer_task, timer_code,
0, timer_prio,
TIMER_STACKSIZE,
! TASK_PERIOD_NSEC, RTAPI_NO_FP );
if ( retval != RTAPI_SUCCESS ) {
rtapi_print("timertask init: rtapi_task_start returned %d\n", retval );
|