From fe7e5b97a50fa66aadb11e20b8f5210e1cb6dde6 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Thu, 7 Mar 2024 12:48:29 -0600 Subject: Finished Arduino Program. --- SPI.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'SPI.c') diff --git a/SPI.c b/SPI.c index 46c31bc..5ab0a2f 100644 --- a/SPI.c +++ b/SPI.c @@ -7,14 +7,15 @@ #include "SPI.h" +#include "mcc_generated_files/mssp1_spi.h" - uint16_t WriteBuffer[MY_BUFFER_SIZE]; - uint16_t ReadBuffer[MY_BUFFER_SIZE]; + uint8_t WriteBuffer[MY_BUFFER_SIZE]; + uint8_t ReadBuffer[MY_BUFFER_SIZE]; uint16_t writeData; uint16_t readData; uint8_t addr0; uint8_t addr1; - bool write; + uint8_t write; unsigned int total; /*do @@ -25,15 +26,17 @@ } while( total < MY_BUFFER_SIZE );*/ - void Message_OUT(uint8_t Ohm_150, uint8_t Ohm_68, bool testLED) + void Message_OUT(uint8_t Ohm_150, uint8_t Ohm_68, uint8_t 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[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000000; + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0b10000000; 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; + //if (Ohm_68 == 5) WriteBuffer[3]|= 0b10000000; + readData = MSSP1_SPI_Exchange8bitBuffer(WriteBuffer, 6, ReadBuffer); } void Message_BIM(uint8_t outputs[3]) @@ -94,10 +97,14 @@ void Message_HWCR(uint8_t outputs[3]) { - WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001100; - WriteBuffer[1] = outputs[0]; - WriteBuffer[3] = outputs[1]; - WriteBuffer[5] = outputs[2]; + //WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001100; + //WriteBuffer[1] = outputs[0]; + //WriteBuffer[3] = outputs[1]; + //WriteBuffer[5] = outputs[2]; + + WriteBuffer[0] = 0b10001100; + WriteBuffer[1] = 0b10000000; + readData = MSSP1_SPI_Exchange8bitBuffer(*WriteBuffer, 2, *ReadBuffer); } void Message_HWCROCL(uint8_t outputs[3]) -- cgit v1.2.3