123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- #ifndef _H_EXT_CBTIMER_
- #define _H_EXT_CBTIMER_
- #include "EM_os.h"
- #include "cbtimer.h"
- #define EXT_CBTIMER_SUPPORT_REMAINING_TIME
- #define EXT_CBTIMER_MAX_ENTITIES 32
- #define EXT_CBTIMEOUT_MILLISEC 0x80000000
- #define EXT_CBTIMER_HANDLE_INIT_VAL 0xFF
- #define EXT_CBTIMER_STATIC_DATA_SIZE 32
- #define EXT_CBTIMER_ENTITY_FREE 0x00
- #define EXT_CBTIMER_ENTITY_IN_USE 0x01
- #define EXT_CBTIMER_ENTITY_IN_FREE 0x02
- #define EXT_CBTIMER_ENTITY_HOLD_ALLOC_DATA 0x00
- #define EXT_CBTIMER_ENTITY_FREE_ALLOC_DATA 0x01
- #define EXT_CBTIMER_ERR_ID 0xC000
- #define EXT_CBTIMER_MUTEX_INIT_FAILED (0x0001 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_COND_INIT_FAILED (0x0002 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_MUTEX_LOCK_FAILED (0x0003 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_MUTEX_UNLOCK_FAILED (0x0004 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_MEMORY_ALLOCATION_FAILED (0x0005 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_HANDLE_IS_NULL (0x0011 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_CALLBACK_IS_NULL (0x0012 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_QUEUE_EMPTY (0x0013 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_QUEUE_FULL (0x0014 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_ENTITY_SEARCH_FAILED (0x0015 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_NULL_PARAMETER_NOT_ALLOWED (0x0016 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_TIMEOUT_ZERO_NOT_ALLOWED (0x0017 | EXT_CBTIMER_ERR_ID)
- #define EXT_CBTIMER_FAILED_SET_TIME_EVENT (0x0018 | EXT_CBTIMER_ERR_ID)
- #define EXT_PHYOS_INVALID_TIMER_ID 0xFF
- typedef struct ext_cbtimer_entity_struct
- {
-
- UINT8 handle;
-
- void (* callback) (void *, UINT16);
-
- UCHAR *allocated_data;
-
- struct ext_cbtimer_entity_struct *next;
-
- UCHAR static_data[EXT_CBTIMER_STATIC_DATA_SIZE];
-
- UINT32 timeout;
- #ifdef EXT_CBTIMER_SUPPORT_REMAINING_TIME
-
- UINT64 start_timestamp;
- #endif
-
- UINT16 data_length;
-
- UCHAR in_use;
-
- UINT8 timer_id;
- } EXT_CBTIMER_ENTITY;
- typedef UINT8 EXT_cbtimer_handle;
- #ifdef __cplusplus
- extern "C" {
- #endif
- void EXT_cbtimer_init ( void );
- void ext_cbtimer_em_init ( void );
- void ext_cbtimer_em_shutdown ( void );
- EM_RESULT EXT_cbtimer_start_timer
- (
- EXT_cbtimer_handle *handle,
- UINT32 timeout,
- void (* callback) (void *, UINT16),
- void *args, UINT16 size_args
- );
- EM_RESULT EXT_cbtimer_restart_timer
- (
- EXT_cbtimer_handle handle,
- UINT32 new_timeout
- );
- EM_RESULT EXT_cbtimer_stop_timer ( EXT_cbtimer_handle handle );
- UINT32 EXT_cbtimer_get_remain_timer
- (
- EXT_cbtimer_handle handle
- );
- EM_RESULT EXT_cbtimer_get_remaining_time
- (
- EXT_cbtimer_handle handle,
- UINT32 * remaining_time_ms
- );
- EM_RESULT EXT_cbtimer_is_active_timer ( EXT_cbtimer_handle handle );
- EM_RESULT EXT_cbtimer_list_timer ( void );
- #ifdef __cplusplus
- };
- #endif
- #endif
|