ref: 0.13.0
src/libs/lvgl/src/lv_misc/lv_async.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
/** * @file lv_async.c * */ /********************* * INCLUDES *********************/ #include "lv_async.h" /********************* * DEFINES *********************/ /********************** * TYPEDEFS **********************/ /********************** * STATIC PROTOTYPES **********************/ static void lv_async_task_cb(lv_task_t *task); /********************** * STATIC VARIABLES **********************/ /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ lv_res_t lv_async_call(lv_async_cb_t async_xcb, void * user_data) { /*Allocate an info structure */ lv_async_info_t *info = lv_mem_alloc(sizeof(lv_async_info_t)); if(info == NULL) return LV_RES_INV; /* Create a new task */ /* Use highest priority so that it will run before a refresh */ lv_task_t *task = lv_task_create(lv_async_task_cb, 0, LV_TASK_PRIO_HIGHEST, info); if(task == NULL) { lv_mem_free(info); return LV_RES_INV; } info->cb = async_xcb; info->user_data = user_data; /* Set the task's user data */ task->user_data = info; lv_task_once(task); return LV_RES_OK; } /********************** * STATIC FUNCTIONS **********************/ static void lv_async_task_cb(lv_task_t *task) { lv_async_info_t *info = (lv_async_info_t *)task->user_data; info->cb(info->user_data); lv_mem_free(info); } |