Subversion Repositories Code-Repo

Rev

Rev 316 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
315 Kevin 1
#ifndef SPI_H
2
#define	SPI_H
3
 
316 Kevin 4
#define MAX_SPI_BUFFER 64
315 Kevin 5
#define SPI_WRITE_ONLY
6
 
7
#define SPI2_FOSC_TMR2      0b0011
8
#define SPI2_FOSC_64        0b0010
9
#define SPI2_FOSC_16        0b0001
10
#define SPI2_FOSC_4         0b0000
11
 
12
typedef struct {
13
#ifndef SPI_WRITE_ONLY
14
    uint8_t buffer_in[MAX_SPI_BUFFER];
15
    uint8_t buffer_in_read_ind;
16
    uint8_t buffer_in_write_ind;
17
    uint8_t buffer_in_len;
18
#endif
19
 
20
    uint8_t buffer_out[MAX_SPI_BUFFER];
21
    uint8_t buffer_out_ind;
22
    uint8_t buffer_out_len;
23
} SPI_DATA;
24
 
25
void SPI_Init(SPI_DATA *data, uint8_t speed);
26
void SPI_Write(uint8_t *msg, uint16_t length);
27
void SPI2_Write_Repeat(uint8_t c, uint16_t length);
28
#ifndef SPI_WRITE_ONLY
29
void SPI_Recv_Interrupt_Handler(void);
30
void SPI_Read(uint8_t length);
31
uint8_t SPI_Buffer_Len(void);
32
uint8_t SPI_Read_Buffer(uint8_t *buffer);
33
#endif
34
 
35
#endif	/* SPI_H */
36