src/led.c
author lbessard
Wed, 10 Jan 2007 17:42:34 +0100
changeset 64 c72dd78e547f
parent 35 88812de1d7cc
child 71 95cd3376cc9f
permissions -rw-r--r--
Bug reported by Dean corrected
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);
31
a82b70738e5c Code clean-up and fixed xenomai compile problem
lbessard
parents: 3
diff changeset
    45
void led_set_redgreen(CO_Data *d, unsigned char state);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    46
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    47
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    48
// 0 = always off, 1 = always on, 2 = flashing
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    49
static UNS8 led_state_red, led_state_green; 
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    50
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    51
static UNS16 led_sequence_red, led_seq_index_red;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    52
static UNS16 led_sequence_green, led_seq_index_green;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    53
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    54
static UNS8 led_error_code = LED_NO_ERROR;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    55
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    56
const char *led_sequence_table[6] = // up and downs of the sequence
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    57
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    58
	"01",           // flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    59
	"01",           // blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    60
	"100000",       // single flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    61
	"10100000",     // double flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    62
	"1010100000",   // triple flash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    63
	"101010100000"  // quadruple flash
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    67
void led_set_state(CO_Data *d, int state)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    68
{
35
88812de1d7cc Bug on receiveLoopTask termination corrected
lbessard
parents: 31
diff changeset
    69
//printf("led_set_state(%x)\n", state);
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
    70
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    71
	switch(state)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    72
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    73
		case Initialisation:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    74
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    75
	must create a timer for the leds with the scheduler
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    76
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    77
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    78
		case LED_AUTOBITRATE:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    79
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    80
			led_sequence_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    81
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    82
		case Pre_operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    83
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    84
			led_sequence_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    85
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    86
		case Stopped:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    87
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    88
			led_sequence_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    89
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    90
		case LED_PRG_DOWNLOAD:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    91
			led_state_green = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    92
			led_sequence_green = 4;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    93
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    94
		case Operational:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    95
			led_state_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    96
			break;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    97
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    98
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
    99
	if (state == LED_AUTOBITRATE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   100
		led_start_timer(d, 50);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   101
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   102
	else if (led_state_green < 2  &&  led_state_red < 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   103
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   104
		led_stop_timer();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   105
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   106
		//led_set_green(led_state_green);
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   107
		//led_set_red(led_state_red);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   108
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   109
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   110
	else
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   111
		led_start_timer(d, 200);
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   115
void led_set_error(CO_Data *d, UNS8 error)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   116
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   117
	if (error == LED_NO_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   118
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   119
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   120
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   121
		led_state_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   122
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   123
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   124
	else if (error == LED_AUTOBITRATE)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   125
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   126
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   127
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   128
		led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   129
		led_sequence_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   130
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   131
		led_start_timer(d, 50);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   132
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   133
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   134
	else if (error > led_error_code)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   135
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   136
		led_error_code = error;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   137
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   138
		if (error & LED_INVALID_CONFIG)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   139
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   140
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   141
			led_sequence_red = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   142
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   143
		
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   144
		else if (error & LED_WARNING_LIMIT_REACH)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   145
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   146
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   147
			led_sequence_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   148
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   149
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   150
		else if (error & LED_ERROR_CTRL_EVENT)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   151
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   152
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   153
			led_sequence_red = 3;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   154
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   155
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   156
		else if (error & LED_SYNC_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   157
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   158
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   159
			led_sequence_red = 4;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   160
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   161
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   162
		else if (error & LED_EVENT_TIMER_ERROR)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   163
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   164
			led_state_red = 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   165
			led_sequence_green = 5;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   166
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   167
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   168
		else if (error & LED_BUS_OFF)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   169
		{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   170
			led_state_green = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   171
		}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   172
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   173
		led_start_timer(d, 200);
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   174
		//led_set_red(led_state_red);
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   175
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   176
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   177
	if (led_state_green < 2  &&  led_state_red < 2)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   178
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   179
		led_stop_timer();
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   180
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   181
		//led_set_green(led_state_green);
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   182
		//led_set_red(led_state_red);
0
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   187
void led_start_timer(CO_Data* d, UNS32 tm)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   188
{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   189
	SetAlarm(d, 0, &led_callback, MS_TO_TIMEVAL(tm), MS_TO_TIMEVAL(tm));
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   190
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   191
	led_seq_index_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   192
	led_seq_index_green = 0;
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   196
void led_stop_timer(void)
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
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   201
void led_callback(CO_Data *d, UNS32 id)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   202
{
3
d9cf34cd6823 ADDED LED to TESTMASTERSLAVE. It looks nice!
oremeq
parents: 0
diff changeset
   203
	UNS8 bits = 0;
0
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   204
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   205
	// RED LED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   206
	if (led_sequence_table[led_sequence_red][led_seq_index_red] == '1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   207
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   208
		if (led_state_red > 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   209
			bits = 1;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   210
			/* led_set_red(1); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   211
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   212
	else	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   213
	{	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   214
		/*if (led_state_red != 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   215
			led_set_red(0);*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   216
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   217
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   218
	led_seq_index_red++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   219
	if (led_seq_index_red > strlen(led_sequence_table[led_sequence_red]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   220
		led_seq_index_red = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   221
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   222
	// GREEN LED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   223
	if (led_sequence_table[led_sequence_green][led_seq_index_green] == '1')
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   224
	{
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   225
		if (led_state_green > 0)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   226
			bits = bits | 2;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   227
			/* led_set_green(1); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   228
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   229
	else	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   230
	{	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   231
		/* if (led_state_green != 1)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   232
			led_set_green(0); */
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   233
	}
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   234
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   235
	led_seq_index_green++;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   236
	if (led_seq_index_green > strlen(led_sequence_table[led_sequence_green]))
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   237
		led_seq_index_green = 0;
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   238
35
88812de1d7cc Bug on receiveLoopTask termination corrected
lbessard
parents: 31
diff changeset
   239
	//led_set_redgreen(d, bits);
0
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
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   247
char state(state);
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   248
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   249
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   250
Input function to set all the bihaviour indicator
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   251
typical state are:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   252
	NoError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   253
		RedLED=off
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   254
	AutoBitRate_LSS
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   255
		RedLED=flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   256
		GreenLED=flickering
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   257
	InvalidConfiguration
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   258
		RedLED=blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   259
	WarningLimitReached
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   260
		RedLED=singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   261
	ErrorControlEvent
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   262
		RedLED=doubleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   263
	SyncError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   264
		RedLED=tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   265
	EventTimerError
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   266
		RedLED=quadrupleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   267
	BusOFF
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   268
		RedLED=on
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   269
	PRE_OPERATIONAL	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   270
		GreenLED=blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   271
	STOPPED
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   272
		GreenLED=singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   273
	Programm_Firmware_download
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   274
		GreenLED=tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   275
	OPERATIONNAL
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   276
		GreenLED=on
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
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   280
case LEDbihaviour:
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   281
	on
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   282
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   283
	flickeringerror
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   284
		RedLED(on)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   285
		RedLED(off)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   286
	flickeringerror
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   287
		GreenLED(off)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   288
		GreenLED(on)
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   289
	blinking
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   290
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   291
	singleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   292
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   293
	doubleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   294
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   295
	tripleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   296
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   297
	quadrupleflash
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   298
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   299
	off
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
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   303
char  LED(bitLEDs);
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
/*
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   307
Output function to call the driver.
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   308
	if bit=0, then turn LED Off
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   309
	if bit=1, then turn LED On
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   310
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   311
bit#	color		name
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   312
0	red		error/status
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   313
1	green		run/status
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   314
2
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   315
3
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   316
4
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   317
5
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   318
6	
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   319
7
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   320
*/
4472ee7c6c3e Commit a new cvs repo.
etisserant
parents:
diff changeset
   321