1 /** 2 * @file lv_tick.h 3 * Provide access to the system tick with 1 millisecond resolution 4 */ 5 6 #ifndef LV_TICK_H 7 #define LV_TICK_H 8 9 #ifdef __cplusplus 10 extern "C" { 11 #endif 12 13 /********************* 14 * INCLUDES 15 *********************/ 16 #include "../lv_conf_internal.h" 17 18 #include "../misc/lv_types.h" 19 20 /********************* 21 * DEFINES 22 *********************/ 23 #ifndef LV_ATTRIBUTE_TICK_INC 24 #define LV_ATTRIBUTE_TICK_INC 25 #endif 26 27 /********************** 28 * TYPEDEFS 29 **********************/ 30 typedef uint32_t (*lv_tick_get_cb_t)(void); 31 32 typedef void (*lv_delay_cb_t)(uint32_t ms); 33 34 /********************** 35 * GLOBAL PROTOTYPES 36 **********************/ 37 38 /** 39 * You have to call this function periodically 40 * @param tick_period the call period of this function in milliseconds 41 */ 42 LV_ATTRIBUTE_TICK_INC void lv_tick_inc(uint32_t tick_period); 43 44 /** 45 * Get the elapsed milliseconds since start up 46 * @return the elapsed milliseconds 47 */ 48 uint32_t lv_tick_get(void); 49 50 /** 51 * Get the elapsed milliseconds since a previous time stamp 52 * @param prev_tick a previous time stamp (return value of lv_tick_get() ) 53 * @return the elapsed milliseconds since 'prev_tick' 54 */ 55 uint32_t lv_tick_elaps(uint32_t prev_tick); 56 57 /** 58 * Delay for the given milliseconds. 59 * By default it's a blocking delay, but with `lv_delay_set_cb()` 60 * a custom delay function can be set too 61 * @param ms the number of milliseconds to delay 62 */ 63 void lv_delay_ms(uint32_t ms); 64 65 /** 66 * Set the custom callback for 'lv_tick_get' 67 * @param cb call this callback on 'lv_tick_get' 68 */ 69 void lv_tick_set_cb(lv_tick_get_cb_t cb); 70 71 /** 72 * Set a custom callback for 'lv_delay_ms' 73 * @param cb call this callback in 'lv_delay_ms' 74 */ 75 void lv_delay_set_cb(lv_delay_cb_t cb); 76 77 /********************** 78 * MACROS 79 **********************/ 80 81 #ifdef __cplusplus 82 } /*extern "C"*/ 83 #endif 84 85 #endif /*LV_TICK_H*/ 86