[8abaa16] | 1 | /* |
---|
[c0d7e23] | 2 | * COPYRIGHT (c) 1989-2011. |
---|
[8abaa16] | 3 | * On-Line Applications Research Corporation (OAR). |
---|
| 4 | * |
---|
| 5 | * The license and distribution terms for this file may be |
---|
| 6 | * found in the file LICENSE in this distribution or at |
---|
| 7 | * http://www.rtems.com/license/LICENSE. |
---|
| 8 | * |
---|
| 9 | * $Id$ |
---|
| 10 | */ |
---|
| 11 | |
---|
[7d3f9c6] | 12 | #ifdef HAVE_CONFIG_H |
---|
| 13 | #include "config.h" |
---|
| 14 | #endif |
---|
| 15 | |
---|
[8abaa16] | 16 | #include <tmacros.h> |
---|
[f57f5ce2] | 17 | #include "pritime.h" |
---|
[8abaa16] | 18 | |
---|
| 19 | volatile int Fired; |
---|
| 20 | volatile bool timerRan; |
---|
| 21 | |
---|
| 22 | rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored ) |
---|
| 23 | { |
---|
[c0d7e23] | 24 | rtems_status_code status; |
---|
[8abaa16] | 25 | |
---|
| 26 | Fired++; |
---|
| 27 | timerRan = true; |
---|
| 28 | |
---|
[c0d7e23] | 29 | status = rtems_timer_server_fire_after( |
---|
[8abaa16] | 30 | id, |
---|
[1f7ee02] | 31 | rtems_clock_get_ticks_per_second(), |
---|
[8abaa16] | 32 | Timer_Routine, |
---|
| 33 | NULL |
---|
| 34 | ); |
---|
[c0d7e23] | 35 | directive_failed( status, "fire after" ); |
---|
| 36 | |
---|
[8abaa16] | 37 | } |
---|
| 38 | |
---|
| 39 | rtems_task Init( |
---|
| 40 | rtems_task_argument argument |
---|
| 41 | ) |
---|
| 42 | { |
---|
| 43 | rtems_status_code sc; |
---|
| 44 | rtems_id timer1; |
---|
| 45 | struct timespec uptime; |
---|
| 46 | |
---|
| 47 | puts( "\n\n*** TEST 50 ***" ); |
---|
| 48 | |
---|
| 49 | sc = rtems_timer_initiate_server( |
---|
[b1274bd9] | 50 | 1, |
---|
[8abaa16] | 51 | RTEMS_MINIMUM_STACK_SIZE, |
---|
| 52 | RTEMS_DEFAULT_ATTRIBUTES |
---|
| 53 | ); |
---|
| 54 | directive_failed( sc, "rtems_timer_initiate_server" ); |
---|
| 55 | |
---|
| 56 | sc = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &timer1); |
---|
| 57 | directive_failed( sc, "rtems_timer_create" ); |
---|
| 58 | |
---|
| 59 | Fired = 0; |
---|
| 60 | timerRan = false; |
---|
| 61 | |
---|
| 62 | Timer_Routine(timer1, NULL); |
---|
| 63 | |
---|
| 64 | while (1) { |
---|
| 65 | sc = rtems_task_wake_after( 10 ); |
---|
| 66 | directive_failed( sc, "rtems_task_wake_after" ); |
---|
| 67 | |
---|
| 68 | if ( timerRan == true ) { |
---|
| 69 | timerRan = false; |
---|
| 70 | |
---|
| 71 | sc = rtems_clock_get_uptime( &uptime ); |
---|
| 72 | directive_failed( sc, "rtems_clock_get_uptime" ); |
---|
[b1274bd9] | 73 | |
---|
[f57f5ce2] | 74 | printf( "Timer fired at %" PRIdtime_t "\n", uptime.tv_sec ); |
---|
[8abaa16] | 75 | } |
---|
| 76 | |
---|
| 77 | if ( Fired >= 10 ) { |
---|
| 78 | puts( "*** END OF TEST 50 ***" ); |
---|
| 79 | rtems_test_exit( 0 ); |
---|
| 80 | } |
---|
| 81 | /* technically the following is a critical section */ |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | /**************** START OF CONFIGURATION INFORMATION ****************/ |
---|
| 87 | |
---|
| 88 | #define CONFIGURE_INIT |
---|
| 89 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
| 90 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
| 91 | |
---|
| 92 | #define CONFIGURE_MAXIMUM_TASKS 2 |
---|
| 93 | #define CONFIGURE_MAXIMUM_TIMERS 1 |
---|
| 94 | |
---|
| 95 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 96 | |
---|
| 97 | #include <rtems/confdefs.h> |
---|
| 98 | |
---|
| 99 | /**************** END OF CONFIGURATION INFORMATION ****************/ |
---|