void SendCAN(unsigned int Mbox) { // Check for bus off ECanaShadow.CANMC.all = ECanaRegs.CANMC.all; if (ECanaShadow.CANMC.bit.CCR == 1) { BUS_OFF(); } // 1UL so there's a mask for at least 32 mailboxes mask = 1UL << Mbox; ECanaRegs.CANTRS.all = mask; //todo Nathan: calibrate sendcan stopwatch StopWatchRestart(can_watch); do{ECanaShadow.CANTA.all = ECanaRegs.CANTA.all;} while(((ECanaShadow.CANTA.all & mask) != mask) && (isStopWatchComplete(can_watch) == 0)); //wait to send or hit stop watch ECanaRegs.CANTA.all = mask; //clear flag if (isStopWatchComplete(can_watch) == 1) //if stopwatch flag { ops.Flags.bit.can_error = 1; } else if (ops.Flags.bit.can_error == 1) //if no stopwatch and flagged reset { ops.Flags.bit.can_error = 0; } }
void SensorCovSystemInit() { memcpy(&sc_start_ops, &ops_temp_sys, sizeof(struct SYS_OPS)); StopWatchRestart(conv_watch_in_sys); }