Project

General

Profile

Statistics
| Revision:

root / branches / encoders / code / projects / libdragonfly / spi.h @ 546

History | View | Annotate | Download (642 Bytes)

1
#ifndef __SPI_H__
2
#define __SPI_H__
3

    
4
#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
#define SPI_IDLE 0x00
12
#define SPI_SEND 0x01
13
#define SPI_RECV 0x02
14
#define SPI_BOTH 0x03
15

    
16

    
17
/* Pin Defines */
18
#define MOSI _BV(PB2)
19
#define MISO _BV(PB3)
20
#define SS _BV(PB0)
21
#define SCLK _BV(PB1)
22

    
23
//#define size_t int
24
typedef void (*spi_fun_recv_t)(char);
25
typedef void (*spi_fun_send_t)(char);
26
void spi_init(char mode, spi_fun_recv_t recv_func);
27
int spi_send(char *data, int bytes);
28
void spi_master_recv_on(void);
29
void spi_master_recv_off(void);
30
void spi_read_one(void);
31
void spi_read(int bytes);
32

    
33
#endif