root / branches / encoders / code / projects / libdragonfly / spi.h @ 546
History | View | Annotate | Download (642 Bytes)
1 | 490 | bpoole | #ifndef __SPI_H__
|
---|---|---|---|
2 | #define __SPI_H__
|
||
3 | |||
4 | 317 | bpoole | #define DOUBLE_SCK 1 |
5 | #define SPR0_BIT 1 |
||
6 | #define LSB 1 |
||
7 | #define MSB 0 |
||
8 | #define MASTER 1 |
||
9 | #define SLAVE 0 |
||
10 | |||
11 | 546 | kwoo | #define SPI_IDLE 0x00 |
12 | #define SPI_SEND 0x01 |
||
13 | #define SPI_RECV 0x02 |
||
14 | #define SPI_BOTH 0x03 |
||
15 | 490 | bpoole | |
16 | |||
17 | 350 | kwoo | /* Pin Defines */
|
18 | #define MOSI _BV(PB2)
|
||
19 | #define MISO _BV(PB3)
|
||
20 | #define SS _BV(PB0)
|
||
21 | #define SCLK _BV(PB1)
|
||
22 | |||
23 | 546 | kwoo | //#define size_t int
|
24 | 317 | bpoole | typedef void (*spi_fun_recv_t)(char); |
25 | typedef void (*spi_fun_send_t)(char); |
||
26 | 367 | kwoo | void spi_init(char mode, spi_fun_recv_t recv_func); |
27 | 546 | kwoo | int spi_send(char *data, int bytes); |
28 | 367 | kwoo | void spi_master_recv_on(void); |
29 | void spi_master_recv_off(void); |
||
30 | 490 | bpoole | void spi_read_one(void); |
31 | 546 | kwoo | void spi_read(int bytes); |
32 | 490 | bpoole | |
33 | #endif |