summaryrefslogtreecommitdiff
path: root/led/timer
diff options
context:
space:
mode:
Diffstat (limited to 'led/timer')
-rw-r--r--led/timer/.cvsignore1
-rw-r--r--led/timer/Makefile27
-rw-r--r--led/timer/init.c135
3 files changed, 163 insertions, 0 deletions
diff --git a/led/timer/.cvsignore b/led/timer/.cvsignore
new file mode 100644
index 0000000..fecf58a
--- /dev/null
+++ b/led/timer/.cvsignore
@@ -0,0 +1 @@
+o-optimize
diff --git a/led/timer/Makefile b/led/timer/Makefile
new file mode 100644
index 0000000..4ce2a92
--- /dev/null
+++ b/led/timer/Makefile
@@ -0,0 +1,27 @@
+#
+# $Id$
+#
+
+#
+# RTEMS_MAKEFILE_PATH is typically set in an environment variable
+#
+
+PGM=${ARCH}/timer.exe
+
+# optional managers required
+MANAGERS=all
+
+# C source names
+CSRCS = init.c
+COBJS = $(CSRCS:%.c=${ARCH}/%.o)
+
+include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
+include $(RTEMS_CUSTOM)
+include $(PROJECT_ROOT)/make/leaf.cfg
+
+OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
+
+all: ${ARCH} $(PGM)
+
+$(PGM): $(OBJS)
+ $(make-exe)
diff --git a/led/timer/init.c b/led/timer/init.c
new file mode 100644
index 0000000..f9e3a36
--- /dev/null
+++ b/led/timer/init.c
@@ -0,0 +1,135 @@
+/*
+ * COPYRIGHT (c) 1989-2007.
+ * 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 <bsp.h>
+
+#include "../../testmacros.h"
+#include "../led.h"
+
+rtems_id Timer1;
+rtems_id Timer2;
+
+#define USE_TIMER_SERVER
+#if defined(__LED_PRINTING)
+volatile int led_do_print;
+volatile int led_value;
+#endif
+
+rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored )
+{
+ rtems_status_code status;
+
+#if defined(__LED_PRINTING)
+ if ( id == Timer1 )
+ led_value = 1;
+ else
+ led_value = 0;
+ led_do_print = 1;
+#else
+ if ( id == Timer1 )
+ LED_ON();
+ else
+ LED_OFF();
+#endif
+
+#if defined(USE_TIMER_SERVER)
+ status = rtems_timer_server_fire_after(
+#else
+ status = rtems_timer_fire_after(
+#endif
+ id,
+ 2 * get_ticks_per_second(),
+ Timer_Routine,
+ NULL
+ );
+}
+
+rtems_task Init(
+ rtems_task_argument argument
+)
+{
+ rtems_status_code status;
+
+ puts( "\n\n*** LED BLINKER -- timer ***" );
+
+ LED_INIT();
+
+#if defined(USE_TIMER_SERVER)
+ status = rtems_timer_initiate_server(
+ 1,
+ RTEMS_MINIMUM_STACK_SIZE * 2,
+ RTEMS_DEFAULT_ATTRIBUTES
+ );
+
+ if ( status != RTEMS_SUCCESSFUL )
+ fputs( "timer create server failed\n", stderr );
+#endif
+
+ status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '1' ), &Timer1);
+ if ( status != RTEMS_SUCCESSFUL )
+ fputs( "Timer1 create failed\n", stderr );
+
+ status = rtems_timer_create(rtems_build_name( 'T', 'M', 'R', '2' ), &Timer2);
+ if ( status != RTEMS_SUCCESSFUL )
+ fputs( "Timer2 create failed\n", stderr );
+
+ Timer_Routine(Timer1, NULL);
+
+ status = rtems_task_wake_after( get_ticks_per_second() );
+
+ Timer_Routine(Timer2, NULL);
+
+
+#if defined(__LED_PRINTING)
+
+ while (1) {
+ int _led_do_print;
+ int _led_value;
+
+ status = rtems_task_wake_after( 10 );
+
+ /* technically the following 4 statements are a critical section */
+ _led_do_print = led_do_print;
+ _led_value = led_value;
+ led_do_print = 0;
+ led_value = 0;
+
+ if ( _led_do_print ) {
+ if ( _led_value )
+ LED_ON();
+ else
+ LED_OFF();
+
+ }
+ }
+#endif
+ status = rtems_task_delete( RTEMS_SELF );
+}
+
+
+/**************** 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_TIMERS 2
+#define CONFIGURE_MAXIMUM_SEMAPHORES 20
+
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
+
+#define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
+
+#include <rtems/confdefs.h>
+
+/**************** END OF CONFIGURATION INFORMATION ****************/