Project

General

Profile

Statistics
| Revision:

root / branches / encoders / code / projects / template / main.c @ 546

History | View | Annotate | Download (633 Bytes)

1
#include <dragonfly_lib.h>
2
#include "spi.h"
3

    
4
#define MODE 0
5
#define TEST 1
6
extern char spi_status;
7

    
8
void recv_func(char c) {
9
    if (c != '\n');
10
        if(MODE)
11
                usb_puts("MASTER");
12
        else
13
                usb_puts("SLAVE");
14
        
15
        usb_puts(": received [");usb_putc(c);usb_puts("]\n\r");
16
        return;
17
}
18

    
19

    
20

    
21
int main(void)
22
{
23
        dragonfly_init(ALL_ON);
24
        spi_init(MODE, recv_func);
25
        usb_puts("Init done\n\r");
26
        while(1) {
27
                if(TEST){
28
                        if(MODE){
29
                                spi_read(6);
30
                                delay_ms(1000);
31
                        } else {
32
                                //if(!(spi_status & SPI_SEND))
33
                                spi_send("SLAVE ",6);
34
                                //delay_ms(800);
35
                        }
36
                } else {
37
                        if (MODE) {
38
                                spi_send("MASTER",6);
39
                        }
40
                }
41
                
42
        }
43
        
44
        return 0;
45
        
46
}
47