This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void doTransfer(void){ | |
unsigned char byte; | |
int i; | |
SPI1TCNTH = 0; | |
SPI1TCNTL = 4; | |
transferMode = 1; | |
SPI1TXBbits.TXB = 0; | |
while(PIR2bits.SPI1TXIF == 0); | |
SPI1TXBbits.TXB = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SPI_HIGH 1 | |
#define SPI_LOW 0 | |
#define SPI_DELAY Delay1000us() | |
void pushByte(unsigned char byte){ | |
LATBbits.LATB5 = SPI_HIGH; | |
LATBbits.LATB4 = SPI_HIGH; | |
SPI_DELAY; | |
for(int i = 0; i < 8; i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//#define I2C_Allow0Adress | |
#define I2C_DefaultAddress 2 | |
//#define I2C_DoAddressShift | |
typedef enum _I2C_TYPE_DATA{ | |
NO_CHANGE_I2C_MSG = 0, | |
SINGLE_CHANGE_I2C_MSG = 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MAX_BUFFER 32 | |
// SLAVE | |
void I2C_SlaveInit(unsigned char addr); | |
void I2C_SlaveInterruptRoutine(void); | |
typedef struct _I2C_BufferInfo{ | |
unsigned char size; |