forked from Imagelibrary/rtems
These tests should have been fairly clean examples. Instead they
showed their roots as tests and included numerous references to test support routines.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
rtems_task Application_task(
|
rtems_task Application_task(
|
||||||
rtems_task_argument node
|
rtems_task_argument node
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ rtems_task Application_task(
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_MP_APPLICATION
|
#define CONFIGURE_MP_APPLICATION
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
@@ -40,8 +42,4 @@ rtems_task Application_task(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
rtems_task Application_task(
|
rtems_task Application_task(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define ARGUMENT 0
|
#define ARGUMENT 0
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -27,6 +27,8 @@ rtems_task Application_task(
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
@@ -34,8 +36,4 @@ rtems_task Application_task(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -20,6 +20,6 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ rtems_task main_task(
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
@@ -32,8 +34,4 @@ rtems_task main_task(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ rtems_task Init(
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
|
|
||||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||||
@@ -31,8 +33,4 @@ rtems_task Init(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -20,8 +20,9 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
extern int paranoia(int, char **);
|
extern int paranoia(int, char **);
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -23,6 +23,8 @@ rtems_task Init(
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
@@ -34,8 +36,4 @@ rtems_task Init(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -20,8 +20,16 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the names and IDs in global variables so another task can use them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rtems_id Task_id[ 4 ]; /* array of task ids */
|
||||||
|
rtems_name Task_name[ 4 ]; /* array of task names */
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
@@ -32,7 +40,14 @@ rtems_task Init(
|
|||||||
|
|
||||||
puts( "\n\n*** CLOCK TICK TEST ***" );
|
puts( "\n\n*** CLOCK TICK TEST ***" );
|
||||||
|
|
||||||
build_time( &time, 12, 31, 1988, 9, 0, 0, 0 );
|
time.year = 1988;
|
||||||
|
time.month = 12;
|
||||||
|
time.day = 31;
|
||||||
|
time.hour = 9;
|
||||||
|
time.minute = 0;
|
||||||
|
time.second = 0;
|
||||||
|
time.ticks = 0;
|
||||||
|
|
||||||
status = rtems_clock_set( &time );
|
status = rtems_clock_set( &time );
|
||||||
|
|
||||||
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
|
Task_name[ 1 ] = rtems_build_name( 'T', 'A', '1', ' ' );
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <tmacros.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
@@ -25,8 +25,20 @@ rtems_task Test_task(
|
|||||||
rtems_task_argument argument
|
rtems_task_argument argument
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* global variables */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Keep the names and IDs in global variables so another task can use them.
|
||||||
|
*/
|
||||||
|
|
||||||
|
extern rtems_id Task_id[ 4 ]; /* array of task ids */
|
||||||
|
extern rtems_name Task_name[ 4 ]; /* array of task names */
|
||||||
|
|
||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
|
||||||
|
|
||||||
@@ -36,9 +48,66 @@ rtems_task Test_task(
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
/*
|
||||||
|
* Handy macros and static inline functions
|
||||||
|
*/
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Task_id[ 4 ]; /* array of task ids */
|
/*
|
||||||
TEST_EXTERN rtems_name Task_name[ 4 ]; /* array of task names */
|
* Macro to hide the ugliness of printing the time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define print_time(_s1, _tb, _s2) \
|
||||||
|
do { \
|
||||||
|
printf( "%s%02d:%02d:%02d %02d/%02d/%04d%s", \
|
||||||
|
_s1, (_tb)->hour, (_tb)->minute, (_tb)->second, \
|
||||||
|
(_tb)->month, (_tb)->day, (_tb)->year, _s2 ); \
|
||||||
|
fflush(stdout); \
|
||||||
|
} while ( 0 )
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Macro to print an task name that is composed of ASCII characters.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define put_name( _name, _crlf ) \
|
||||||
|
do { \
|
||||||
|
rtems_unsigned32 c0, c1, c2, c3; \
|
||||||
|
\
|
||||||
|
c0 = ((_name) >> 24) & 0xff; \
|
||||||
|
c1 = ((_name) >> 16) & 0xff; \
|
||||||
|
c2 = ((_name) >> 8) & 0xff; \
|
||||||
|
c3 = (_name) & 0xff; \
|
||||||
|
putchar( (char)c0 ); \
|
||||||
|
if ( c1 ) putchar( (char)c1 ); \
|
||||||
|
if ( c2 ) putchar( (char)c2 ); \
|
||||||
|
if ( c3 ) putchar( (char)c3 ); \
|
||||||
|
if ( (_crlf) ) \
|
||||||
|
putchar( '\n' ); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* static inline routine to make obtaining ticks per second easier.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static inline rtems_unsigned32 get_ticks_per_second( void )
|
||||||
|
{
|
||||||
|
rtems_interval ticks_per_second;
|
||||||
|
(void) rtems_clock_get( RTEMS_CLOCK_GET_TICKS_PER_SECOND, &ticks_per_second ); return ticks_per_second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This allows us to view the "Test_task" instantiations as a set
|
||||||
|
* of numbered tasks by eliminating the number of application
|
||||||
|
* tasks created.
|
||||||
|
*
|
||||||
|
* In reality, this is too complex for the purposes of this
|
||||||
|
* example. It would have been easier to pass a task argument. :)
|
||||||
|
* But it shows how rtems_id's can sometimes be used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define task_number( tid ) \
|
||||||
|
( rtems_get_index( tid ) - \
|
||||||
|
rtems_configuration_get_rtems_api_configuration()->number_of_initialization_tasks )
|
||||||
|
|
||||||
/* end of include file */
|
/* end of include file */
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
rtems_task Test_task(
|
rtems_task Test_task(
|
||||||
rtems_task_argument unused
|
rtems_task_argument unused
|
||||||
@@ -30,7 +31,7 @@ rtems_task Test_task(
|
|||||||
|
|
||||||
status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
|
status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
|
||||||
task_index = task_number( tid );
|
task_index = task_number( tid );
|
||||||
while( FOREVER ) {
|
for ( ; ; ) {
|
||||||
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &time );
|
||||||
if ( time.second >= 35 ) {
|
if ( time.second >= 35 ) {
|
||||||
puts( "*** END OF CLOCK TICK TEST ***" );
|
puts( "*** END OF CLOCK TICK TEST ***" );
|
||||||
@@ -38,6 +39,6 @@ rtems_task Test_task(
|
|||||||
}
|
}
|
||||||
put_name( Task_name[ task_index ], FALSE );
|
put_name( Task_name[ task_index ], FALSE );
|
||||||
print_time( " - rtems_clock_get - ", &time, "\n" );
|
print_time( " - rtems_clock_get - ", &time, "\n" );
|
||||||
status = rtems_task_wake_after( task_index * 5 * TICKS_PER_SECOND );
|
status = rtems_task_wake_after( task_index * 5 * get_ticks_per_second() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* $Id$
|
* $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TEST_INIT
|
#define CONFIGURE_INIT
|
||||||
|
|
||||||
#include "system.h"
|
#include "system.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
|
|
||||||
#include <tmacros.h>
|
|
||||||
|
|
||||||
/* functions */
|
/* functions */
|
||||||
|
|
||||||
rtems_task Init(
|
rtems_task Init(
|
||||||
@@ -43,6 +41,8 @@ void test3();
|
|||||||
|
|
||||||
/* configuration information */
|
/* configuration information */
|
||||||
|
|
||||||
|
#include <bsp.h> /* for device driver prototypes */
|
||||||
|
|
||||||
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
|
||||||
|
|
||||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||||
@@ -54,10 +54,6 @@ void test3();
|
|||||||
|
|
||||||
#include <confdefs.h>
|
#include <confdefs.h>
|
||||||
|
|
||||||
/* global variables */
|
|
||||||
|
|
||||||
TEST_EXTERN rtems_id Global_variable; /* example global variable */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keep track of the task id's created, use a large array.
|
* Keep track of the task id's created, use a large array.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user