ardupilot/libraries/AP_HAL_ESP32/HAL_ESP32_Class.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

135 lines
3.4 KiB
C++
Raw Normal View History

/*
* This file 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 file 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/>.
*/
#include <AP_HAL/AP_HAL.h>
#include <AP_HAL_Empty/AP_HAL_Empty_Private.h>
#include "HAL_ESP32_Class.h"
#include "Scheduler.h"
#include "I2CDevice.h"
#include "SPIDevice.h"
#include "UARTDriver.h"
#include "WiFiDriver.h"
#include "WiFiUdpDriver.h"
#include "RCInput.h"
#include "RCOutput.h"
#include "Storage.h"
#include "AnalogIn.h"
#include "Util.h"
#if AP_SIM_ENABLED
#include <AP_HAL/SIMState.h>
#endif
static ESP32::UARTDriver cons(0);
#ifdef HAL_ESP32_WIFI
#if HAL_ESP32_WIFI == 1
static ESP32::WiFiDriver serial1Driver; //tcp, client should connect to 192.168.4.1 port 5760
#elif HAL_ESP32_WIFI == 2
static ESP32::WiFiUdpDriver serial1Driver; //udp
#else
static Empty::UARTDriver serial1Driver;
#endif
#else
static Empty::UARTDriver serial1Driver;
#endif
static ESP32::UARTDriver serial2Driver(2);
static ESP32::UARTDriver serial3Driver(1);
static Empty::UARTDriver serial4Driver;
static Empty::UARTDriver serial5Driver;
static Empty::UARTDriver serial6Driver;
static Empty::UARTDriver serial7Driver;
static Empty::UARTDriver serial8Driver;
static Empty::UARTDriver serial9Driver;
#if HAL_WITH_DSP
static Empty::DSP dspDriver;
#endif
static ESP32::I2CDeviceManager i2cDeviceManager;
static ESP32::SPIDeviceManager spiDeviceManager;
#ifndef HAL_DISABLE_ADC_DRIVER
static ESP32::AnalogIn analogIn;
#else
static Empty::AnalogIn analogIn;
#endif
#ifdef HAL_USE_EMPTY_STORAGE
static Empty::Storage storageDriver;
#else
static ESP32::Storage storageDriver;
#endif
static Empty::GPIO gpioDriver;
#if AP_SIM_ENABLED
static Empty::RCOutput rcoutDriver;
#else
static ESP32::RCOutput rcoutDriver;
#endif
static ESP32::RCInput rcinDriver;
static ESP32::Scheduler schedulerInstance;
static ESP32::Util utilInstance;
static Empty::OpticalFlow opticalFlowDriver;
static Empty::Flash flashDriver;
#if AP_SIM_ENABLED
static AP_HAL::SIMState xsimstate;
#endif
extern const AP_HAL::HAL& hal;
HAL_ESP32::HAL_ESP32() :
AP_HAL::HAL(
&cons, //Console/mavlink
&serial1Driver, //Telem 1
&serial2Driver, //Telem 2
&serial3Driver, //GPS 1
&serial4Driver, //GPS 2
&serial5Driver, //Extra 1
&serial6Driver, //Extra 2
&serial7Driver, //Extra 3
&serial8Driver, //Extra 4
&serial9Driver, //Extra 5
&i2cDeviceManager,
&spiDeviceManager,
nullptr,
&analogIn,
&storageDriver,
&cons,
&gpioDriver,
&rcinDriver,
&rcoutDriver,
&schedulerInstance,
&utilInstance,
&opticalFlowDriver,
&flashDriver,
#if AP_SIM_ENABLED
&xsimstate,
#endif
#if HAL_WITH_DSP
&dspDriver,
#endif
nullptr
)
{}
void HAL_ESP32::run(int argc, char * const argv[], Callbacks* callbacks) const
{
((ESP32::Scheduler *)hal.scheduler)->set_callbacks(callbacks);
hal.scheduler->init();
}
void AP_HAL::init()
{
}