Project

General

Profile

Statistics
| Revision:

root / trunk / code / lib / include / libdragonfly / spi.h @ 1461

History | View | Annotate | Download (861 Bytes)

1
/**
2
 * @file spi.h
3
 * @brief Definitions for SPI
4
 * @author Colony Project, CMU Robotics Club
5
 **/
6

    
7
/**
8
 * @addtogroup spi
9
 * @{
10
 **/
11

    
12
#ifndef __SPI_H__
13
#define __SPI_H__
14

    
15
#include<dragonfly_lib.h>
16

    
17
#define DOUBLE_SCK 1
18
#define SPR0_BIT 1
19

    
20
#define MASTER 1
21
#define SLAVE 0
22

    
23
#define MOSI _BV(PB2)
24
#define MISO _BV(PB3)
25
#define SS   _BV(PB0)
26
#define SCLK _BV(PB1)
27

    
28
typedef void (*spi_fun_recv_t)(char);
29
typedef void (*spi_fun_recv_complete_t)(void);
30

    
31
/** 
32
* @brief Initialize SPI
33
* 
34
* @param spi_fun_recv_t The function that handles SPI data, byte for byte.
35
* @param spi_fun_recv_complete_t  Called on a completed transmission - typically for cleaning up.
36
*/
37
int spi_init (spi_fun_recv_t, spi_fun_recv_complete_t);
38

    
39
/** 
40
* @brief Initialize SPI transfer.
41
* 
42
* @param char The number of bytes to transfer.
43
*/
44
int spi_transfer (char);
45

    
46
/**@}**/ //end group
47

    
48
#endif