/* * File: SPI.c * Author: josh * * Created on November 2, 2023, 4:37 AM */ #include "SPI.h" uint16_t WriteBuffer[MY_BUFFER_SIZE]; uint16_t ReadBuffer[MY_BUFFER_SIZE]; uint16_t writeData; uint16_t readData; uint8_t addr0; uint8_t addr1; bool write; unsigned int total; /*do { total = MSSP1_SPI_Exchange8bitBuffer( &myWriteBuffer[total], MY_BUFFER_SIZE - total, &myWriteBuffer[total]); // Do something else... } while( total < MY_BUFFER_SIZE );*/ void Message_OUT(uint8_t Ohm_150, uint8_t Ohm_68, bool testLED) { if (Ohm_150 > 15) Ohm_150 = 15; if (Ohm_68 > 5) Ohm_68 = 5; WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) + (!write << 7) + 0b000000; WriteBuffer[1] = (0xFF << Ohm_150) ^ (0xFF); WriteBuffer[3] = (0xFF << (Ohm_150 - 8)) ^ (0xFF); WriteBuffer[5] = (0xFF << (Ohm_68 - 4)) ^ (0xFF) + (testLED << 8); if (Ohm_68 == 5) WriteBuffer[3]+= 0b10000000; } void Message_BIM(uint8_t outputs[3]) void Message_MAPIN0(uint8_t outputs[3]) void Message_MAPIN1(uint8_t outputs[3]) void Message_INST(void) void Message_DAGIOL(uint8_t outputs[3]) void Message_DAGOSM(void) void Message_DAGOLON(void) void Message_DAGOLONEN(uint8_t outputs[3]) void Message_HWCR(uint8_t outputs[3]) void Message_HWCROCL(uint8_t outputs[3]) void Message_HWCRPWM(uint8_t outputs[3]) void Message_PWMCR0(uint16_t outputs[3]) void Message_PWMCR1(uint16_t outputs[3]) void Message_PWMOUT(uint8_t outputs[3]) void Message_PWMMAP(uint8_t outputs[3]) { WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) + (!write << 7) + 0b100101; WriteBuffer[1] = outputs[0]; WriteBuffer[3] = outputs[1]; WriteBuffer[5] = outputs[2]; }