root / trunk / code / projects / diagnostic_station / station / test_bom.c @ 1202
History | View | Annotate | Download (1.42 KB)
1 |
#include "test_bom.h" |
---|---|
2 |
#include "global.h" |
3 |
|
4 |
void test_bom_bitmask (uint16_t emitter_bitmask, uint16_t detector_bitmask)
|
5 |
{ |
6 |
usb_puts("# Testing BOM" NL);
|
7 |
|
8 |
for (uint8_t n=0; n<16; ++n, emitter_bitmask>>=1, detector_bitmask>>=1) |
9 |
{ |
10 |
if (emitter_bitmask&1) |
11 |
{ |
12 |
usb_puts("# Testing BOM emitter ");
|
13 |
usb_puti(n); |
14 |
usb_puts(NL); |
15 |
// rotate (emitter position)
|
16 |
// send (turn on only light i)
|
17 |
// wait (done)
|
18 |
// read values
|
19 |
// send (turn off lights)
|
20 |
// wait (done)
|
21 |
} |
22 |
|
23 |
if (detector_bitmask&1) |
24 |
{ |
25 |
usb_puts("# Testing BOM detector ");
|
26 |
usb_puti(n); |
27 |
usb_puts(NL); |
28 |
// rotate (detector position)
|
29 |
//
|
30 |
// turn light on
|
31 |
// send (read data)
|
32 |
// receive (data)
|
33 |
// turn lights off
|
34 |
// send (read data)
|
35 |
// receive (data)
|
36 |
} |
37 |
|
38 |
// turn lights off
|
39 |
} |
40 |
|
41 |
//send data
|
42 |
|
43 |
usb_puts("# Testing BOM finished" NL);
|
44 |
} |
45 |
|
46 |
void test_bom (uint8_t num, bool test_emitter, bool test_detector) |
47 |
{ |
48 |
uint16_t emitter_bitmask=0, detector_bitmask=0; |
49 |
|
50 |
if (test_emitter && num<16) emitter_bitmask =1<<num; |
51 |
if (test_detector && num<16) detector_bitmask=1<<num; |
52 |
|
53 |
test_bom_bitmask (emitter_bitmask, detector_bitmask); |
54 |
} |
55 |
|
56 |
void test_bom_all (bool test_emitters, bool test_detectors) |
57 |
{ |
58 |
uint16_t emitter_bitmask=0, detector_bitmask=0; |
59 |
|
60 |
if (test_emitters ) emitter_bitmask =0xFFFF; |
61 |
if (test_detectors) detector_bitmask=0xFFFF; |
62 |
|
63 |
test_bom_bitmask (emitter_bitmask, detector_bitmask); |
64 |
} |