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();
}
}