Revision 3

View differences:

trunk/tp_info6/bsp/periph.c
16 16

  
17 17

  
18 18

  
19
Tperiph periph[26];
19
Tperiph periph['z'-'A'];
20 20

  
21 21
#define eot 0x0D
22 22

  
......
25 25
int i;
26 26
	uart0_init();
27 27
    dma0_init();
28
	for (i=0;i<26;i++)
28
	for (i=0;i<'z'-'A';i++)
29 29
		periph[i].maj=periph[i].val=periph[i].ev=0;
30 30
		
31 31
}
......
38 38
		periph_write('I',c);
39 39
		dly_tsk(0);
40 40
		i++;
41
		if (i>=8) break;
41
		if (i>=64) break;
42 42
	}while (c=*(++nom));
43 43
	periph_write('I',0);
44 44
	dly_tsk(0);
......
107 107
	ipsnd_dtq (CanTx,(VP_INT) comm.msg);	
108 108
}
109 109

  
110
static int hex_2_int (char * str)
111
{
112
	int i;
113
	long val;
114
	val=0;
115
	for (i=0;i<4;i++)
116
	{
117
		val=(val*16);
118
		val+=(str[i]>='A')?(int) str[i]-'A'+10:(int)str[i]-'0';
119
	}
120
	if (val>0x7FFF) val=val-0x10000;
121
	return val;
110
static int hex_2_int (char * str)

111
{

112
	int i;

113
	long val;

114
	val=0;

115
	for (i=0;i<4;i++)

116
	{

117
		val=(val*16);

118
		val+=(str[i]>='A')?(int) str[i]-'A'+10:(int)str[i]-'0';

119
	}

120
	if (val>0x7FFF) val=val-0x10000;

121
	return val;

122 122
}
123 123

  
124 124
static void int_2_hex(unsigned int val, char * str)
trunk/tp_info6/bsp/periph.h
1 1

  
2
#define ADDR(x) ((x & ~0x20) - 'A')
2
#define ADDR(x) (x -'A')
3 3

  
4 4
int periph_read (char addr,int * val);
5 5
void periph_write (char addr,int valeur);
......
27 27

  
28 28
void periph_init(void);
29 29

  
30
extern Tperiph periph[26];
31
extern int canal[7];
32
extern int canal_ok;
30
extern Tperiph periph['z'-'A'];

Also available in: Unified diff