mirror of
https://jihulab.com/mr-one/openpilot.git
synced 2026-10-27 04:53:44 +08:00
编辑can_common.h
This commit is contained in:
@@ -34,6 +34,9 @@ extern bool can_loopback;
|
||||
bool ignition_can = false;
|
||||
uint32_t ignition_can_cnt = 0U;
|
||||
|
||||
// Mazda 0x202 RPM-based ignition timeout
|
||||
uint32_t mazda_ignition_rpm_cnt = 0U;
|
||||
|
||||
#define ALL_CAN_SILENT 0xFF
|
||||
#define ALL_CAN_LIVE 0
|
||||
|
||||
@@ -228,6 +231,7 @@ void ignition_can_hook(CANPacket_t *to_push) {
|
||||
// Mazda engine RPM based ignition (0x202, 100Hz)
|
||||
if ((addr == 0x202) && (len == 8)) {
|
||||
int rpm_raw = (GET_BYTE(to_push, 0) << 8) | GET_BYTE(to_push, 1);
|
||||
mazda_ignition_rpm_cnt = 0U;
|
||||
if (rpm_raw > 200) { // > 200 RPM = engine running
|
||||
ignition_can = true;
|
||||
ignition_can_cnt = 0U;
|
||||
@@ -244,6 +248,7 @@ void ignition_can_hook(CANPacket_t *to_push) {
|
||||
// Mazda engine RPM based ignition (0x202, 100Hz) - bus 1 redundancy
|
||||
if ((addr == 0x202) && (len == 8)) {
|
||||
int rpm_raw = (GET_BYTE(to_push, 0) << 8) | GET_BYTE(to_push, 1);
|
||||
mazda_ignition_rpm_cnt = 0U;
|
||||
if (rpm_raw > 200) { // > 200 RPM = engine running
|
||||
ignition_can = true;
|
||||
ignition_can_cnt = 0U;
|
||||
@@ -258,6 +263,12 @@ void ignition_can_hook(CANPacket_t *to_push) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Mazda 0x202 RPM timeout: clear ignition_can if no 0x202 seen for ~3s
|
||||
if (mazda_ignition_rpm_cnt > 3U) {
|
||||
ignition_can = false;
|
||||
}
|
||||
mazda_ignition_rpm_cnt++;
|
||||
}
|
||||
|
||||
bool can_tx_check_min_slots_free(uint32_t min) {
|
||||
|
||||
Reference in New Issue
Block a user