Revision 1496
Reverted "libdragonfly" folder back to version before Init Checking was implemented and did "make dist" to recompile the library. BOM LEDs now shine
correctly.
spi.c | ||
---|---|---|
6 | 6 |
**/ |
7 | 7 |
|
8 | 8 |
#include <avr/interrupt.h> |
9 |
|
|
10 |
#include "dragonfly_defs.h" |
|
11 | 9 |
#include "spi.h" |
12 | 10 |
|
13 |
unsigned char spi_initd=0; |
|
14 | 11 |
|
15 | 12 |
static volatile char spi_bytes; /* number of bytes to read */ |
16 | 13 |
static spi_fun_recv_t spi_recv_func; /* byte handler */ |
... | ... | |
21 | 18 |
* |
22 | 19 |
* @param recv_func The function to be called for each byte of data received. |
23 | 20 |
* @param recv_complete_func The function to be called at the end of a complete transmission. |
24 |
* |
|
25 |
* @return 0 if init succesfull, an error code otherwise |
|
26 | 21 |
*/ |
27 |
int spi_init (spi_fun_recv_t recv_func, spi_fun_recv_complete_t recv_complete_func)
|
|
22 |
void spi_init (spi_fun_recv_t recv_func, spi_fun_recv_complete_t recv_complete_func)
|
|
28 | 23 |
{ |
29 |
if(spi_initd) { |
|
30 |
return ERROR_INIT_ALREADY_INITD; |
|
31 |
} |
|
32 |
|
|
33 | 24 |
/* Enable Interrupt, Enable SPI Module, MSB First, Master Mode, Clock div = 64 */ |
34 | 25 |
SPCR = _BV(SPE) | _BV(SPIE) /*| _BV(DORD)*/ | _BV(MSTR) | _BV(SPR1) | _BV(SPR0); |
35 | 26 |
SPSR = _BV(SPI2X); |
... | ... | |
46 | 37 |
spi_recv_complete_func = recv_complete_func; |
47 | 38 |
spi_bytes = 0; |
48 | 39 |
//usb_puts("\tspi.c Debug: SPI INITIALIZED\n"); |
49 |
|
|
50 |
spi_initd=1; |
|
51 |
return 0; |
|
52 | 40 |
} |
53 | 41 |
|
54 | 42 |
/** |
... | ... | |
56 | 44 |
* |
57 | 45 |
* @param bytes The number of bytes to be transferred. |
58 | 46 |
**/ |
59 |
int spi_transfer(char bytes)
|
|
47 |
void spi_transfer(char bytes)
|
|
60 | 48 |
{ |
61 |
if(!spi_initd) |
|
62 |
return ERROR_LIBRARY_NOT_INITD; |
|
63 |
|
|
64 | 49 |
spi_bytes = bytes; |
65 | 50 |
PORTB &= ~SS; /* Set SS low to initiate transmission */ |
66 | 51 |
SPDR = 0xff; /* Initiate data transmision */ |
67 |
|
|
68 |
return 0; |
|
69 | 52 |
} |
70 | 53 |
|
71 | 54 |
ISR(SIG_SPI) |
Also available in: Unified diff