Project

General

Profile

Revision 565

Added by Kevin Woo over 14 years ago

More testing. Transmission is messed up.

View differences:

main.c
2 2
#include "spi.h"
3 3

  
4 4
#define MODE 0
5
#define TEST 1
5
#define TEST 0
6

  
6 7
extern char spi_status;
7 8

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

  
16 21
	return;
17 22
}
18 23

  
......
22 27
{
23 28
	dragonfly_init(ALL_ON);
24 29
	spi_init(MODE, recv_func);
25
	usb_puts("Init done\n\r");
30
	usb_puts("Init done.\n\r");
31
/*
32
    if (TEST) {
33
        if (MODE) {
34
            while (1) {
35
                spi_read(6);
36
                delay_ms(1000);	
37
            }
38
        } else {
39
            spi_send("SLAVE", 5);
40
        }
41
        
42
    
43
    }
44

  
45
    while(1);
46
*/
47

  
26 48
	while(1) {
27 49
		if(TEST){
28 50
			if(MODE){
......
30 52
				delay_ms(1000);
31 53
			} else {
32 54
				//if(!(spi_status & SPI_SEND))
33
				spi_send("SLAVE ",6);
34
				//delay_ms(800);
55
				spi_send("SLAVE", 5);
56
				
57
				
35 58
			}
36 59
		} else {
37 60
			if (MODE) {
......
40 63
		}
41 64
		
42 65
	}
43
	
66
//	*/
44 67
	return 0;
45 68
	
46 69
}

Also available in: Unified diff