Changeset a3bf3ec in examples-v2


Ignore:
Timestamp:
Dec 17, 2009, 10:07:06 PM (9 years ago)
Author:
Glenn Humphrey <glenn.humphrey@…>
Branches:
4.11, examples-v2-4-10-branch, 286403d7a3d0e521179e677c0d2fd7549c9ceab4
Children:
fd3c47c
Parents:
c7ee085
Message:

2009-12-17 Glenn Humphrey <glenn.humphrey@…>

  • timer/init.c, timer_server/init.c: Simplified examples to insure consistent behavior for all cases.
Location:
led
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • led/ChangeLog

    rc7ee085 ra3bf3ec  
     12009-12-17      Glenn Humphrey <glenn.humphrey@OARcorp.com>
     2
     3        * timer/init.c, timer_server/init.c: Simplified examples to insure
     4        consistent behavior for all cases.
     5
    162009-12-17      Glenn Humphrey <glenn.humphrey@OARcorp.com>
    27
  • led/timer/init.c

    rc7ee085 ra3bf3ec  
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2009.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
     
    1515#include "../led.h"
    1616
    17 rtems_id          Timer1;
    18 rtems_id          Timer2;
    19 
    20 #if defined(__LED_PRINTING)
    2117volatile int led_do_print;
    2218volatile int led_value;
    23 #endif
     19rtems_id     Timer1;
     20rtems_id     Timer2;
     21
     22void LED_Change_Routine( void ) {
     23  int _led_do_print;
     24  int _led_value;
     25
     26  /* technically the following 4 statements are a critical section */
     27  _led_do_print = led_do_print;
     28  _led_value = led_value;
     29  led_do_print = 0;
     30  led_value = 0;
     31 
     32  if ( _led_do_print ) {
     33    if ( _led_value == 1 )
     34      LED_OFF();
     35    else
     36      LED_ON();
     37  }
     38}
    2439
    2540rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored )
     
    2742  rtems_status_code status;
    2843
    29 #if defined(__LED_PRINTING)
    3044  if ( id == Timer1 )
    3145    led_value = 1;
    3246  else
    33     led_value = 0;
     47    led_value = 2;
    3448  led_do_print = 1;
    35 #else
    36   if ( id == Timer1 )
    37     LED_ON();
    38   else
    39     LED_OFF();
    40 #endif
    4149
    4250  status = rtems_timer_fire_after(
     
    6775
    6876  Timer_Routine(Timer1, NULL);
     77  LED_Change_Routine();
    6978
    7079  status = rtems_task_wake_after( rtems_clock_get_ticks_per_second() );
    7180
    7281  Timer_Routine(Timer2, NULL);
     82  LED_Change_Routine();
    7383
    74 #if defined(__LED_PRINTING)
    7584  while (1) {
    76     int _led_do_print;
    77     int _led_value;
    78 
    7985    status = rtems_task_wake_after( 10 );
    80 
    81     /* technically the following 4 statements are a critical section */
    82     _led_do_print = led_do_print;
    83     _led_value = led_value;
    84     led_do_print = 0;
    85     led_value = 0;
    86    
    87     if ( _led_do_print ) {
    88       if ( _led_value )
    89         LED_ON();
    90       else
    91         LED_OFF();
    92 
    93     }
     86    LED_Change_Routine();
    9487  }
    95 #endif
    9688
    9789  status = rtems_task_delete( RTEMS_SELF );
  • led/timer_server/init.c

    rc7ee085 ra3bf3ec  
    11/*
    2  *  COPYRIGHT (c) 1989-2007.
     2 *  COPYRIGHT (c) 1989-2009.
    33 *  On-Line Applications Research Corporation (OAR).
    44 *
     
    1515#include "../led.h"
    1616
    17 rtems_id          Timer1;
    18 rtems_id          Timer2;
    19 
    20 #if defined(__LED_PRINTING)
    21 volatile int led_do_print;
    22 volatile int led_value;
    23 #endif
     17rtems_id     Timer1;
     18rtems_id     Timer2;
    2419
    2520rtems_timer_service_routine Timer_Routine( rtems_id id, void *ignored )
     
    2722  rtems_status_code status;
    2823
    29 #if defined(__LED_PRINTING)
    3024  if ( id == Timer1 )
    31     led_value = 1;
     25    LED_OFF();
    3226  else
    33     led_value = 0;
    34   led_do_print = 1;
    35 #else
    36   if ( id == Timer1 )
    3727    LED_ON();
    38   else
    39     LED_OFF();
    40 #endif
    4128
    4229  status = rtems_timer_server_fire_after(
     
    8168  Timer_Routine(Timer2, NULL);
    8269
    83 #if defined(__LED_PRINTING)
    84   while (1) {
    85     int _led_do_print;
    86     int _led_value;
    87 
    88     status = rtems_task_wake_after( 10 );
    89 
    90     /* technically the following 4 statements are a critical section */
    91     _led_do_print = led_do_print;
    92     _led_value = led_value;
    93     led_do_print = 0;
    94     led_value = 0;
    95    
    96     if ( _led_do_print ) {
    97       if ( _led_value )
    98         LED_ON();
    99       else
    100         LED_OFF();
    101 
    102     }
    103   }
    104 #endif
    105 
    10670  status = rtems_task_delete( RTEMS_SELF );
    10771}
Note: See TracChangeset for help on using the changeset viewer.