Project

General

Profile

Revision 410

works for real this time! I haven't tried actually running a current through the board, but without that it shows proper debug values and Robot Debug/main.c formats them nicely!

View differences:

main.c
1 1
#include <dragonfly_lib.h>
2 2
#include <i2c.h>
3 3

  
4
volatile uint32_t byte;
5
volatile short code, next;
6

  
4 7
void recv(char i2c_byte){
5
	usb_putc(i2c_byte);
8
    static char str[8];
9

  
10
    if(code){
11
        if(next==0){
12
            byte = i2c_byte<<8; //get first byte in int
13
            next = 1;
14
        }
15
        else{
16
            byte |= i2c_byte; //get second byte in int
17
            itoa(byte,str,10);
18
            
19
            usb_puts(str);
20
            usb_putc('\t');
21
            
22
            if(code==2)
23
                usb_puts("\r\n"); //newline for easy to read output
24
            
25
            byte=0;
26
            code=0;
27
            next=0;
28
        }
29
    }
30
    else {
31
    
32
        //if the byte is a debug control then set code to 1, otherwise, print it
33
        switch(i2c_byte){
34
            case 'C':
35
            case 'P':
36
            case 'I':
37
            case 'V':
38
                code = 1;
39
                break;
40
            case 'T':
41
                code = 2; //T is last, put a newline after it
42
                break;
43
                
44
            default:
45
                usb_putc(i2c_byte);
46
                break;
47
        }
48
        
49
    }
6 50
}
7 51

  
8
int main(){
52
int main( void ){
9 53

  
10 54
	dragonfly_init(ALL_ON);
11 55
	sei();
56
    code = 0;
57
    byte = 0;
58
    next = 0;
12 59
	i2c_init(0x01, NULL, recv, NULL);
13 60
	
14 61
	usb_puts("init'd everything.\r\n");

Also available in: Unified diff