src/led.c
author dejoigny
Tue, 16 May 2006 17:29:08 +0200
changeset 9 49f701f3dca7
parent 3 d9cf34cd6823
child 31 a82b70738e5c
permissions -rw-r--r--
data.h manquant
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     1
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     2
This file is part of CanFestival, a library implementing CanOpen Stack.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     4
 Author: CANopen Canada (canfestival@canopencanada.ca)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     6
See COPYING file for copyrights details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     8
This library is free software; you can redistribute it and/or
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
     9
modify it under the terms of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    10
License as published by the Free Software Foundation; either
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    11
version 2.1 of the License, or (at your option) any later version.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    12
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    13
This library is distributed in the hope that it will be useful,
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    14
but WITHOUT ANY WARRANTY; without even the implied warranty of
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    16
Lesser General Public License for more details.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    17
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    18
You should have received a copy of the GNU Lesser General Public
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    19
License along with this library; if not, write to the Free Software
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    21
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    22
	DS-303-3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    23
	LED implementation
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    24
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    25
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    26
#include <stdlib.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    27
#include <string.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    28
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    29
#include <sys/time.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    30
#include <signal.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    31
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    32
#include <applicfg.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    33
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    34
#include <data.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    35
#include <can_driver.h>
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    36
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    37
#include "led.h"
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    38
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    39
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    40
void led_start_timer(CO_Data *, UNS32 t0);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    41
void led_stop_timer(void);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    42
void led_set_green(UNS8 on);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    43
void led_set_red(UNS8 on);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    44
void led_callback(CO_Data* d, UNS32 id);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    45
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
// 0 = always off, 1 = always on, 2 = flashing
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
static UNS8 led_state_red, led_state_green; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
static UNS16 led_sequence_red, led_seq_index_red;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
static UNS16 led_sequence_green, led_seq_index_green;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
static UNS8 led_error_code = LED_NO_ERROR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
const char *led_sequence_table[6] = // up and downs of the sequence
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
	"01",           // flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
	"01",           // blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
	"100000",       // single flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
	"10100000",     // double flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
	"1010100000",   // triple flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
	"101010100000"  // quadruple flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
};
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    64
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    65
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    66
void led_set_state(CO_Data *d, int state)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
{
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
    68
printf("led_set_state(%x)\n", state);
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
    69
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    70
	switch(state)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
		case Initialisation:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
	must create a timer for the leds with the scheduler
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
		case LED_AUTOBITRATE:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
			led_sequence_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
		case Pre_operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
			led_sequence_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
		case Stopped:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
			led_sequence_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
		case LED_PRG_DOWNLOAD:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
			led_sequence_green = 4;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
		case Operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
			led_state_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
	if (state == LED_AUTOBITRATE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
		led_start_timer(d, 50);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
	else if (led_state_green < 2  &&  led_state_red < 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
		led_stop_timer();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   105
		//led_set_green(led_state_green);
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   106
		//led_set_red(led_state_red);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   107
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
	else
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
		led_start_timer(d, 200);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   112
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   113
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   114
void led_set_error(CO_Data *d, UNS8 error)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
	if (error == LED_NO_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
		led_state_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
	else if (error == LED_AUTOBITRATE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
		led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
		led_sequence_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
		led_start_timer(d, 50);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
	else if (error > led_error_code)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
		if (error & LED_INVALID_CONFIG)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
			led_sequence_red = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
		
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
		else if (error & LED_WARNING_LIMIT_REACH)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
			led_sequence_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
		else if (error & LED_ERROR_CTRL_EVENT)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
			led_sequence_red = 3;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
		else if (error & LED_SYNC_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
			led_sequence_red = 4;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
		else if (error & LED_EVENT_TIMER_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
			led_sequence_green = 5;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
		else if (error & LED_BUS_OFF)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
			led_state_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
		led_start_timer(d, 200);
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   173
		//led_set_red(led_state_red);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   174
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
	if (led_state_green < 2  &&  led_state_red < 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
		led_stop_timer();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   180
		//led_set_green(led_state_green);
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   181
		//led_set_red(led_state_red);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   182
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   183
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   184
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   185
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   186
void led_start_timer(CO_Data* d, UNS32 tm)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
	SetAlarm(d, 0, &led_callback, MS_TO_TIMEVAL(tm), MS_TO_TIMEVAL(tm));
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
	led_seq_index_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
	led_seq_index_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   193
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   194
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   195
void led_stop_timer(void)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   197
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   198
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   199
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   200
void led_callback(CO_Data *d, UNS32 id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
{
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   202
	UNS8 bits = 0;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   203
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
	// RED LED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
	if (led_sequence_table[led_sequence_red][led_seq_index_red] == '1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
		if (led_state_red > 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
			bits = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
			/* led_set_red(1); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
	else	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
	{	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
		/*if (led_state_red != 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
			led_set_red(0);*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
	led_seq_index_red++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
	if (led_seq_index_red > strlen(led_sequence_table[led_sequence_red]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
		led_seq_index_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
	// GREEN LED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
	if (led_sequence_table[led_sequence_green][led_seq_index_green] == '1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
		if (led_state_green > 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
			bits = bits | 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
			/* led_set_green(1); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
	else	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
	{	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
		/* if (led_state_green != 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
			led_set_green(0); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   233
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
	led_seq_index_green++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
	if (led_seq_index_green > strlen(led_sequence_table[led_sequence_green]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
		led_seq_index_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   238
	led_set_redgreen(d, bits);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   239
}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   240
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   241
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   242
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   243
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   244
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   245
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   246
char state(state);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   248
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
Input function to set all the bihaviour indicator
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
typical state are:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
	NoError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
		RedLED=off
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
	AutoBitRate_LSS
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
		RedLED=flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
		GreenLED=flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
	InvalidConfiguration
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
		RedLED=blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
	WarningLimitReached
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
		RedLED=singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
	ErrorControlEvent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
		RedLED=doubleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
	SyncError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
		RedLED=tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
	EventTimerError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
		RedLED=quadrupleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
	BusOFF
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
		RedLED=on
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
	PRE_OPERATIONAL	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
		GreenLED=blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
	STOPPED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
		GreenLED=singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
	Programm_Firmware_download
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   273
		GreenLED=tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   274
	OPERATIONNAL
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   275
		GreenLED=on
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   277
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   278
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   279
case LEDbihaviour:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
	on
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
	flickeringerror
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
		RedLED(on)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
		RedLED(off)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
	flickeringerror
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
		GreenLED(off)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
		GreenLED(on)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
	blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   289
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
	singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
	doubleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   293
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   294
	tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   295
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   296
	quadrupleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   297
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   298
	off
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   299
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   300
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   301
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   302
char  LED(bitLEDs);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   304
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   305
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   306
Output function to call the driver.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   307
	if bit=0, then turn LED Off
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
	if bit=1, then turn LED On
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   309
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
bit#	color		name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
0	red		error/status
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   312
1	green		run/status
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   313
2
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   314
3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   315
4
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   316
5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   317
6	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   319
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320