Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
360 kakl 1
//--- Diagnostika cidel a vymazani EEPROM ---
2
void diag()
3
{
4
   int8 n;
5
 
6
   // Vymaz Black Box v EEPROM
7
   for(n=0;n<255;n++) write_eeprom(n,0);
8
   bb_l[0]=0;        // Zapis na pozici 0 vzdalenost 0
9
   bb_h[0]=0;
10
   bb_f[0]=0;
11
   write_eeprom(EEMAX,0); // Zapis do EEPROM pocet zaznamu 0, tedy jeden zaznam
12
   for(n=0;n<=4;n++)
13
   {
14
      disp(0x55);       // Blikni pro potvrzeni
15
      delay_ms(200);
16
      disp(0xAA);
17
      delay_ms(200);
18
   };
19
 
20
   while(true)
21
   {
22
      if(!IRRX)
23
      {
24
         int8 ble;
25
 
26
         i2c_start();     // Cteni kompasu
27
         i2c_write(COMPAS_ADR);
28
         i2c_write(0x1);
29
         i2c_stop();
30
         i2c_start();
31
         i2c_write(COMPAS_ADR+1);
32
         ble=i2c_read(0);
33
         i2c_stop();
34
         disp(ble);
35
         delay_ms(200);
36
      }
37
      else
38
      {
39
         i2c_start();      // Diagnostika sonaru
40
         i2c_write(SONAR_ADR);
41
         i2c_write(0x02);  // dosah
42
         i2c_write(0x03);  // n*43mm
43
         i2c_stop();
44
         i2c_start();
45
         i2c_write(SONAR_ADR);
46
         i2c_write(0x01);  // zesileni
47
         i2c_write(0x01);  // male, pro eliminaci echa z minuleho mereni
48
         i2c_stop();
49
 
50
         i2c_start();     // Sonar Ping
51
         i2c_write(0xE0);
52
         i2c_write(0x0);
53
         i2c_write(0x51);  // 50 mereni v palcich, 51 mereni v cm, 52 v us
54
         i2c_stop();
55
         delay_ms(100);
56
         i2c_start();     // Odraz ze sonaru
57
         i2c_write(0xE0);
58
         i2c_write(0x3);
59
         i2c_stop();
60
         i2c_start();
61
         i2c_write(0xE1);
62
         n=i2c_read(0);
63
         i2c_stop();
64
         disp(n);  // Zobrazeni hodnoty ze sonaru a zaroven diagnostika predniho IR cidla
65
         delay_ms(200);
66
      }
67
   }
68
}