mn_tickhook.hpp
Go to the documentation of this file.
1 
19 #ifndef MINLIB_ESP32_TICK_HOOK_
20 #define MINLIB_ESP32_TICK_HOOK_
21 
22 #include "mn_config.hpp"
23 
24 #include <freertos/FreeRTOS.h>
25 #include <freertos/task.h>
26 
27 #if ( configUSE_TICK_HOOK == 1 )
28 
29 #include "mn_error.hpp"
30 #include "queue/mn_queue.hpp"
31 #include "mn_task.hpp"
32 #include "mn_tickhook_entry.hpp"
33 
34 
40 extern "C" void vApplicationTickHook(void);
41 
42 namespace mn {
50  class base_tickhook {
51  private:
58  base_tickhook();
59 
63  static base_tickhook* m_pInstance;
67  static mutex_t m_staticInstanceMux;
68  public:
73  static base_tickhook& instance();
74 
85  int enqueue(base_tickhook_entry* entry,
86  unsigned int timeout = (unsigned int) 0xffffffffUL);
97  int dequeue(base_tickhook_entry* entry,
98  unsigned int timeout = (unsigned int) 0xffffffffUL);
102  void clear();
103 
107  void reset();
112  unsigned int count();
118  void onApplicationTickHook();
119  private:
120 
125  void swap();
126  private:
127  mutex_t m_mutexAdd;
128  queue::queue_t m_listHooks, m_listToAdd;
129  unsigned int m_iCurrent;
130  };
131 
132  using tickhook_t = base_tickhook;
133 }
134 
135 #endif // #if ( configUSE_TICK_HOOK == 1 )
136 #endif // MINLIB_ESP32_TICK_HOOK_
A list of all error codes in this lib. This file is part of the Mini Thread Library (https://github....
basic_queue queue_t
Definition: queue/mn_queue.hpp:142
Definition: mn_allocator_typetraits.hpp:25
basic_mutex mutex_t
Definition: mn_mutex.hpp:76
void swap(TAssignable &a, TAssignable &b)
Definition: mn_algorithm.hpp:312