HAL_ESP32: allow for building with sim on hw

This commit is contained in:
Andrew Tridgell 2024-01-07 13:02:48 +11:00
parent 6c88111267
commit d90a4654a7
4 changed files with 28 additions and 2 deletions

View File

@ -28,6 +28,9 @@
#include "Storage.h"
#include "AnalogIn.h"
#include "Util.h"
#if AP_SIM_ENABLED
#include <AP_HAL/SIMState.h>
#endif
static ESP32::UARTDriver cons(0);
@ -60,15 +63,27 @@ 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() :
@ -96,6 +111,9 @@ HAL_ESP32::HAL_ESP32() :
&utilInstance,
&opticalFlowDriver,
&flashDriver,
#if AP_SIM_ENABLED
&xsimstate,
#endif
#if HAL_WITH_DSP
&dspDriver,
#endif

View File

@ -89,10 +89,10 @@ uint8_t RCInput::read(uint16_t* periods, uint8_t len)
void RCInput::_timer_tick(void)
{
#if AP_RCPROTOCOL_ENABLED
if (!_init) {
return;
}
AP_RCProtocol &rcprot = AP::RC();
#ifdef HAL_ESP32_RCIN
@ -126,4 +126,5 @@ void RCInput::_timer_tick(void)
#endif
#endif
#endif // AP_RCPROTOCOL_ENABLED
}

View File

@ -148,3 +148,4 @@
#define HAL_LOGGING_BACKENDS_DEFAULT 1
#define AP_RCPROTOCOL_ENABLED 0

View File

@ -44,7 +44,7 @@
#define HAL_USE_ADC 0
// 2 use udp, 1 use tcp... for udp,client needs to connect as UDPCL in missionplanner etc to 192.168.4.1 port 14550
#define HAL_ESP32_WIFI 1
#define HAL_ESP32_WIFI 2
// see boards.py
#ifndef ENABLE_HEAP
@ -87,3 +87,9 @@
#define HAL_LOGGING_BACKENDS_DEFAULT 1
#define AP_RCPROTOCOL_ENABLED 0
#define AP_FILESYSTEM_ESP32_ENABLED 0
#define AP_SCRIPTING_ENABLED 0
#define HAL_USE_EMPTY_STORAGE 1