mirror of
https://github.com/opentx/opentx.git
synced 2025-07-15 20:35:17 +03:00
Sky9x simulator should now be OK
This commit is contained in:
parent
88ca7fcc68
commit
b6e8b73589
7 changed files with 53 additions and 38 deletions
|
@ -2,7 +2,7 @@
|
||||||
* Copyright (C) OpenTX
|
* Copyright (C) OpenTX
|
||||||
*
|
*
|
||||||
* Based on code named
|
* Based on code named
|
||||||
* th9x - http://code.google.com/p/th9x
|
* th9x - http://code.google.com/p/th9x
|
||||||
* er9x - http://code.google.com/p/er9x
|
* er9x - http://code.google.com/p/er9x
|
||||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
#include "stamp.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
|
@ -31,7 +32,7 @@ void debugPrintf(const char * format, ...)
|
||||||
{
|
{
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
char tmp[PRINTF_BUFFER_SIZE];
|
char tmp[PRINTF_BUFFER_SIZE];
|
||||||
|
|
||||||
va_start(arglist, format);
|
va_start(arglist, format);
|
||||||
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
||||||
va_end(arglist);
|
va_end(arglist);
|
||||||
|
@ -77,7 +78,6 @@ const struct TraceElement * getTraceElement(uint16_t idx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "stamp-opentx.h"
|
|
||||||
|
|
||||||
void dumpTraceBuffer()
|
void dumpTraceBuffer()
|
||||||
{
|
{
|
||||||
|
@ -88,13 +88,15 @@ void dumpTraceBuffer()
|
||||||
filltm(&traceBuffer[n].time, &tp);
|
filltm(&traceBuffer[n].time, &tp);
|
||||||
TRACE_INFO_WP("%02d ", n);
|
TRACE_INFO_WP("%02d ", n);
|
||||||
TRACE_INFO_WP("%4d-%02d-%02d,%02d:%02d:%02d.%02d0", tp.tm_year+1900, tp.tm_mon+1, tp.tm_mday, tp.tm_hour, tp.tm_min, tp.tm_sec, traceBuffer[n].time_ms);
|
TRACE_INFO_WP("%4d-%02d-%02d,%02d:%02d:%02d.%02d0", tp.tm_year+1900, tp.tm_mon+1, tp.tm_mday, tp.tm_hour, tp.tm_min, tp.tm_sec, traceBuffer[n].time_ms);
|
||||||
TRACE(" %03d 0x%08x", traceBuffer[n].event, traceBuffer[n].data);
|
TRACE(" %03d 0x%08x", traceBuffer[n].event, traceBuffer[n].data);
|
||||||
if (traceBuffer[n].time == 0 && traceBuffer[n].time_ms == 0) break;
|
if (traceBuffer[n].time == 0 && traceBuffer[n].time_ms == 0) break;
|
||||||
|
#if !defined(SIMU)
|
||||||
if ((n % 5) == 0) {
|
if ((n % 5) == 0) {
|
||||||
while (!serial2TxFifo.empty()) {
|
while (!serial2TxFifo.empty()) {
|
||||||
CoTickDelay(1);
|
CoTickDelay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
TRACE("End of Trace Buffer dump");
|
TRACE("End of Trace Buffer dump");
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,8 @@ void menuTelemetryMavlinkSetup(uint8_t event);
|
||||||
|
|
||||||
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
void menuCustomFunctions(uint8_t event, CustomFunctionData * functions, CustomFunctionsContext * functionsContext);
|
||||||
|
|
||||||
enum EnumTabDiag {
|
enum EnumTabDiag
|
||||||
|
{
|
||||||
e_Setup,
|
e_Setup,
|
||||||
CASE_SDCARD(e_Sd)
|
CASE_SDCARD(e_Sd)
|
||||||
CASE_CPUARM(e_GeneralCustomFunctions)
|
CASE_CPUARM(e_GeneralCustomFunctions)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../../opentx.h"
|
#include "opentx.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
void drawColumnHeader(const char * const * headers, uint8_t index)
|
void drawColumnHeader(const char * const * headers, uint8_t index)
|
||||||
|
|
|
@ -1983,7 +1983,13 @@ void opentxStart()
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
doSplash();
|
bool display_alerts = (g_eeGeneral.chkSum == evalChkSum());
|
||||||
|
|
||||||
|
#if defined(GUI)
|
||||||
|
if (display_alerts) {
|
||||||
|
doSplash();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(DEBUG_TRACE_BUFFER)
|
#if defined(DEBUG_TRACE_BUFFER)
|
||||||
trace_event(trace_start, 0x12345678);
|
trace_event(trace_start, 0x12345678);
|
||||||
|
@ -1996,12 +2002,11 @@ void opentxStart()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(GUI)
|
#if defined(GUI)
|
||||||
checkAlarm();
|
if (display_alerts) {
|
||||||
checkAll();
|
checkAlarm();
|
||||||
#endif
|
checkAll();
|
||||||
|
}
|
||||||
#if defined(GUI)
|
else {
|
||||||
if (g_eeGeneral.chkSum != evalChkSum()) {
|
|
||||||
chainMenu(menuFirstCalib);
|
chainMenu(menuFirstCalib);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2550,6 +2555,13 @@ void opentxInit(OPENTX_INIT_ARGS)
|
||||||
|
|
||||||
TRACE("opentxInit()");
|
TRACE("opentxInit()");
|
||||||
|
|
||||||
|
#if defined(GUI)
|
||||||
|
menuHandlers[0] = menuMainView;
|
||||||
|
#if MENUS_LOCK != 2/*no menus*/
|
||||||
|
menuHandlers[1] = menuModelSelect;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
#if defined(RTCLOCK) && !defined(COPROCESSOR)
|
||||||
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
rtcInit(); // RTC must be initialized before rambackupRestore() is called
|
||||||
#endif
|
#endif
|
||||||
|
@ -2654,13 +2666,6 @@ void opentxInit(OPENTX_INIT_ARGS)
|
||||||
startPulses();
|
startPulses();
|
||||||
|
|
||||||
wdt_enable(WDTO_500MS);
|
wdt_enable(WDTO_500MS);
|
||||||
|
|
||||||
#if defined(GUI)
|
|
||||||
menuHandlers[0] = menuMainView;
|
|
||||||
#if MENUS_LOCK != 2/*no menus*/
|
|
||||||
menuHandlers[1] = menuModelSelect;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SIMU)
|
#if defined(SIMU)
|
||||||
|
|
|
@ -946,9 +946,12 @@ extern uint16_t lastMixerDuration;
|
||||||
#define RESET_THR_TRACE() s_timeCum16ThrP = s_timeCumThr = 0
|
#define RESET_THR_TRACE() s_timeCum16ThrP = s_timeCumThr = 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CPUSTM32)
|
#if defined(SIMU)
|
||||||
|
uint16_t getTmr2MHz();
|
||||||
|
uint16_t getTmr16KHz();
|
||||||
|
#elif defined(CPUSTM32)
|
||||||
static inline uint16_t getTmr2MHz() { return TIMER_2MHz_TIMER->CNT; }
|
static inline uint16_t getTmr2MHz() { return TIMER_2MHz_TIMER->CNT; }
|
||||||
#elif defined(CPUARM)
|
#elif defined(PCBSKY9X)
|
||||||
static inline uint16_t getTmr2MHz() { return TC1->TC_CHANNEL[0].TC_CV; }
|
static inline uint16_t getTmr2MHz() { return TC1->TC_CHANNEL[0].TC_CV; }
|
||||||
#else
|
#else
|
||||||
uint16_t getTmr16KHz();
|
uint16_t getTmr16KHz();
|
||||||
|
|
|
@ -23,9 +23,7 @@
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#if defined(RTCLOCK)
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined WIN32 || !defined __GNUC__
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
|
@ -96,6 +94,20 @@ void toplcdOff()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t getTmr16KHz()
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return tv.tv_usec * 2 / 125;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t getTmr2MHz()
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
gettimeofday(&tv, NULL);
|
||||||
|
return tv.tv_usec * 2;
|
||||||
|
}
|
||||||
|
|
||||||
void simuInit()
|
void simuInit()
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= 17; i++) {
|
for (int i = 0; i <= 17; i++) {
|
||||||
|
@ -273,14 +285,9 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getTmr16KHz()
|
|
||||||
{
|
|
||||||
return get_tmr10ms() * 160;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(PCBTARANIS) && !defined(PCBHORUS)
|
#if !defined(PCBTARANIS) && !defined(PCBHORUS)
|
||||||
bool eeprom_thread_running = true;
|
bool eeprom_thread_running = true;
|
||||||
void *eeprom_write_function(void *)
|
void * eeprom_write_function(void *)
|
||||||
{
|
{
|
||||||
while (!sem_wait(eeprom_write_sem)) {
|
while (!sem_wait(eeprom_write_sem)) {
|
||||||
if (!eeprom_thread_running)
|
if (!eeprom_thread_running)
|
||||||
|
@ -324,11 +331,6 @@ void *eeprom_write_function(void *)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
|
||||||
#define chdir _chdir
|
|
||||||
#define getcwd _getcwd
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void StartSimu(bool tests)
|
void StartSimu(bool tests)
|
||||||
{
|
{
|
||||||
s_current_protocol[0] = 255;
|
s_current_protocol[0] = 255;
|
||||||
|
@ -1243,7 +1245,7 @@ uint32_t pwrPressed() { return false; }
|
||||||
uint32_t pwrCheck() { return true; }
|
uint32_t pwrCheck() { return true; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBTARANIS) || defined(PCBFLAMENCO) || defined(PCBHORUS)
|
#if defined(CPUSTM32)
|
||||||
void pwrInit() { }
|
void pwrInit() { }
|
||||||
void pwrOff() { }
|
void pwrOff() { }
|
||||||
int usbPlugged() { return false; }
|
int usbPlugged() { return false; }
|
||||||
|
|
|
@ -28,6 +28,8 @@ extern int g_snapshot_idx;
|
||||||
#define sleep(x) Sleep(x)
|
#define sleep(x) Sleep(x)
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#define strncasecmp _tcsnicmp
|
#define strncasecmp _tcsnicmp
|
||||||
|
#define chdir _chdir
|
||||||
|
#define getcwd _getcwd
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define sleep(x) usleep(1000*x)
|
#define sleep(x) usleep(1000*x)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue