From bdf3d4e66606135e84a49ce47da22df2b66120a7 Mon Sep 17 00:00:00 2001 From: Fabian Date: Fri, 17 Feb 2023 16:09:53 +0100 Subject: [PATCH] Revert "fix(flush,tick): use atomics instead of volatile for synchronization (#3965)" (#3997) --- src/hal/lv_hal_disp.h | 22 ++++++---------------- src/hal/lv_hal_tick.c | 11 ++--------- src/misc/lv_types.h | 9 --------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/src/hal/lv_hal_disp.h b/src/hal/lv_hal_disp.h index ec7c1ff3e..cd0d676e1 100644 --- a/src/hal/lv_hal_disp.h +++ b/src/hal/lv_hal_disp.h @@ -23,11 +23,6 @@ extern "C" { #include "../misc/lv_area.h" #include "../misc/lv_ll.h" #include "../misc/lv_timer.h" -#include "../misc/lv_types.h" - -#if LV_USE_ATOMICS == 1 -#include -#endif /********************* * DEFINES @@ -52,11 +47,6 @@ struct _lv_disp_t; struct _lv_disp_drv_t; struct _lv_theme_t; -#if LV_USE_ATOMICS == 1 -#define FLUSHING_TYPE atomic_int -#else -#define FLUSHING_TYPE volatile int -#endif /** * Structure for holding display buffer information. */ @@ -67,13 +57,13 @@ typedef struct _lv_disp_draw_buf_t { /*Internal, used by the library*/ void * buf_act; uint32_t size; /*In pixel count*/ - FLUSHING_TYPE flushing; - /*It was the last chunk to flush. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ - FLUSHING_TYPE flushing_last; - uint32_t last_area : 1; /*1: the last area is being rendered*/ - uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/ + /*1: flushing is in progress. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ + volatile int flushing; + /*1: It was the last chunk to flush. (It can't be a bit field because when it's cleared from IRQ Read-Modify-Write issue might occur)*/ + volatile int flushing_last; + volatile uint32_t last_area : 1; /*1: the last area is being rendered*/ + volatile uint32_t last_part : 1; /*1: the last part of the current area is being rendered*/ } lv_disp_draw_buf_t; -#undef FLUSHING_TYPE typedef enum { LV_DISP_ROT_NONE = 0, diff --git a/src/hal/lv_hal_tick.c b/src/hal/lv_hal_tick.c index 0b904672c..c12a5942e 100644 --- a/src/hal/lv_hal_tick.c +++ b/src/hal/lv_hal_tick.c @@ -7,8 +7,6 @@ * INCLUDES *********************/ #include "lv_hal_tick.h" -#include "../misc/lv_types.h" -#include #include #if LV_TICK_CUSTOM == 1 @@ -31,13 +29,8 @@ * STATIC VARIABLES **********************/ #if !LV_TICK_CUSTOM - #if LV_USE_ATOMICS == 1 - static _Atomic(uint32_t) sys_time = 0; - static atomic_int tick_irq_flag; - #else - static volatile uint32_t sys_time = 0; - static volatile int tick_irq_flag; - #endif + static uint32_t sys_time = 0; + static volatile uint8_t tick_irq_flag; #endif /********************** diff --git a/src/misc/lv_types.h b/src/misc/lv_types.h index e2ea2f0be..8dfc07b0f 100644 --- a/src/misc/lv_types.h +++ b/src/misc/lv_types.h @@ -32,15 +32,6 @@ extern "C" { #endif -/*Use atomics instead of volatile variables for state which is potentially shared between threads, as long as - *the compiler supports it.*/ -#if (defined(__cplusplus) && __cplusplus >= 201103L)\ - || (__STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)) -#define LV_USE_ATOMICS 1 -#else -#define LV_USE_ATOMICS 0 -#endif - /********************** * TYPEDEFS **********************/