root / branches / encoders / code / projects / template / main.c @ 490
History | View | Annotate | Download (589 Bytes)
1 | 16 | bcoltin | #include <dragonfly_lib.h> |
---|---|---|---|
2 | 367 | kwoo | #include "spi.h" |
3 | 16 | bcoltin | |
4 | 446 | bpoole | #define MODE 0 |
5 | 490 | bpoole | #define TEST 1 |
6 | extern char spi_status; |
||
7 | 257 | ayeager | |
8 | 367 | kwoo | void recv_func(char c) { |
9 | 490 | bpoole | if(MODE)
|
10 | usb_puts("MASTER");
|
||
11 | else
|
||
12 | usb_puts("SLAVE");
|
||
13 | usb_puts(": received [");usb_putc(c);usb_puts("]\n\r"); |
||
14 | 367 | kwoo | return;
|
15 | 193 | ayeager | } |
16 | |||
17 | |||
18 | |||
19 | 16 | bcoltin | int main(void) |
20 | { |
||
21 | dragonfly_init(ALL_ON); |
||
22 | 367 | kwoo | spi_init(MODE, recv_func); |
23 | 490 | bpoole | usb_puts("Init done\n\r");
|
24 | 367 | kwoo | while(1) { |
25 | 490 | bpoole | if(TEST){
|
26 | if(MODE){
|
||
27 | spi_read_one(); |
||
28 | delay_ms(1000);
|
||
29 | } else {
|
||
30 | if(!(spi_status &SPI_SEND))
|
||
31 | spi_send("SLAVE",6); |
||
32 | } |
||
33 | } else {
|
||
34 | if (MODE) {
|
||
35 | spi_send("MASTER",6); |
||
36 | } |
||
37 | 257 | ayeager | } |
38 | 367 | kwoo | |
39 | } |
||
40 | 257 | ayeager | |
41 | 16 | bcoltin | return 0; |
42 | 193 | ayeager | |
43 | 16 | bcoltin | } |