summaryrefslogtreecommitdiff
path: root/irq_test_c/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'irq_test_c/init.c')
-rw-r--r--irq_test_c/init.c156
1 files changed, 156 insertions, 0 deletions
diff --git a/irq_test_c/init.c b/irq_test_c/init.c
new file mode 100644
index 0000000..a67235e
--- /dev/null
+++ b/irq_test_c/init.c
@@ -0,0 +1,156 @@
+/*
+ * COPYRIGHT (c) 1989-2003.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <bsp.h>
+#include <rtems/score/timespec.h> /* _Timespec_Substract */
+
+struct timespec start;
+#if defined(INCLUDE_TO_ISR)
+ struct timespec to_isr;
+#endif
+struct timespec stop_in_task;
+
+rtems_id semaphore;
+rtems_id task_id;
+
+void irqforce(int);
+
+void ISR( uint32_t arg )
+{
+ rtems_status_code status;
+ #if defined(INCLUDE_TO_ISR)
+ _TOD_Get( &to_isr );
+ #endif
+ status = rtems_semaphore_release( semaphore );
+}
+
+rtems_task ISR_Task(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ struct timespec diff1, diff2;
+
+ #define print_timespec( _t ) \
+ printf ( "%ld:%ld ", (long) _t.tv_sec, (long) _t.tv_nsec );
+
+ /*
+ * Print base overhead
+ */
+
+ _TOD_Get( &start );
+ _TOD_Get( &stop_in_task );
+ _Timespec_Subtract( &start, &stop_in_task, &diff1 );
+ printf( "Timer Overhead: " );
+ print_timespec( start );
+ print_timespec( stop_in_task );
+ printf( "--> " );
+ print_timespec( diff1 );
+ printf( "\n" );
+
+ while (1) {
+ status = rtems_semaphore_obtain( semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
+ _TOD_Get( &stop_in_task );
+
+ _Timespec_Subtract( &start, &stop_in_task, &diff2 );
+ print_timespec( start );
+ #if defined(INCLUDE_TO_ISR)
+ _Timespec_Subtract( &start, &to_isr, &diff1 );
+ print_timespec( to_isr );
+ #endif
+ print_timespec( stop_in_task );
+ printf( "--> " );
+ #if defined(INCLUDE_TO_ISR)
+ print_timespec( diff1 );
+ #endif
+ print_timespec( diff2 );
+ printf( "\n" );
+ }
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+ rtems_time_of_day time;
+ int i;
+
+ puts( "\n\n*** IRQ FORCE TEST ***" );
+
+ time.year = 2007;
+ time.month = 10;
+ time.day = 17;
+ time.hour = 13;
+ time.minute = 45;
+ time.second = 0;
+ time.ticks = 0;
+
+ status = rtems_clock_set( &time );
+
+ /*
+ * Create the simple semaphore used to wake us up
+ */
+
+ status = rtems_semaphore_create(
+ rtems_build_name( 'A', 'I', 'S', 'R' ),
+ 0,
+ RTEMS_SIMPLE_BINARY_SEMAPHORE | RTEMS_FIFO,
+ 0,
+ &semaphore
+ );
+
+ status = rtems_task_create(
+ rtems_build_name( 'A', 'I', 'S', 'R' ),
+ 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES,
+ RTEMS_DEFAULT_ATTRIBUTES, &task_id
+ );
+ status = rtems_task_start( task_id, ISR_Task, 1 );
+
+
+ /*
+ * Now generate the interrupt and time it
+ */
+
+ set_vector( ISR, 17, 1 );
+ for ( i=0 ; i<= 10 ; i++ ) {
+ sleep(1);
+ _TOD_Get( &start );
+ irqforce(1);
+ }
+ sleep(1);
+
+ exit( 0 );
+}
+
+/**************** START OF CONFIGURATION INFORMATION ****************/
+
+#define CONFIGURE_INIT
+
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
+#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+
+#define CONFIGURE_MAXIMUM_TASKS 4
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+#define CONFIGURE_INIT_TASK_PRIORITY 5
+#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_PREEMPT
+
+#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
+
+#include <rtems/confdefs.h>
+
+/**************** END OF CONFIGURATION INFORMATION ****************/
+