AP_Mount: add Backend_Serial
This commit is contained in:
parent
3a4fdb16a8
commit
1e777390b2
24
libraries/AP_Mount/AP_Mount_Backend_Serial.cpp
Normal file
24
libraries/AP_Mount/AP_Mount_Backend_Serial.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "AP_Mount_Backend_Serial.h"
|
||||
|
||||
#if HAL_MOUNT_ENABLED
|
||||
#include <AP_SerialManager/AP_SerialManager.h>
|
||||
|
||||
// Default init function for every mount
|
||||
void AP_Mount_Backend_Serial::init()
|
||||
{
|
||||
const AP_SerialManager& serial_manager = AP::serialmanager();
|
||||
|
||||
// search for serial port. hild classes should check that uart is not nullptr
|
||||
_uart = serial_manager.find_serial(AP_SerialManager::SerialProtocol_Gimbal, _serial_instance);
|
||||
if (_uart == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// initialised successfully if uart is found
|
||||
_initialised = true;
|
||||
|
||||
// call the parent class init
|
||||
AP_Mount_Backend::init();
|
||||
}
|
||||
|
||||
#endif // HAL_MOUNT_ENABLED
|
48
libraries/AP_Mount/AP_Mount_Backend_Serial.h
Normal file
48
libraries/AP_Mount/AP_Mount_Backend_Serial.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
Mount driver backend class for serial drivers
|
||||
Mounts using custom serial protocols should be derived from this class
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "AP_Mount_config.h"
|
||||
|
||||
#if HAL_MOUNT_ENABLED
|
||||
|
||||
#include "AP_Mount_Backend.h"
|
||||
|
||||
class AP_Mount_Backend_Serial : public AP_Mount_Backend
|
||||
{
|
||||
public:
|
||||
// Constructor
|
||||
AP_Mount_Backend_Serial(class AP_Mount &frontend, class AP_Mount_Params ¶ms, uint8_t instance, uint8_t serial_instance) :
|
||||
AP_Mount_Backend(frontend, params, instance),
|
||||
_serial_instance(serial_instance)
|
||||
{}
|
||||
|
||||
// perform any required initialisation for this instance
|
||||
void init() override;
|
||||
|
||||
protected:
|
||||
|
||||
// internal variables
|
||||
AP_HAL::UARTDriver *_uart; // uart connected to gimbal
|
||||
uint8_t _serial_instance; // this instance's serial instance number
|
||||
bool _initialised; // true if uart has been initialised
|
||||
};
|
||||
|
||||
#endif // HAL_MOUNT_ENABLED
|
Loading…
Reference in New Issue
Block a user