#ifndef __SPI_MASTER_H #define __SPI_MASTER_H //----------------------------------------------------------------------------- #include "typedefs.h" #include "application.h" #include "usart.h" //----------------------------------------------------------------------------- // Port Definitions #define SPI_PRT PORTB #define SPI_DDR DDRB // Bit Definitions #define SPI_SCLK PB7 #define SPI_MOSI PB5 #define SPI_MISO PB6 // #define SPI_SS PB4 // not in this application!!! danger #define SPI_E_CS PB4 //device 0 #define SPI_AD_CS PD3 //device 1 #define SPI_M_CS PD4 //device 2 #define SPI_A_CS PD5 //device 3 #define SPI_READ_BUFFER_SIZE 16 #define SPI_WRITE_BUFFER_SIZE 16 #define SPI_MAX_SLAVE_INDEX 2 #define SPI_MAX_CLOCK_INDEX 6 //----------------------------------------------------------------------------- extern volatile U08 spi_clock_index; extern volatile U08 spi_cpol; extern volatile U08 spi_cpha; extern volatile U08 spi_dord; extern volatile U08 SPI_DEVICE_SS[4]; extern volatile BOOL SPI_DEVICE_ACTIVE_HIGH[4]; extern volatile U08 spi_read_buffer[SPI_READ_BUFFER_SIZE]; extern volatile U08 spi_write_buffer[SPI_WRITE_BUFFER_SIZE]; //----------------------------------------------------------------------------- void spi_init(void); void spi_transfer(U08 bytes, U08 device); U08 spi_transfer_byte(U08 data); void spi_set_clock_index(U08 clock_index); void spi_set_dord(U08 dord); void spi_set_cpol(U08 cpol); void spi_set_cpha(U08 cpha); void spi_setup(void); void spi_transfer_string(U08 length, U08* addr, U08 device); //----------------------------------------------------------------------------- #endif