Project

General

Profile

Statistics
| Revision:

root / branches / init_refactor / code / projects / unit_tests / test_usb.c @ 1547

History | View | Annotate | Download (921 Bytes)

1
#include <dragonfly_lib.h>
2

    
3
/*
4
 * This function outputs to TeraTerm the following:
5
 *
6
 * Testing...
7
 * 1, 2, 3
8
 * 2A, 00F4, C8E1
9
 * done.
10
 * 
11
 */
12

    
13
#ifdef DRAGONFLY_DEBUG
14
#error it worked?
15
#endif
16

    
17
int testusb(void) {
18
        
19
        usb_init();
20
        usb_puts("usb turned on, test starting:\r\n");
21
  
22
        usb_puts("\r\n\n");
23
        delay_ms(1000);
24
        
25
        // print some values to usb
26
  usb_puts("Testing...\r\n");
27
  usb_puti(1);
28
  usb_putc(',');
29
  usb_putc(' ');
30
  usb_puti(2);
31
  usb_putc(',');
32
  usb_putc(' ');
33
  usb_puti(3);
34
  usb_putc('\r');
35
  usb_putc('\n');
36
  usb_puth8(0x2A);  
37
  usb_putc(',');
38
  usb_putc(' ');
39
  usb_puth16(0xF4);
40
  usb_putc(',');
41
  usb_putc(' ');
42
  usb_puth(0xC8E1);
43
  usb_putc('\r');
44
  usb_putc('\n');
45
  usb_puts("enter an 'a':");  
46

    
47
  // test getting a value from usb
48
  if (usb_getc() == 'a')
49
    usb_puts("\r\ngetc() works\r\n");
50
  else
51
    usb_puts("\r\ngetc() fails\r\n");
52
  
53
  usb_puts("done.\r\n\r\n");
54
  
55
  
56
        return 0;
57
}