diff options
Diffstat (limited to 'SPI.c')
-rw-r--r-- | SPI.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -39,6 +39,20 @@ //if (Ohm_68 == 5) WriteBuffer[3]|= 0b10000000; readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); } + uint8_t active150() + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0b01000000; + WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x00; + readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); + return (bitcount(ReadBuffer[5]) + bitcount(ReadBuffer[3] << 1)); + } + uint8_t active68() + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0b01000000; + WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x00; + readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); + return ((ReadBuffer[3] >> 7) + bitcount(ReadBuffer[1] << 1)); + } void Message_BIM(uint8_t outputs[3]) { @@ -161,3 +175,14 @@ WriteBuffer[3] = outputs[1]; WriteBuffer[5] = outputs[2]; } + +uint8_t bitcount(uint8_t n) +{ + uint8_t count = 0; + while (n > 0) + { + count++; + n = n & (n-1); + } + return count; +} |