source: firmware/FSC/src/spi_master.h@ 10102

Last change on this file since 10102 was 10102, checked in by neise, 14 years ago
- still testing - AD7719 and ATmega ADC work muxers as well output via USB
File size: 1.7 KB
Line 
1#ifndef __SPI_MASTER_H
2#define __SPI_MASTER_H
3//-----------------------------------------------------------------------------
4
5#include "typedefs.h"
6#include "application.h"
7#include "usart.h"
8//-----------------------------------------------------------------------------
9
10// Port Definitions
11#define SPI_PRT PORTB
12#define SPI_DDR DDRB
13
14// Bit Definitions
15#define SPI_SCLK PB7
16#define SPI_MOSI PB5
17#define SPI_MISO PB6
18// #define SPI_SS PB4 // not in this application!!! danger
19#define SPI_E_CS PB4 //device 0
20#define SPI_AD_CS PD3 //device 1
21#define SPI_M_CS PD4 //device 2
22#define SPI_A_CS PD5 //device 3
23
24#define SPI_READ_BUFFER_SIZE 16
25#define SPI_WRITE_BUFFER_SIZE 16
26
27#define SPI_MAX_SLAVE_INDEX 2
28#define SPI_MAX_CLOCK_INDEX 6
29
30//-----------------------------------------------------------------------------
31
32extern volatile U08 spi_clock_index;
33extern volatile U08 spi_cpol;
34extern volatile U08 spi_cpha;
35extern volatile U08 spi_dord;
36extern volatile U08 SPI_DEVICE_SS[4];
37extern volatile BOOL SPI_DEVICE_ACTIVE_HIGH[4];
38
39extern volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE];
40extern volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE];
41//-----------------------------------------------------------------------------
42
43void spi_init(void);
44void spi_transfer(U08 bytes, U08 device);
45U08 spi_transfer_byte(U08 data);
46void spi_set_clock_index(U08 clock_index);
47void spi_set_dord(U08 dord);
48void spi_set_cpol(U08 cpol);
49void spi_set_cpha(U08 cpha);
50void spi_setup(void);
51void spi_transfer_string(U08 length, U08* addr, U08 device);
52//-----------------------------------------------------------------------------
53
54#endif
Note: See TracBrowser for help on using the repository browser.