Update to latest libopenui

This commit is contained in:
Bertrand Songis
2020-03-18 17:06:14 +01:00
parent d542019582
commit 34aa1e4327
25 changed files with 172 additions and 173 deletions
@@ -32,7 +32,7 @@ set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
../common/arm/stm32/rtc_driver.cpp
${AUX_SERIAL_DRIVER}
../common/arm/stm32/delays.cpp
../common/arm/stm32/delays_driver.cpp
../common/arm/stm32/usb_bsp.c
../common/arm/stm32/usbd_desc.c
../common/arm/stm32/usbd_usr.cpp
@@ -69,6 +69,7 @@
#include "stm32f2xx_flash.h"
#include "stm32f2xx_dbgmcu.h"
#include "misc.h"
#include "dwt.h" // the old ST library that we use does not define DWT register for STM32F2xx
#endif
#if __clang__
@@ -127,13 +128,28 @@ static inline bool isVBatBridgeEnabled()
}
// Delays driver
#define SYSTEM_TICKS_1MS ((CPU_FREQ + 500) / 1000)
#define SYSTEM_TICKS_1US ((CPU_FREQ + 500000) / 1000000)
#define SYSTEM_TICKS_01US ((CPU_FREQ + 5000000) / 10000000)
#ifdef __cplusplus
extern "C" {
#endif
void delaysInit(void);
void delay_01us(uint16_t nb);
void delay_us(uint16_t nb);
void delay_ms(uint32_t ms);
inline uint32_t ticksNow()
{
#if defined(SIMU)
return 0;
#else
return DWT->CYCCNT;
#endif
}
void delaysInit();
void delay_01us(uint32_t count);
void delay_us(uint32_t count);
void delay_ms(uint32_t count);
#ifdef __cplusplus
}
#endif
@@ -78,7 +78,7 @@ set(BOOTLOADER_SRC
../../../../../targets/${TARGET_DIR}/bootloader/boot_menu.cpp
../usbd_usr.cpp
../usbd_storage_msd.cpp
../delays.cpp
../delays_driver.cpp
../usbd_desc.c
../usb_bsp.c
../usb_driver.cpp
@@ -1,56 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <OsConfig.h>
#include "board.h"
#if defined(STM32F2)
#include "dwt.h" // the old ST library that we use does not define DWT register for STM32F2xx
#endif
#define SYSTEM_TICKS_1US ((CFG_CPU_FREQ + 500000) / 1000000) // number of system ticks in 1us
#define SYSTEM_TICKS_01US ((CFG_CPU_FREQ + 5000000) / 10000000) // number of system ticks in 0.1us (rounding needed for sys frequencies that are not multiple of 10MHz)
void delaysInit(void)
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
}
void delay_01us(uint16_t nb)
{
volatile uint32_t dwtStart = DWT->CYCCNT;
volatile uint32_t dwtTotal = (SYSTEM_TICKS_01US * nb) - 10;
while ((DWT->CYCCNT - dwtStart) < dwtTotal);
}
void delay_us(uint16_t nb)
{
volatile uint32_t dwtStart = DWT->CYCCNT;
volatile uint32_t dwtTotal = (SYSTEM_TICKS_1US * nb) - 10;
while ((DWT->CYCCNT - dwtStart) < dwtTotal);
}
void delay_ms(uint32_t ms)
{
while (ms--) {
delay_us(1000);
}
}
@@ -0,0 +1,56 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "board.h"
void delaysInit()
{
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
DWT->CYCCNT = 0;
DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk;
}
void delay_01us(uint32_t count)
{
volatile uint32_t dwtStart = ticksNow();
volatile uint32_t dwtTotal = (SYSTEM_TICKS_01US * count) - 10;
while ((ticksNow() - dwtStart) < dwtTotal);
}
void delay_us(uint32_t count)
{
volatile uint32_t dwtStart = ticksNow();
volatile uint32_t dwtTotal = (SYSTEM_TICKS_1US * count) - 10;
while ((ticksNow() - dwtStart) < dwtTotal);
}
void delay_1ms()
{
volatile uint32_t dwtStart = ticksNow();
volatile uint32_t dwtTotal = SYSTEM_TICKS_1MS - 10;
while ((ticksNow() - dwtStart) < dwtTotal);
}
void delay_ms(uint32_t count)
{
while (count--) {
delay_1ms();
}
}
+8 -17
View File
@@ -123,15 +123,6 @@ uint32_t sdMounted();
#define SD_CARD_PRESENT() true
#endif
#if defined(DISK_CACHE)
#include "FatFs/diskio.h"
DRESULT __disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count);
DRESULT __disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count);
#else
#define __disk_read disk_read
#define __disk_write disk_write
#endif
// Flash Write driver
#define FLASH_PAGESIZE 256
void unlockFlash();
@@ -658,13 +649,13 @@ void bluetoothWriteWakeup();
uint8_t bluetoothIsWriting();
void bluetoothDisable();
#if defined(__cplusplus)
#include "fifo.h"
#include "dmafifo.h"
extern DMAFifo<512> telemetryFifo;
typedef DMAFifo<32> AuxSerialRxFifo;
extern AuxSerialRxFifo auxSerialRxFifo;
extern volatile uint32_t externalModulePort;
#endif
//#if defined(__cplusplus)
//#include "fifo.h"
//#include "dmafifo.h"
//extern DMAFifo<512> telemetryFifo;
//typedef DMAFifo<32> AuxSerialRxFifo;
//extern AuxSerialRxFifo auxSerialRxFifo;
//extern volatile uint32_t externalModulePort;
//#endif
#endif // _BOARD_H_
+2
View File
@@ -21,6 +21,8 @@
#ifndef _HAL_H_
#define _HAL_H_
#define CPU_FREQ 168000000
// Keys
#define KEYS_RCC_AHB1Periph (RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG | RCC_AHB1Periph_GPIOH | RCC_AHB1Periph_GPIOI | RCC_AHB1Periph_GPIOJ)
#if defined(PCBX12S)
+1 -23
View File
@@ -23,8 +23,8 @@
#include "../definitions.h"
#include "../opentx_constants.h"
#include "board_common.h"
#include "hal.h"
#include "board_common.h"
#if !defined(LUA_EXPORT_GENERATION)
#include "stm32f4xx_sdio.h"
@@ -71,18 +71,6 @@ void boardOff();
void init2MhzTimer();
void init5msTimer();
// Delays driver
#ifdef __cplusplus
extern "C" {
#endif
void delaysInit();
void delay_01us(uint16_t nb);
void delay_us(uint16_t nb);
void delay_ms(uint32_t ms);
#ifdef __cplusplus
}
#endif
// CPU Unique ID
#define LEN_CPU_UID (3*8+2)
void getCPUUniqueID(char * s);
@@ -110,15 +98,6 @@ uint32_t sdMounted();
#define SD_CARD_PRESENT() true
#endif
#if defined(DISK_CACHE)
#include "diskio.h"
DRESULT __disk_read(BYTE drv, BYTE * buff, DWORD sector, UINT count);
DRESULT __disk_write(BYTE drv, const BYTE * buff, DWORD sector, UINT count);
#else
#define __disk_read disk_read
#define __disk_write disk_write
#endif
// Flash Write driver
#define FLASH_PAGESIZE 256
void unlockFlash();
@@ -373,7 +352,6 @@ void adcInit();
void adcRead();
uint16_t getAnalogValue(uint8_t index);
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
uint16_t getBattery2Voltage(); // returns current battery voltage in 10mV steps
#define BATTERY_WARN 36 // 3.6V
#define BATTERY_MIN 35 // 3.5V
+2
View File
@@ -21,6 +21,8 @@
#ifndef _HAL_H_
#define _HAL_H_
#define CPU_FREQ 168000000
/* Timers Allocation:
* TIM1 = Haptic
* TIM4 = Trainer
+6 -6
View File
@@ -126,9 +126,9 @@ void OpenTxSimulator::start(const char * filename, bool tests)
QMutexLocker lckr(&m_mtxSimuMain);
QMutexLocker slckr(&m_mtxSettings);
StartEepromThread(filename);
StartAudioThread(volumeGain);
StartSimu(tests, simuSdDirectory.toLatin1().constData(), simuSettingsDirectory.toLatin1().constData());
startEepromThread(filename);
startAudioThread(volumeGain);
simuStart(tests, simuSdDirectory.toLatin1().constData(), simuSettingsDirectory.toLatin1().constData());
emit started();
QTimer::singleShot(0, this, SLOT(run())); // old style for Qt < 5.4
@@ -143,9 +143,9 @@ void OpenTxSimulator::stop()
setStopRequested(true);
QMutexLocker lckr(&m_mtxSimuMain);
StopSimu();
StopAudioThread();
StopEepromThread();
simuStop();
stopAudioThread();
stopEepromThread();
emit stopped();
}
+24 -5
View File
@@ -52,6 +52,25 @@ USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4;
SysTick_Type systick;
ADC_Common_TypeDef adc;
RTC_TypeDef rtc;
void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { }
void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) { }
void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState) { }
void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) { }
FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) { return RESET; }
uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx) { return 0; }
void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) { }
void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx) { }
void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct) { }
void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState) { }
void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct) { }
void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState) { }
void lcdCopy(void * dest, void * src);
FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG) { return RESET; }
ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { return RESET; }
void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { }
void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState) { }
void UART3_Configure(uint32_t baudrate, uint32_t masterClock) { }
void NVIC_Init(NVIC_InitTypeDef * NVIC_InitStruct) { }
#else
Pio Pioa, Piob, Pioc;
Pmc pmc;
@@ -175,7 +194,7 @@ void simuSetSwitch(uint8_t swtch, int8_t state)
switchesStates[swtch] = state;
}
void StartSimu(bool tests, const char * sdPath, const char * settingsPath)
void simuStart(bool tests, const char * sdPath, const char * settingsPath)
{
if (simu_running)
return;
@@ -224,7 +243,7 @@ void StartSimu(bool tests, const char * sdPath, const char * settingsPath)
#endif
}
void StopSimu()
void simuStop()
{
if (!simu_running)
return;
@@ -379,12 +398,12 @@ void * audioThread(void *)
return nullptr;
}
void StartAudioThread(int volumeGain)
void startAudioThread(int volumeGain)
{
simuAudio.leftoverLen = 0;
simuAudio.threadRunning = true;
simuAudio.volumeGain = volumeGain;
TRACE_SIMPGMSPACE("StartAudioThread(%d)", volumeGain);
TRACE_SIMPGMSPACE("startAudioThread(%d)", volumeGain);
setScaledVolume(VOLUME_LEVEL_DEF);
pthread_attr_t attr;
@@ -398,7 +417,7 @@ void StartAudioThread(int volumeGain)
#endif
}
void StopAudioThread()
void stopAudioThread()
{
simuAudio.threadRunning = false;
pthread_join(simuAudio.threadPid, nullptr);
+15 -31
View File
@@ -240,25 +240,27 @@ extern char * main_thread_error;
inline void getADC() { }
uint64_t simuTimerMicros(void);
void simuInit();
void StartSimu(bool tests=true, const char * sdPath = 0, const char * settingsPath = 0);
void StopSimu();
bool simuIsRunning();
uint8_t simuSleep(uint32_t ms); // returns true if thread shutdown requested
void simuSetKey(uint8_t key, bool state);
void simuSetTrim(uint8_t trim, bool state);
void simuSetSwitch(uint8_t swtch, int8_t state);
void StartEepromThread(const char *filename="eeprom.bin");
void StopEepromThread();
#if defined(__cplusplus)
void simuInit();
void simuStart(bool tests = true, const char * sdPath = nullptr, const char * settingsPath = nullptr);
void simuStop();
bool simuIsRunning();
void startEepromThread(const char * filename = "eeprom.bin");
void stopEepromThread();
#if defined(SIMU_AUDIO)
void StartAudioThread(int volumeGain = 10);
void StopAudioThread(void);
void startAudioThread(int volumeGain = 10);
void stopAudioThread(void);
#else
#define StartAudioThread(dummy)
#define StopAudioThread()
#define startAudioThread(dummy)
#define stopAudioThread()
#endif
#endif
void simuMain();
@@ -269,7 +271,6 @@ void simuMain();
#define USART_ClearFlag(...)
#if defined(STM32)
inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) { }
#define TIM_DeInit(...)
#define TIM_SetCompare2(...)
#define TIM_ClearFlag(...)
@@ -280,27 +281,10 @@ inline void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct) {
#define GPIO_ReadInputDataBit(GPIOx, pin) (GPIOx->BSRRL & pin)
#define RCC_AHB1PeriphClockCmd(...)
#define RCC_APB2PeriphClockCmd(...)
inline void SPI_Init(SPI_TypeDef* SPIx, SPI_InitTypeDef* SPI_InitStruct) { }
inline void SPI_CalculateCRC(SPI_TypeDef* SPIx, FunctionalState NewState) { }
inline void SPI_Cmd(SPI_TypeDef* SPIx, FunctionalState NewState) { }
inline FlagStatus SPI_I2S_GetFlagStatus(SPI_TypeDef* SPIx, uint16_t SPI_I2S_FLAG) { return RESET; }
inline uint16_t SPI_I2S_ReceiveData(SPI_TypeDef* SPIx) { return 0; }
inline void SPI_I2S_SendData(SPI_TypeDef* SPIx, uint16_t Data) { }
inline void DMA_DeInit(DMA_Stream_TypeDef* DMAy_Streamx) { }
inline void DMA_Init(DMA_Stream_TypeDef* DMAy_Streamx, DMA_InitTypeDef* DMA_InitStruct) { }
inline void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState) { }
inline void DMA_StructInit(DMA_InitTypeDef* DMA_InitStruct) { }
inline void DMA_Cmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState) { }
void lcdCopy(void * dest, void * src);
inline FlagStatus DMA_GetFlagStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_FLAG) { return RESET; }
inline ITStatus DMA_GetITStatus(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { return RESET; }
inline void DMA_ClearITPendingBit(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT) { }
inline void SPI_I2S_DMACmd(SPI_TypeDef* SPIx, uint16_t SPI_I2S_DMAReq, FunctionalState NewState) { }
inline void UART3_Configure(uint32_t baudrate, uint32_t masterClock) { }
inline void NVIC_Init(NVIC_InitTypeDef *) { }
#endif
inline void delay_01us(int dummy) { }
// inline void delay_01us(uint32_t dummy) { }
#define configure_pins(...)
#if defined(SDCARD) && !defined(SKIP_FATFS_DECLARATION) && !defined(SIMU_DISKIO)
+2 -2
View File
@@ -139,7 +139,7 @@ void eepromWriteBlock(uint8_t * buffer, size_t address, size_t size)
pthread_t eeprom_thread_pid;
void StartEepromThread(const char * filename)
void startEepromThread(const char * filename)
{
eepromFile = filename;
if (eepromFile) {
@@ -160,7 +160,7 @@ void StartEepromThread(const char * filename)
RTOS_CREATE_TASK(eeprom_thread_pid, eeprom_thread_function, "eeprom");
}
void StopEepromThread()
void stopEepromThread()
{
eeprom_thread_running = false;
sem_post(eeprom_write_sem);
+2
View File
@@ -28,6 +28,8 @@
#include "audio_driver.h"
#include "../opentx_constants.h"
#define CPU_FREQ 36000000
extern uint16_t ResetReason;
#define BOOTLOADER_SIZE 0x8000
+1 -1
View File
@@ -24,8 +24,8 @@
#include <inttypes.h>
#include "definitions.h"
#include "opentx_constants.h"
#include "board_common.h"
#include "hal.h"
#include "board_common.h"
#if defined(ROTARY_ENCODER_NAVIGATION)
// Rotary Encoder driver
+6
View File
@@ -21,6 +21,12 @@
#ifndef _HAL_H_
#define _HAL_H_
#if defined(STM32F4)
#define CPU_FREQ 168000000
#else
#define CPU_FREQ 120000000
#endif
// Keys
#if defined(PCBX9E)
#define KEYS_GPIO_REG_MENU GPIOD->IDR