swTimer.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #ifndef __SW_TIMER_H__
  2. #define __SW_TIMER_H__
  3. #include "user_interface.h"
  4. //#define SWTMR_DEBUG
  5. #define USE_SWTMR_ERROR_STRINGS
  6. #if defined(DEVELOP_VERSION)
  7. #define SWTMR_DEBUG
  8. #endif
  9. #if defined(SWTMR_DEBUG)
  10. #define SWTMR_DBG(fmt, ...) dbg_printf("\tSWTIMER(%s):"fmt"\n", __FUNCTION__, ##__VA_ARGS__)
  11. #else
  12. #define SWTMR_DBG(...)
  13. #endif
  14. #if defined(NODE_ERROR)
  15. #define SWTMR_ERR(fmt, ...) NODE_ERR("%s"fmt"\n", "SWTIMER:", ##__VA_ARGS__)
  16. #else
  17. #define SWTMR_ERR(...)
  18. #endif
  19. enum SWTMR_STATUS{
  20. SWTMR_FAIL = 0,
  21. SWTMR_OK = 1,
  22. SWTMR_MALLOC_FAIL = 10,
  23. SWTMR_TIMER_NOT_ARMED,
  24. // SWTMR_NULL_PTR,
  25. SWTMR_REGISTRY_NO_REGISTERED_TIMERS,
  26. // SWTMR_SUSPEND_ARRAY_INITIALIZATION_FAILED,
  27. // SWTMR_SUSPEND_ARRAY_ADD_FAILED,
  28. // SWTMR_SUSPEND_ARRAY_REMOVE_FAILED,
  29. SWTMR_SUSPEND_TIMER_ALREADY_SUSPENDED,
  30. SWTMR_SUSPEND_TIMER_ALREADY_REARMED,
  31. SWTMR_SUSPEND_NO_SUSPENDED_TIMERS,
  32. SWTMR_SUSPEND_TIMER_NOT_SUSPENDED,
  33. };
  34. /* Global Function Declarations */
  35. void swtmr_register(void* timer_ptr);
  36. void swtmr_unregister(void* timer_ptr);
  37. int swtmr_suspend(os_timer_t* timer_ptr);
  38. int swtmr_resume(os_timer_t* timer_ptr);
  39. void swtmr_print_registry(void);
  40. void swtmr_print_suspended(void);
  41. void swtmr_print_timer_list(void);
  42. const char* swtmr_errorcode2str(int error_value);
  43. bool swtmr_suspended_test(os_timer_t* timer_ptr);
  44. #endif // __SW_TIMER_H__