mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-02 05:58:30 -04:00
AP_EFI: Add currawong ECU EFI backend
This commit is contained in:
parent
d3ee4ebf64
commit
49b7efe4cb
72
libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp
Normal file
72
libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AP_EFI_Currawong_ECU.cpp
|
||||
*
|
||||
* Author: Reilly Callaway
|
||||
*/
|
||||
|
||||
#include <AP_PiccoloCAN/piccolo_protocol/ECUPackets.h>
|
||||
#include <AP_Math/definitions.h>
|
||||
|
||||
#if HAL_EFI_CURRAWONG_ECU_ENABLED
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
AP_EFI_Currawong_ECU* AP_EFI_Currawong_ECU::singleton;
|
||||
|
||||
AP_EFI_Currawong_ECU::AP_EFI_Currawong_ECU(AP_EFI &_frontend) :
|
||||
AP_EFI_Backend(_frontend)
|
||||
{
|
||||
singleton = this;
|
||||
|
||||
internal_state.oil_pressure_status = Oil_Pressure_Status::OIL_PRESSURE_STATUS_NOT_SUPPORTED;
|
||||
internal_state.debris_status = Debris_Status::NOT_SUPPORTED;
|
||||
internal_state.misfire_status = Misfire_Status::NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
void AP_EFI_Currawong_ECU::update()
|
||||
{
|
||||
// copy the data to the front end
|
||||
copy_to_frontend();
|
||||
}
|
||||
|
||||
bool AP_EFI_Currawong_ECU::handle_message(AP_HAL::CANFrame &frame)
|
||||
{
|
||||
bool valid = true;
|
||||
|
||||
// There are differences between Ardupilot EFI_State and types/scaling of Piccolo packets.
|
||||
// So we first decode to Piccolo structs, and then store the data we need in EFI_State internal_state with any scaling required.
|
||||
|
||||
// Structs to decode Piccolo messages into
|
||||
ECU_TelemetryFast_t telemetryFast;
|
||||
ECU_TelemetrySlow0_t telemetrySlow0;
|
||||
ECU_TelemetrySlow1_t telemetrySlow1;
|
||||
ECU_TelemetrySlow2_t telemetrySlow2;
|
||||
ECU_Errors_t errors;
|
||||
|
||||
// Throw the message at the decoding functions
|
||||
|
||||
|
||||
if (valid)
|
||||
{
|
||||
internal_state.last_updated_ms = AP_HAL::millis();
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
#endif // HAL_EFI_CURRAWONG_ECU_ENABLED
|
55
libraries/AP_EFI/AP_EFI_Currawong_ECU.h
Normal file
55
libraries/AP_EFI/AP_EFI_Currawong_ECU.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* AP_EFI_Currawong_ECU.h
|
||||
*
|
||||
* Author: Reilly Callaway
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AP_EFI.h"
|
||||
#include "AP_EFI_Backend.h"
|
||||
|
||||
#ifndef HAL_EFI_CURRAWONG_ECU_ENABLED
|
||||
#define HAL_EFI_CURRAWONG_ECU_ENABLED HAL_MAX_CAN_PROTOCOL_DRIVERS && BOARD_FLASH_SIZE > 1024
|
||||
#endif
|
||||
|
||||
#if HAL_EFI_CURRAWONG_ECU_ENABLED
|
||||
|
||||
|
||||
|
||||
class AP_EFI_Currawong_ECU : public AP_EFI_Backend {
|
||||
public:
|
||||
AP_EFI_Currawong_ECU(AP_EFI &_frontend);
|
||||
|
||||
void update() override;
|
||||
|
||||
static AP_EFI_Currawong_ECU* get_instance(void)
|
||||
{
|
||||
return singleton;
|
||||
}
|
||||
|
||||
private:
|
||||
bool handle_message(AP_HAL::CANFrame &frame);
|
||||
|
||||
static AP_EFI_Currawong_ECU *singleton;
|
||||
|
||||
friend class AP_PiccoloCAN;
|
||||
};
|
||||
|
||||
#endif // HAL_EFI_NWPWU_ENABLED
|
||||
|
Loading…
Reference in New Issue
Block a user