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
@@ -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