Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / test / test_inits.c @ 1463

History | View | Annotate | Download (1.71 KB)

1
#include <dragonfly_lib.h>
2

    
3
int testinits(void) {
4

    
5
  if(usb_init())
6
    return -1;
7

    
8
  usb_puts("usb\n");
9

    
10
  if(xbee_init()) {
11
    usb_puts("ERROR! xbee\n"); 
12
    return -1;
13
  }
14
  usb_puts("xbee\n");
15
  if(analog_init(0)) {
16
    usb_puts("ERROR! analog\n");
17
    return -1;
18
  }
19
  usb_puts("analog\n");
20
  if(bom_init(BOM15)) {
21
    usb_puts("ERROR! bom\n");
22
    return -1;
23
  }
24
  usb_puts("bom\n");
25
  if(motors_init()) {
26
    usb_puts("ERROR! motors_init\n");
27
    return -1;
28
  }
29
  usb_puts("motors\n");
30
  if(range_init()) {
31
    usb_puts("ERROR: range\n");
32
    return -1;
33
  }
34
  usb_puts("range\n");
35
  if(encoders_init()) {
36
    usb_puts("ERROR! encoders_init\n");
37
    return -1;
38
  }
39
  usb_puts("encoders\n");
40

    
41

    
42
  usb_puts("\nfirst pass done, testing re-inits\n\n");
43

    
44

    
45
  //now each of these should return ERROR_INIT_ALREADY_INITD
46
  if(usb_init() != ERROR_INIT_ALREADY_INITD) {
47
    usb_puts("ERROR! usb\n");
48
    return -1;
49
  }
50
  usb_puts("usb\n");
51

    
52
  if(xbee_init() != ERROR_INIT_ALREADY_INITD) {
53
    usb_puts("ERROR! xbee\n"); 
54
    return -1;
55
  }
56
  usb_puts("xbee\n");
57
  if(analog_init(0) != ERROR_INIT_ALREADY_INITD) {
58
    usb_puts("ERROR! analog\n");
59
    return -1;
60
  }
61
  usb_puts("analog\n");
62
  if(bom_init(BOM15) != ERROR_INIT_ALREADY_INITD) {
63
    usb_puts("ERROR! bom\n");
64
    return -1;
65
  }
66
  usb_puts("bom\n");
67
  if(motors_init() != ERROR_INIT_ALREADY_INITD) {
68
    usb_puts("ERROR! motors_init\n");
69
    return -1;
70
  }
71
  usb_puts("motors\n");
72
  if(range_init() != ERROR_INIT_ALREADY_INITD) {
73
    usb_puts("ERROR: range\n");
74
    return -1;
75
  }
76
  usb_puts("range\n");
77
  if(encoders_init() != ERROR_INIT_ALREADY_INITD) {
78
    usb_puts("ERROR! encoders_init\n");
79
    return -1;
80
  }
81
  usb_puts("encoders\n");
82

    
83

    
84
  usb_puts("init test passed!\n");
85

    
86
  return 0;
87

    
88
}