2021-10-27 05:43:28 -03:00
|
|
|
/*
|
|
|
|
* 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"
|
2024-01-06 22:02:48 -04:00
|
|
|
#if AP_SIM_ENABLED
|
|
|
|
#include <AP_HAL/SIMState.h>
|
|
|
|
#endif
|
2021-10-27 05:43:28 -03:00
|
|
|
|
|
|
|
|
|
|
|
static ESP32::UARTDriver cons(0);
|
|
|
|
#ifdef HAL_ESP32_WIFI
|
|
|
|
#if HAL_ESP32_WIFI == 1
|
2023-12-10 13:33:12 -04:00
|
|
|
static ESP32::WiFiDriver serial1Driver; //tcp, client should connect to 192.168.4.1 port 5760
|
2021-10-27 05:43:28 -03:00
|
|
|
#elif HAL_ESP32_WIFI == 2
|
2023-12-10 13:33:12 -04:00
|
|
|
static ESP32::WiFiUdpDriver serial1Driver; //udp
|
2021-10-27 05:43:28 -03:00
|
|
|
#endif
|
|
|
|
#else
|
2023-12-10 13:33:12 -04:00
|
|
|
static Empty::UARTDriver serial1Driver;
|
2021-10-27 05:43:28 -03:00
|
|
|
#endif
|
2023-12-10 13:33:12 -04:00
|
|
|
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;
|
2021-10-27 05:43:28 -03:00
|
|
|
|
2024-01-01 21:49:00 -04:00
|
|
|
#if HAL_WITH_DSP
|
2021-10-27 05:43:28 -03:00
|
|
|
static Empty::DSP dspDriver;
|
2024-01-01 21:49:00 -04:00
|
|
|
#endif
|
2021-10-27 05:43:28 -03:00
|
|
|
|
|
|
|
static ESP32::I2CDeviceManager i2cDeviceManager;
|
|
|
|
static ESP32::SPIDeviceManager spiDeviceManager;
|
|
|
|
#ifndef HAL_DISABLE_ADC_DRIVER
|
|
|
|
static ESP32::AnalogIn analogIn;
|
|
|
|
#else
|
|
|
|
static Empty::AnalogIn analogIn;
|
|
|
|
#endif
|
2024-01-06 22:02:48 -04:00
|
|
|
#ifdef HAL_USE_EMPTY_STORAGE
|
|
|
|
static Empty::Storage storageDriver;
|
|
|
|
#else
|
2021-10-27 05:43:28 -03:00
|
|
|
static ESP32::Storage storageDriver;
|
2024-01-06 22:02:48 -04:00
|
|
|
#endif
|
2021-10-27 05:43:28 -03:00
|
|
|
static Empty::GPIO gpioDriver;
|
2024-01-06 22:02:48 -04:00
|
|
|
#if AP_SIM_ENABLED
|
|
|
|
static Empty::RCOutput rcoutDriver;
|
|
|
|
#else
|
2021-10-27 05:43:28 -03:00
|
|
|
static ESP32::RCOutput rcoutDriver;
|
2024-01-06 22:02:48 -04:00
|
|
|
#endif
|
2021-10-27 05:43:28 -03:00
|
|
|
static ESP32::RCInput rcinDriver;
|
|
|
|
static ESP32::Scheduler schedulerInstance;
|
|
|
|
static ESP32::Util utilInstance;
|
|
|
|
static Empty::OpticalFlow opticalFlowDriver;
|
|
|
|
static Empty::Flash flashDriver;
|
|
|
|
|
2024-01-06 22:02:48 -04:00
|
|
|
#if AP_SIM_ENABLED
|
|
|
|
static AP_HAL::SIMState xsimstate;
|
|
|
|
#endif
|
|
|
|
|
2021-10-27 05:43:28 -03:00
|
|
|
extern const AP_HAL::HAL& hal;
|
|
|
|
|
|
|
|
HAL_ESP32::HAL_ESP32() :
|
|
|
|
AP_HAL::HAL(
|
|
|
|
&cons, //Console/mavlink
|
2023-12-10 13:33:12 -04:00
|
|
|
&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
|
2021-10-27 05:43:28 -03:00
|
|
|
&i2cDeviceManager,
|
|
|
|
&spiDeviceManager,
|
|
|
|
nullptr,
|
|
|
|
&analogIn,
|
|
|
|
&storageDriver,
|
|
|
|
&cons,
|
|
|
|
&gpioDriver,
|
|
|
|
&rcinDriver,
|
|
|
|
&rcoutDriver,
|
|
|
|
&schedulerInstance,
|
|
|
|
&utilInstance,
|
|
|
|
&opticalFlowDriver,
|
|
|
|
&flashDriver,
|
2024-01-06 22:02:48 -04:00
|
|
|
#if AP_SIM_ENABLED
|
|
|
|
&xsimstate,
|
|
|
|
#endif
|
2024-01-01 21:49:00 -04:00
|
|
|
#if HAL_WITH_DSP
|
2021-10-27 05:43:28 -03:00
|
|
|
&dspDriver,
|
2024-01-01 21:49:00 -04:00
|
|
|
#endif
|
2021-10-27 05:43:28 -03:00
|
|
|
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()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|