From d1ff01d738d77ff74d2b32f40362e1ca6b6342be Mon Sep 17 00:00:00 2001 From: Jay Blackman Date: Fri, 4 Jul 2025 15:40:17 +1000 Subject: [PATCH] SITL: Minor changes to simplify platform (#14501) * SITL: Minor changes to simplify platform * Update main.c * Update platform.h * As per @ledvinap review --- src/main/main.c | 6 +++--- src/main/pg/gps.c | 2 +- src/main/pg/gyrodev.c | 4 ---- src/platform/SIMULATOR/include/platform/platform.h | 4 ++++ 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index a2a97a4e9b..73175023e4 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -31,7 +31,7 @@ void run(void); int main(int argc, char * argv[]) { -#ifdef SIMULATOR_BUILD +#ifdef USE_MAIN_ARGS targetParseArgs(argc, argv); #else UNUSED(argc); @@ -48,8 +48,8 @@ void FAST_CODE run(void) { while (true) { scheduler(); -#ifdef SIMULATOR_BUILD - delayMicroseconds_real(50); // max rate 20kHz +#if defined(RUN_LOOP_DELAY_US) && RUN_LOOP_DELAY_US > 0 + delayMicroseconds_real(RUN_LOOP_DELAY_US); #endif } } diff --git a/src/main/pg/gps.c b/src/main/pg/gps.c index 81f9e0e396..8a178589b9 100644 --- a/src/main/pg/gps.c +++ b/src/main/pg/gps.c @@ -32,7 +32,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(gpsConfig_t, gpsConfig, PG_GPS_CONFIG, 4); PG_RESET_TEMPLATE(gpsConfig_t, gpsConfig, -#if defined(SIMULATOR_BUILD) && defined(USE_VIRTUAL_GPS) +#if defined(USE_VIRTUAL_GPS) .provider = GPS_VIRTUAL, #else .provider = GPS_UBLOX, diff --git a/src/main/pg/gyrodev.c b/src/main/pg/gyrodev.c index 0a4fabf826..f16427dfd1 100644 --- a/src/main/pg/gyrodev.c +++ b/src/main/pg/gyrodev.c @@ -35,10 +35,6 @@ #include "drivers/sensor.h" #include "sensors/gyro.h" -#ifdef SIMULATOR_BUILD -#define GYRO_COUNT 1 -#endif - #ifndef GYRO_1_CS_PIN #define GYRO_1_CS_PIN NONE #endif diff --git a/src/platform/SIMULATOR/include/platform/platform.h b/src/platform/SIMULATOR/include/platform/platform.h index 4331c71989..1545db177e 100644 --- a/src/platform/SIMULATOR/include/platform/platform.h +++ b/src/platform/SIMULATOR/include/platform/platform.h @@ -36,4 +36,8 @@ #define I2CDEV_COUNT 0 +#define RUN_LOOP_DELAY_US 50 // max 20khz run loop frequency +#define USE_MAIN_ARGS +#define GYRO_COUNT 1 // 1 Gyro + typedef void* ADC_TypeDef; // Dummy definition for ADC_TypeDef