.. | .. |
---|
950 | 950 | |
---|
951 | 951 | /** @brief Initialize a timer |
---|
952 | 952 | * |
---|
953 | | - * Initializes a given timer instance. |
---|
954 | | - * This does not start the timer. |
---|
955 | | - |
---|
956 | | - * @param tim the timer to init. |
---|
957 | | - * @param callback the callback that would be called when 'tim' times out. |
---|
| 953 | + * Allocates resources for a new timer, and initializes them. This does not |
---|
| 954 | + * start the timer. |
---|
| 955 | + * |
---|
| 956 | + * @return a pointer to the allocated timer object, or NULL on failure. |
---|
958 | 957 | */ |
---|
959 | | -void _mali_osk_timer_init(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback); |
---|
| 958 | +_mali_osk_timer_t *_mali_osk_timer_init(_mali_osk_timer_callback_t callback); |
---|
960 | 959 | |
---|
961 | 960 | /** @brief Start a timer |
---|
962 | 961 | * |
---|
963 | 962 | * It is an error to start a timer without setting the callback via |
---|
964 | | - * _mali_osk_timer_init(). |
---|
| 963 | + * _mali_osk_timer_setcallback(). |
---|
965 | 964 | * |
---|
966 | 965 | * It is an error to use this to start an already started timer. |
---|
967 | 966 | * |
---|
968 | 967 | * The timer will expire in \a ticks_to_expire ticks, at which point, the |
---|
969 | 968 | * callback function will be invoked with the callback-specific data, |
---|
970 | | - * as registered by _mali_osk_timer_init(). |
---|
| 969 | + * as registered by _mali_osk_timer_setcallback(). |
---|
971 | 970 | * |
---|
972 | 971 | * @param tim the timer to start |
---|
973 | 972 | * @param ticks_to_expire the amount of time in ticks for the timer to run |
---|
.. | .. |
---|
981 | 980 | * stopped. If \a ticks_to_expire 0 the timer fires immediately. |
---|
982 | 981 | * |
---|
983 | 982 | * It is an error to modify a timer without setting the callback via |
---|
984 | | - * _mali_osk_timer_init(). |
---|
| 983 | + * _mali_osk_timer_setcallback(). |
---|
985 | 984 | * |
---|
986 | 985 | * The timer will expire at \a ticks_to_expire from the time of the call, at |
---|
987 | 986 | * which point, the callback function will be invoked with the |
---|
988 | | - * callback-specific data, as set by _mali_osk_timer_init(). |
---|
| 987 | + * callback-specific data, as set by _mali_osk_timer_setcallback(). |
---|
989 | 988 | * |
---|
990 | 989 | * @param tim the timer to modify, and start if necessary |
---|
991 | 990 | * @param ticks_to_expire the \em absolute time in ticks at which this timer |
---|
.. | .. |
---|
1035 | 1034 | */ |
---|
1036 | 1035 | mali_bool _mali_osk_timer_pending(_mali_osk_timer_t *tim); |
---|
1037 | 1036 | |
---|
| 1037 | +/** @brief Set a timer's callback parameters. |
---|
| 1038 | + * |
---|
| 1039 | + * This must be called at least once before a timer is started/modified. |
---|
| 1040 | + * |
---|
| 1041 | + * After a timer has been stopped or expires, the callback remains set. This |
---|
| 1042 | + * means that restarting the timer will call the same function with the same |
---|
| 1043 | + * parameters on expiry. |
---|
| 1044 | + * |
---|
| 1045 | + * @param tim the timer to set callback on. |
---|
| 1046 | + * @param callback Function to call when timer expires |
---|
| 1047 | + * @param data Function-specific data to supply to the function on expiry. |
---|
| 1048 | + */ |
---|
| 1049 | +void _mali_osk_timer_setcallback(_mali_osk_timer_t *tim, _mali_osk_timer_callback_t callback, void *data); |
---|
| 1050 | + |
---|
| 1051 | +/** @brief Terminate a timer, and deallocate resources. |
---|
| 1052 | + * |
---|
| 1053 | + * The timer must first be stopped by calling _mali_osk_timer_del(). |
---|
| 1054 | + * |
---|
| 1055 | + * It is a programming error for _mali_osk_timer_term() to be called on: |
---|
| 1056 | + * - timer that is currently running |
---|
| 1057 | + * - a timer that is currently executing its callback. |
---|
| 1058 | + * |
---|
| 1059 | + * @param tim the timer to deallocate. |
---|
| 1060 | + */ |
---|
| 1061 | +void _mali_osk_timer_term(_mali_osk_timer_t *tim); |
---|
| 1062 | +/** @} */ /* end group _mali_osk_timer */ |
---|
| 1063 | + |
---|
| 1064 | + |
---|
1038 | 1065 | /** @defgroup _mali_osk_time OSK Time functions |
---|
1039 | 1066 | * |
---|
1040 | 1067 | * \ref _mali_osk_time use the OS's representation of time, which are |
---|