AccelStepperI2C
v 0.1
I2C wrapper (and a bit more) for the AccelStepper Arduino library
|
Go to the documentation of this file.
18 buffer =
new uint8_t [buflen];
30 uint8_t SimpleBuffer::calculateCRC8 ()
33 uint8_t len =
idx - 1;
36 uint8_t inbyte = *
addr++;
37 for (uint8_t i = 8; i; i--) {
38 uint8_t mix = (crc ^ inbyte) & 0x01;
51 buffer[0] = calculateCRC8();
56 return buffer[0] == calculateCRC8();
void setCRC8()
Calculate CRC8 checksum for the currently used buffer ([1]...[idx-1]) and store it in the first byte ...
bool checkCRC8()
Check for correct CRC8 checksum. First byte [0] holds the checksum, rest of the currently used buffer...
uint8_t idx
The position pointer. Remember, [0] holds the CRC8 checksum, so for an empty buffer,...
void init(uint8_t buflen)
Allocate and reset buffer.
void reset()
Reset the position pointer to the start of the buffer (which is[1] as [0] is the CRC8 chcksum) withou...
uint8_t maxLen
Maximum length of buffer in bytes. Read and write operations use this to check for sufficient space (...
Simple and ugly serialization buffer for any data type. Template technique and CRC8 adapted from Nick...
uint8_t * buffer
The allocated buffer.