No more voltage alarms on simu

This commit is contained in:
Bertrand Songis
2019-08-12 14:23:03 +02:00
parent bd6ba97707
commit 185532f05e
15 changed files with 147 additions and 128 deletions
+1 -1
View File
@@ -126,7 +126,6 @@ set(GVAR_SCREEN model_gvars.cpp)
set(TARGET_SRC
${TARGET_SRC}
board.cpp
led_driver.cpp
extmodule_driver.cpp
trainer_driver.cpp
@@ -140,6 +139,7 @@ set(TARGET_SRC
set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
${LCD_DRIVER}
board.cpp
backlight_driver.cpp
pwr_driver.cpp
sdram_driver.c
+2 -4
View File
@@ -20,12 +20,12 @@
#include "opentx.h"
#if defined(__cplusplus) && !defined(SIMU)
#if defined(__cplusplus)
extern "C" {
#endif
#include "usb_dcd_int.h"
#include "usb_bsp.h"
#if defined(__cplusplus) && !defined(SIMU)
#if defined(__cplusplus)
}
#endif
@@ -78,7 +78,6 @@ void boardInit()
initialise_monitor_handles();
#endif
#if !defined(SIMU)
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
PCBREV_RCC_AHB1Periph |
LED_RCC_AHB1Periph |
@@ -182,7 +181,6 @@ void boardInit()
#endif
ledBlue();
#endif
}
void boardOff()
+64 -11
View File
@@ -356,7 +356,7 @@ void * audioThread(void *)
*/
if ( SDL_OpenAudio(&wanted, &have) < 0 ) {
fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
return 0;
return nullptr;
}
SDL_PauseAudio(0);
@@ -365,7 +365,7 @@ void * audioThread(void *)
sleep(1);
}
SDL_CloseAudio();
return 0;
return nullptr;
}
void StartAudioThread(int volumeGain)
@@ -428,6 +428,18 @@ void telemetryPortInit()
{
}
void sportUpdatePowerOn()
{
}
void sportUpdatePowerOff()
{
}
void boardInit()
{
}
display_t simuLcdBackupBuf[DISPLAY_BUFFER_SIZE];
void lcdStoreBackupBuffer()
{
@@ -648,21 +660,62 @@ void RTC_GetDate(uint32_t RTC_Format, RTC_DateTypeDef * RTC_DateStruct)
RTC_DateStruct->RTC_Date = timeinfo->tm_mday;
}
void unlockFlash()
{
}
void unlockFlash() { }
void lockFlash() { }
void flashWrite(uint32_t *address, uint32_t *buffer) { simuSleep(100); }
uint32_t isBootloaderStart(const uint8_t * block) { return 1; }
void lockFlash()
{
}
void flashWrite(uint32_t *address, uint32_t *buffer)
{
simuSleep(100);
}
uint32_t isBootloaderStart(const uint8_t * block)
{
return 1;
}
#endif // defined(STM32)
#if defined(PCBHORUS)
void LCD_ControlLight(uint16_t dutyCycle) { }
#endif
#if defined(PCBXLITES)
bool isJackPlugged() { return false; }
bool isJackPlugged()
{
return false;
}
#endif
void serialPrintf(const char * format, ...) { }
void serialCrlf() { }
void serialPutc(char c) { }
uint16_t getBatteryVoltage()
{
return (BATTERY_MAX + BATTERY_WARN) * 5;
}
void boardOff()
{
}
#if defined(PCBHORUS) || defined(PCBTARANIS)
HardwareOptions hardwareOptions;
#endif
uint32_t Master_frequency = 0;
uint32_t Current_used = 0;
uint16_t Current_max = 0;
void setSticksGain(uint8_t)
{
}
uint16_t getCurrent()
{
return 10;
}
void calcConsumption()
{
}
+1 -1
View File
@@ -82,6 +82,7 @@ endif()
set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
../common/arm/loadboot.cpp
board.cpp
core_cm3.c
board_lowlevel.c
crt.c
@@ -111,7 +112,6 @@ set(FIRMWARE_TARGET_SRC
set(TARGET_SRC
${TARGET_SRC}
board.cpp
telemetry_driver.cpp
adc_driver.cpp
pulses_driver.cpp
+53 -64
View File
@@ -26,7 +26,6 @@
uint16_t ResetReason;
uint32_t Master_frequency ;
volatile uint32_t Tenms ;
volatile uint8_t lcdLock;
volatile uint32_t lcdInputs;
@@ -58,7 +57,6 @@ inline void setup_switches()
configure_pins( 0x91114900, PIN_ENABLE | PIN_INPUT | PIN_PORTC | PIN_PULLUP ) ;
}
#if !defined(SIMU)
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
{
Uart *pUart = BT_USART;
@@ -85,7 +83,7 @@ inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock)
/* Enable receiver and transmitter */
pUart->UART_CR = UART_CR_RXEN | UART_CR_TXEN;
#if 0
pUart->UART_IER = UART_IER_RXRDY ;
NVIC_EnableIRQ(UART1_IRQn) ;
@@ -247,72 +245,59 @@ void init_pwm()
void configure_pins( uint32_t pins, uint16_t config )
{
Pio *pioptr ;
Pio * pioptr;
pioptr = PIOA + ( ( config & PIN_PORT_MASK ) >> 6) ;
if ( config & PIN_PULLUP )
{
pioptr->PIO_PPDDR = pins ;
pioptr->PIO_PUER = pins ;
}
else
{
pioptr->PIO_PUDR = pins ;
}
pioptr = PIOA + ((config & PIN_PORT_MASK) >> 6);
if (config & PIN_PULLUP) {
pioptr->PIO_PPDDR = pins;
pioptr->PIO_PUER = pins;
}
else {
pioptr->PIO_PUDR = pins;
}
if ( config & PIN_PULLDOWN )
{
pioptr->PIO_PUDR = pins ;
pioptr->PIO_PPDER = pins ;
}
else
{
pioptr->PIO_PPDDR = pins ;
}
if (config & PIN_PULLDOWN) {
pioptr->PIO_PUDR = pins;
pioptr->PIO_PPDER = pins;
}
else {
pioptr->PIO_PPDDR = pins;
}
if ( config & PIN_HIGH )
{
pioptr->PIO_SODR = pins ;
}
else
{
pioptr->PIO_CODR = pins ;
}
if (config & PIN_HIGH) {
pioptr->PIO_SODR = pins;
}
else {
pioptr->PIO_CODR = pins;
}
if ( config & PIN_INPUT )
{
pioptr->PIO_ODR = pins ;
}
else
{
pioptr->PIO_OER = pins ;
}
if (config & PIN_INPUT) {
pioptr->PIO_ODR = pins;
}
else {
pioptr->PIO_OER = pins;
}
if ( config & PIN_PERI_MASK_L )
{
pioptr->PIO_ABCDSR[0] |= pins ;
}
else
{
pioptr->PIO_ABCDSR[0] &= ~pins ;
}
if ( config & PIN_PERI_MASK_H )
{
pioptr->PIO_ABCDSR[1] |= pins ;
}
else
{
pioptr->PIO_ABCDSR[1] &= ~pins ;
}
if (config & PIN_PERI_MASK_L) {
pioptr->PIO_ABCDSR[0] |= pins;
}
else {
pioptr->PIO_ABCDSR[0] &= ~pins;
}
if ( config & PIN_ENABLE )
{
pioptr->PIO_PER = pins ;
}
else
{
pioptr->PIO_PDR = pins ;
}
if (config & PIN_PERI_MASK_H) {
pioptr->PIO_ABCDSR[1] |= pins;
}
else {
pioptr->PIO_ABCDSR[1] &= ~pins;
}
if (config & PIN_ENABLE) {
pioptr->PIO_PER = pins;
}
else {
pioptr->PIO_PDR = pins;
}
}
void opentxBootloader();
@@ -345,7 +330,6 @@ void i2cInit()
TWI0->TWI_MMR = 0x002F0000 ; // Device 5E (>>1) and master is writing
NVIC_EnableIRQ(TWI0_IRQn) ;
}
#endif
void boardInit()
{
@@ -502,3 +486,8 @@ uint16_t getBatteryVoltage()
instant_vbat /= 5530;
return (uint16_t)instant_vbat;
}
void boardOff()
{
pwrOff();
}
+4 -2
View File
@@ -35,8 +35,8 @@ extern uint16_t ResetReason;
#define FIRMWARE_ADDRESS 0x00400000
// Board driver
void boardInit(void);
#define boardOff() pwrOff()
void boardInit();
void boardOff();
// Rotary Encoder driver
void rotaryEncoderInit();
@@ -252,9 +252,11 @@ extern "C" {
#if defined(WATCHDOG_DISABLED) || defined(SIMU)
#define wdt_enable(x)
#define wdt_reset()
#define IS_RESET_REASON_WATCHDOG() false
#else
#define wdt_enable(x) WDT->WDT_MR = 0x3FFF207F
#define wdt_reset() WDT->WDT_CR = 0xA5000001
#define IS_RESET_REASON_WATCHDOG() ((ResetReason & RSTC_SR_RSTTYP) == (2 << 8))
#endif
// Backlight driver
+1 -1
View File
@@ -271,7 +271,6 @@ set(SRC
set(TARGET_SRC
${TARGET_SRC}
board.cpp
${LED_DRIVER}
backlight_driver.cpp
extmodule_driver.cpp
@@ -292,6 +291,7 @@ endif()
set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
${LCD_DRIVER}
board.cpp
i2c_driver.cpp
pwr_driver.cpp
../common/arm/loadboot.cpp
+3 -8
View File
@@ -20,12 +20,12 @@
#include "opentx.h"
#if defined(__cplusplus) && !defined(SIMU)
#if defined(__cplusplus)
extern "C" {
#endif
#include "usb_dcd_int.h"
#include "usb_bsp.h"
#if defined(__cplusplus) && !defined(SIMU)
#if defined(__cplusplus)
}
#endif
@@ -81,7 +81,6 @@ void sportUpdatePowerOff()
void boardInit()
{
#if !defined(SIMU)
RCC_AHB1PeriphClockCmd(PWR_RCC_AHB1Periph |
PCBREV_RCC_AHB1Periph |
KEYS_RCC_AHB1Periph |
@@ -267,8 +266,6 @@ void boardInit()
#if defined(GYRO)
gyroInit();
#endif
#endif // !defined(SIMU)
}
void boardOff()
@@ -298,9 +295,7 @@ void boardOff()
while (1) {
wdt_reset();
#if defined(SIMU)
return;
#elif defined(PWR_BUTTON_PRESS)
#if defined(PWR_BUTTON_PRESS)
// X9E/X7 needs watchdog reset because CPU is still running while
// the power key is held pressed by the user.
// The power key should be released by now, but we must make sure