From ed2644ef4e934f2f7cf93890760737790925a1c8 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Thu, 6 Jun 2024 16:23:43 -0500 Subject: Changed loss of connection behavior and cleaned up code. --- SPI.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'SPI.c') diff --git a/SPI.c b/SPI.c index 96a18a8..1fff384 100644 --- a/SPI.c +++ b/SPI.c @@ -38,7 +38,7 @@ if(Ohm_150>7)WriteBuffer[3] = 0x7f; else WriteBuffer[3] = (0x7f >> (7-Ohm_150));// + ((Ohm_68 - 4)<<7); - WriteBuffer[5] = 0xff >> (15-Ohm_150); + WriteBuffer[5] = 0xff << (15-Ohm_150); if(Ohm_68<5)WriteBuffer[1] = ((0xf0 >> (Ohm_68))&0x0f)| (testLED << 7); else {WriteBuffer[1] = 0x0f | (testLED << 7); WriteBuffer[3] |= 0x80;} //WriteBuffer[1] = 0xFF; @@ -46,15 +46,16 @@ SPI_slaveSelect(); readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); SPI_slaveDeselect(); + //if(ReadBuffer[5]>0)_LATB8 = 0; } void active(uint8_t *activeResistors) { - WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x40; + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x40; //Output driver data will be received by host controller after next message is sent. WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x02; SPI_slaveSelect(); readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); SPI_slaveDeselect(); - WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x00; + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x00; //Output diagnostic data on next frame WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0x00; SPI_slaveSelect(); readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); @@ -132,12 +133,10 @@ SPI_slaveDeselect(); } - void Message_HWCROCL(uint8_t outputs[3]) + void Message_HWCROCL() { WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x8D; - WriteBuffer[1] = outputs[0]; - WriteBuffer[3] = outputs[1]; - WriteBuffer[5] = outputs[2]; + WriteBuffer[1] = WriteBuffer[3] = WriteBuffer[5] = 0xff; } void Message_HWCRPWM(uint8_t outputs[3]) -- cgit v1.2.3