mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
feat(nuttx): add cache interface (#5348)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
parent
5c459ba544
commit
86138aad37
77
src/dev/nuttx/lv_nuttx_cache.c
Normal file
77
src/dev/nuttx/lv_nuttx_cache.c
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* @file lv_nuttx_cache.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#include "lv_nuttx_cache.h"
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_NUTTX
|
||||
|
||||
#include <nuttx/cache.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_nuttx_cache_init(void)
|
||||
{
|
||||
lv_draw_buf_handlers_t * handlers = lv_draw_buf_get_handlers();
|
||||
handlers->invalidate_cache_cb = invalidate_cache;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
static void invalidate_cache(void * buf, uint32_t stride, lv_color_format_t color_format, const lv_area_t * area)
|
||||
{
|
||||
LV_UNUSED(color_format);
|
||||
LV_ASSERT_NULL(buf);
|
||||
|
||||
lv_uintptr_t start;
|
||||
lv_uintptr_t end;
|
||||
|
||||
if(area) {
|
||||
int32_t h = lv_area_get_height(area);
|
||||
start = (lv_uintptr_t)buf + area->y1 * stride;
|
||||
end = start + h * stride;
|
||||
}
|
||||
else {
|
||||
/* If area is empty, use stride as length */
|
||||
start = (lv_uintptr_t)buf;
|
||||
end = start + stride;
|
||||
}
|
||||
|
||||
LV_UNUSED(start);
|
||||
LV_UNUSED(end);
|
||||
up_invalidate_dcache(start, end);
|
||||
}
|
||||
|
||||
#endif /* LV_USE_NUTTX */
|
39
src/dev/nuttx/lv_nuttx_cache.h
Normal file
39
src/dev/nuttx/lv_nuttx_cache.h
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @file lv_nuttx_cache.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_NUTTX_CACHE_H
|
||||
#define LV_NUTTX_CACHE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
void lv_nuttx_cache_init(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_NUTTX_CACHE_H*/
|
@ -13,6 +13,7 @@
|
||||
#include <time.h>
|
||||
#include <nuttx/tls.h>
|
||||
#include <syslog.h>
|
||||
#include "lv_nuttx_cache.h"
|
||||
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
@ -95,6 +96,8 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result)
|
||||
#endif
|
||||
lv_tick_set_cb(millis);
|
||||
|
||||
lv_nuttx_cache_init();
|
||||
|
||||
if(result) {
|
||||
lv_memzero(result, sizeof(lv_nuttx_result_t));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user