Project

General

Profile

Revision 490

Added by Ben Poole over 14 years ago

slave -> master kind of works

View differences:

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

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

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

  
......
16 20
{
17 21
	dragonfly_init(ALL_ON);
18 22
	spi_init(MODE, recv_func);
19
	usb_puts("Init done\r\n");
23
	usb_puts("Init done\n\r");
20 24
	while(1) {
21
	//usb_puts("loop\r\n");
22
		if (MODE) {
23
			spi_master_recv_on();
24
		}else {
25
			SPDR = 'b';
26
		//	delay_ms(10);
25
		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
			}
27 37
		}
28 38
		
29 39
	}

Also available in: Unified diff