#define SPI_CSS_ANSEL ANSELBbits.ANSB0
#define SPI_CS1_ANSEL ANSELBbits.ANSB2
#define SPI_CS2_ANSEL ANSELBbits.ANSB4
#define SPI_CS3_ANSEL ANSELBbits.ANSB5
#define SPI_CS4_ANSEL ANSELGbits.ANSG9
#define SPI_SDI_ANSEL ANSELBbits.ANSB3
#define SPI_SDO_ANSEL ANSELBbits.ANSB1
#define SPI_SCK_ANSEL ANSELGbits.ANSG6

#define DET_TRIS TRISFbits.TRISF3
#define SPI_CSS_TRIS TRISBbits.TRISB0
#define SPI_CS1_TRIS TRISBbits.TRISB2
#define SPI_CS2_TRIS TRISBbits.TRISB4
#define SPI_CS3_TRIS TRISBbits.TRISB5
#define SPI_CS4_TRIS TRISGbits.TRISG9
#define SPI_SDI_TRIS TRISBbits.TRISB3
#define SPI_SDO_TRIS TRISBbits.TRISB1
#define SPI_SCK_TRIS TRISGbits.TRISG6

#define SPI_CSS LATBbits.LATB0
#define SPI_CS1 LATBbits.LATB2
#define SPI_CS2 LATBbits.LATB4
#define SPI_CS3 LATBbits.LATB5
#define SPI_CS4 LATGbits.LATG9

#define DET_PORT PORTFbits.RF3

void initSpi(void);
void masterSpi(void);
void slaveSpi(void);
unsigned char putSpi(unsigned char data);