Project

General

Profile

Statistics
| Revision:

root / branches / rbom / code / projects / colonet / testing / robot_routine_reg_test / bom.c @ 1390

History | View | Annotate | Download (962 Bytes)

1 13 emarinel
#include "bom.h"
2
3
4
const int lookup[16] = {7,6,5,0xe,1,4,3,2,0xf,0,0xd,8,0xc,0xb,9,0xa};
5
6
int getMaxBom(void) {
7
        int max_bom_temp = 0;
8
        int a, i, j, h;
9
    h = 255;
10
11
    for (j = 0; j < 16; j++)
12
    {
13
      i = lookup[j];
14
15
      if (i&8)
16
        output_high(MONK3);
17
      else
18
        output_low(MONK3);
19
20
      if (i&4)
21
        output_high(MONK2);
22
      else
23
        output_low(MONK2);
24
25
      if (i&2)
26
        output_high(MONK1);
27
      else
28
        output_low(MONK1);
29
30
      if (i&1)
31
        output_high(MONK0);
32
      else
33
        output_low(MONK0);
34
35
      a = analog8(MONKI);
36
37
      if (a < h)
38
      {
39
        h = a;
40
        max_bom_temp = j;
41
      }
42
43
    }
44
45
        return max_bom_temp;
46
}
47
48
void bom_on(void)
49
{
50
  output_high(MONKL);
51
52
}
53
54
void bom_off(void)
55
{
56
  output_low(MONKL);
57
}
58
59
void output_high(int which) {
60
        digital_output(which, 1);
61
}
62
63
void output_low(int which) {
64
        digital_output(which, 0);
65
}