/*
* TWIlib.c
*
* Created: 6/01/2014 10:41:33 PM
* Author: Chris Herring
*/
// Global transmit buffer
volatile uint8_t *TWITransmitBuffer;
// Global receive buffer
volatile uint8_t TWIReceiveBuffer;
// Buffer indexes
volatile int TXBuffIndex; // Index of the transmit buffer. Is volatile, can change at any time.
int RXBuffIndex; // Current index in the receive buffer
// Buffer lengths
int TXBuffLen; // The total length of the transmit buffer
int RXBuffLen; // The total number of bytes to read (should be less than RXMAXBUFFLEN)
TWIInfoStruct TWIInfo;
void
uint8_t
void
// uint8_t TWITransmitData(void *const TXdata, uint8_t dataLen, uint8_t repStart)
// {
// if (dataLen <= TXMAXBUFLEN)
// {
// // Wait until ready
// while (!isTWIReady()) {_delay_us(1);}
// // Set repeated start mode
// TWIInfo.repStart = repStart;
// // Copy data into the transmit buffer
// uint8_t *data = (uint8_t *)TXdata;
// for (int i = 0; i < dataLen; i++)
// {
// TWITransmitBuffer[i] = data[i];
// }
// // Copy transmit info to global variables
// TXBuffLen = dataLen;
// TXBuffIndex = 0;
// // If a repeated start has been sent, then devices are already listening for an address
// // and another start does not need to be sent.
// if (TWIInfo.mode == RepeatedStartSent)
// {
// TWIInfo.mode = Initializing;
// TWDR = TWITransmitBuffer[TXBuffIndex++]; // Load data to transmit buffer
// TWISendTransmit(); // Send the data
// }
// else // Otherwise, just send the normal start signal to begin transmission.
// {
// TWIInfo.mode = Initializing;
// TWISendStart();
// }
// }
// else
// {
// return 1; // return an error if data length is longer than buffer
// }
// return 0;
// }
uint8_t