Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
601 | ddp | 1 | #include "_global.h" |
2 | #include "_output.h" |
||
3 | #include "_uart.h" |
||
4 | #include <util/delay_basic.h> |
||
5 | |||
6 | //----------------------------------------------------------------------------- |
||
7 | |||
8 | void PinTest(void) |
||
9 | { |
||
10 | u8 err, tmp; |
||
11 | |||
12 | err=0; // ��ઠ ����� UART TX |
||
13 | PORTD|=(1<<PD3); |
||
14 | _delay_loop_1(3); |
||
15 | if (!(PIND&(1<<PD3))) err|=0x01; |
||
16 | PORTD&=~(1<<PD3); |
||
17 | DDRD|=(1<<PD3); |
||
18 | _delay_loop_1(3); |
||
19 | if (PIND&(1<<PD3)) err|=0x02; |
||
20 | DDRD&=~(1<<PD3); |
||
21 | |||
22 | if (err) // ����� � ������ UART TX |
||
23 | { // 堮��᪨ ������ �.������ |
||
24 | DDRB|=(1<<PB7); |
||
25 | while (1) |
||
26 | { |
||
27 | PORTB&=~(1<<PB7); // led off |
||
28 | if (random8()&0x01) PORTB|=(1<<PB7); // led on |
||
29 | _delay_loop_2(0x6c00); |
||
30 | } |
||
31 | } |
||
32 | // ���� � ����� UART TX ��� - |
||
33 | directuart_init(); // - �������㥬 UART ��� ���� FIFO |
||
34 | directuart_crlf(); |
||
35 | directuart_crlf(); |
||
36 | directuart_crlf(); |
||
37 | print_msg(msg_title1); |
||
38 | print_short_vers(); |
||
39 | print_mlmsg(mlmsg_pintest); |
||
40 | // ��ઠ �����. 1 �⠯. |
||
41 | PORTA=0b01010101; |
||
42 | DDRA =0b10101010; |
||
43 | PORTB=0b10000010; |
||
44 | DDRB =0b00000101; |
||
45 | PORTC=0b00010101; |
||
46 | DDRC =0b00001010; |
||
47 | PORTD|= (1<<PD5); |
||
48 | DDRD &=~(1<<PD5); |
||
49 | PORTE|= (1<<PE0); |
||
50 | DDRE &=~(1<<PE0); |
||
51 | PORTE&=~(1<<PE1); |
||
52 | DDRE |= (1<<PE1); |
||
53 | PORTG=0b00010101; |
||
54 | DDRG =0b00001010; |
||
55 | _delay_loop_2(276); // 100 us |
||
56 | |||
57 | err=0; |
||
58 | tmp=PINA; |
||
59 | if (tmp!=0b01010101) err|=0x01; |
||
60 | tmp=PINB; |
||
61 | if ((tmp&0b10000111)!=0b10000000) err|=0x02; |
||
62 | tmp=PINC; |
||
63 | if ((tmp&0b00011111)!=0b00010101) err|=0x04; |
||
64 | if (!(PIND&(1<<PD5))) err|=0x08; |
||
65 | tmp=PINE; |
||
66 | if ((tmp&0b00000011)!=0b00000001) err|=0x10; |
||
67 | tmp=PING; |
||
68 | if ((tmp&0b00011111)!=0b00010101) err|=0x20; |
||
69 | // ��ઠ �����. 2 �⠯. |
||
70 | PORTA=0b10101010; |
||
71 | DDRA =0b01010101; |
||
72 | PORTB=0b00000101; |
||
73 | DDRB =0b10000010; |
||
74 | PORTC=0b00001010; |
||
75 | DDRC =0b00010101; |
||
76 | PORTD&=~(1<<PD5); |
||
77 | DDRD |= (1<<PD5); |
||
78 | PORTE&=~(1<<PE0); |
||
79 | DDRE |= (1<<PE0); |
||
80 | PORTE|= (1<<PE1); |
||
81 | DDRE &=~(1<<PE1); |
||
82 | PORTG=0b00001010; |
||
83 | DDRG =0b00010101; |
||
84 | _delay_loop_2(276); // 100 us |
||
85 | |||
86 | tmp=PINA; |
||
87 | if (tmp!=0b10101010) err|=0x01; |
||
88 | tmp=PINB; |
||
89 | if ((tmp&0b10000111)!=0b00000101) err|=0x02; |
||
90 | tmp=PINC; |
||
91 | if ((tmp&0b00011111)!=0b00001010) err|=0x04; |
||
92 | if (PIND&(1<<PD5)) err|=0x08; |
||
93 | tmp=PINE; |
||
94 | if ((tmp&0b00000011)!=0b00000010) err|=0x10; |
||
95 | tmp=PING; |
||
96 | if ((tmp&0b00011111)!=0b00001010) err|=0x20; |
||
97 | // �⮣, ����� १���� |
||
98 | if (err) |
||
99 | { |
||
100 | u16 ptr; |
||
101 | ptr=0x0020; |
||
102 | while (ptr<0x003c) *(u8*)(ptr++)=0; |
||
103 | ptr=0x0061; |
||
104 | while (ptr<0x0066) *(u8*)(ptr++)=0; |
||
105 | print_mlmsg(mlmsg_pintest_error); |
||
106 | if (err&0x01) print_msg(msg_pintest_pa); |
||
107 | if (err&0x02) print_msg(msg_pintest_pb); |
||
108 | if (err&0x04) print_msg(msg_pintest_pc); |
||
109 | if (err&0x08) print_msg(msg_pintest_pd); |
||
110 | if (err&0x10) print_msg(msg_pintest_pe); |
||
111 | if (err&0x20) print_msg(msg_pintest_pg); |
||
112 | print_mlmsg(mlmsg_halt); |
||
113 | while (1) {} |
||
114 | } |
||
115 | else |
||
116 | { |
||
117 | print_mlmsg(mlmsg_pintest_ok); |
||
118 | } |
||
119 | } |
||
120 | |||
121 | //----------------------------------------------------------------------------- |