1
0
mirror of https://github.com/halleysfifthinc/Toyota-AVC-LAN synced 2025-06-07 07:56:21 +00:00

[NFC] Update comments and move a defines

This commit is contained in:
Allen Hill 2023-10-25 14:26:09 -04:00
parent dbe8b8b877
commit c656281275

View File

@ -125,6 +125,12 @@
#define READING_NBITS GPIOR2 #define READING_NBITS GPIOR2
#define READING_PARITY GPIOR3 #define READING_PARITY GPIOR3
#ifdef SOFTWARE_DEBUG
#define TCB_CNTMODE TCB_CNTMODE_FRQPW_gc
#else
#define TCB_CNTMODE TCB_CNTMODE_PW_gc
#endif
uint16_t CD_ID; uint16_t CD_ID;
uint16_t HU_ID; uint16_t HU_ID;
@ -282,13 +288,7 @@ void AVCLAN_init() {
EVSYS.ASYNCCH0 = EVSYS_ASYNCCH0_AC2_OUT_gc; EVSYS.ASYNCCH0 = EVSYS_ASYNCCH0_AC2_OUT_gc;
EVSYS.ASYNCUSER0 = EVSYS_ASYNCUSER0_ASYNCCH0_gc; // USER0 is TCB0 EVSYS.ASYNCUSER0 = EVSYS_ASYNCUSER0_ASYNCCH0_gc; // USER0 is TCB0
// TCB0 for read bit timing // TCB0 for read bit timing
#ifdef SOFTWARE_DEBUG
#define TCB_CNTMODE TCB_CNTMODE_FRQPW_gc
#else
#define TCB_CNTMODE TCB_CNTMODE_PW_gc
#endif
TCB0.CTRLB = TCB_CNTMODE; TCB0.CTRLB = TCB_CNTMODE;
TCB0.INTCTRL = TCB_CAPT_bm; TCB0.INTCTRL = TCB_CAPT_bm;
TCB0.EVCTRL = TCB_CAPTEI_bm; TCB0.EVCTRL = TCB_CAPTEI_bm;
@ -436,7 +436,7 @@ void AVCLAN_sendbit_ACK() {
uint8_t AVCLAN_readbit_ACK() { uint8_t AVCLAN_readbit_ACK() {
TCB1.CNT = 0; TCB1.CNT = 0;
set_AVC_logic_for(0, AVCLAN_BIT1_LOGIC_0); set_AVC_logic_for(0, AVCLAN_BIT1_LOGIC_0);
AVC_SET_LOGICAL_1(); AVC_SET_LOGICAL_1(); // Stop driving bus
while (1) { while (1) {
if (!BUS_IS_IDLE && (TCB1.CNT > AVCLAN_READBIT_THRESHOLD)) if (!BUS_IS_IDLE && (TCB1.CNT > AVCLAN_READBIT_THRESHOLD))
@ -538,7 +538,7 @@ ISR(TCB0_INT_vect) {
const uint8_t *: AVCLAN_readbitsi, \ const uint8_t *: AVCLAN_readbitsi, \
uint8_t *: AVCLAN_readbitsi)(bits, len) uint8_t *: AVCLAN_readbitsi)(bits, len)
// Send `len` bits on the AVCLAN bus; returns the even parity // Read `len` bits on the AVCLAN bus; returns the even parity
uint8_t AVCLAN_readbitsi(uint8_t *bits, uint8_t len) { uint8_t AVCLAN_readbitsi(uint8_t *bits, uint8_t len) {
cli(); cli();
READING_BYTE = 0; READING_BYTE = 0;
@ -564,7 +564,7 @@ uint8_t AVCLAN_readbitsi(uint8_t *bits, uint8_t len) {
return (parity & 1); return (parity & 1);
} }
// Send `len` bits on the AVCLAN bus; returns the even parity // Read `len` bits on the AVCLAN bus; returns the even parity
uint8_t AVCLAN_readbitsl(uint16_t *bits, int8_t len) { uint8_t AVCLAN_readbitsl(uint16_t *bits, int8_t len) {
uint8_t parity = 0; uint8_t parity = 0;
if (len > 8) { if (len > 8) {