diff options
author | Joshua Drake <joshua.ellis.drake@gmail.com> | 2023-11-03 13:22:01 -0500 |
---|---|---|
committer | Joshua Drake <joshua.ellis.drake@gmail.com> | 2023-11-03 13:22:01 -0500 |
commit | fdd6a8d9a9a8a8df0a4f5d75eef428e9f7f1ab22 (patch) | |
tree | 9d229add6e9b92a4f84d5ebe2c34eb518ccd7993 /SPI.c | |
parent | b8cf25e2ba80c484846437059563779d9ca923cc (diff) |
Finished SPI commands for NCV7755.
Diffstat (limited to 'SPI.c')
-rw-r--r-- | SPI.c | 100 |
1 files changed, 95 insertions, 5 deletions
@@ -29,45 +29,135 @@ { 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[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; + WriteBuffer[5] = (0xFF << (Ohm_68 - 4)) ^ (0xFF) | (testLED << 8); + if (Ohm_68 == 5) WriteBuffer[3]|= 0b10000000; } void Message_BIM(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000001; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_MAPIN0(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000100; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_MAPIN1(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b000101; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_INST(void) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x46; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_DAGIOL(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001000; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_DAGOSM(void) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x49; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_DAGOLON(void) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x4A; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_DAGOLONEN(uint8_t outputs[3]) - + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001011; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } + 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]; + } void Message_HWCROCL(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = 0x8D; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_HWCRPWM(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b001110; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_PWMCR0(uint16_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | (0b00010000); + WriteBuffer[0] |= ((outputs[0] << 6) >> 14; + WriteBuffer[2] |= ((outputs[1] << 6) >> 14; + WriteBuffer[4] |= ((outputs[3] << 6) >> 14; + WriteBuffer[1] = (outputs[0] << 8) >> 8; + WriteBuffer[3] = (outputs[1] << 8) >> 8; + WriteBuffer[5] = (outputs[2] << 8) >> 8; + } void Message_PWMCR1(uint16_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | (0b00010100); + WriteBuffer[0] |= ((outputs[0] << 6) >> 14; + WriteBuffer[2] |= ((outputs[1] << 6) >> 14; + WriteBuffer[4] |= ((outputs[3] << 6) >> 14; + WriteBuffer[1] = (outputs[0] << 8) >> 8; + WriteBuffer[3] = (outputs[1] << 8) >> 8; + WriteBuffer[5] = (outputs[2] << 8) >> 8; + } void Message_PWMOUT(uint8_t outputs[3]) + { + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b100100; + WriteBuffer[1] = outputs[0]; + WriteBuffer[3] = outputs[1]; + WriteBuffer[5] = outputs[2]; + } void Message_PWMMAP(uint8_t outputs[3]) { - WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) + (!write << 7) + 0b100101; + WriteBuffer[0] = WriteBuffer[2] = WriteBuffer[4] = (write << 8) | (!write << 7) | 0b100101; WriteBuffer[1] = outputs[0]; WriteBuffer[3] = outputs[1]; WriteBuffer[5] = outputs[2]; |