The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
Diff: drivers/InterruptManager.h
- Revision:
- 170:e95d10626187
- Parent:
- 165:d1b4690b3f8b
- Child:
- 172:65be27845400
--- a/drivers/InterruptManager.h Fri Jun 22 15:38:59 2018 +0100 +++ b/drivers/InterruptManager.h Thu Sep 06 13:39:34 2018 +0100 @@ -58,26 +58,26 @@ class InterruptManager : private NonCopyable<InterruptManager> { public: /** Get the instance of InterruptManager Class - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @return the only instance of this class */ MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") - static InterruptManager* get(); + "public API of mbed-os and is being removed in the future.") + static InterruptManager *get(); /** Destroy the current instance of the interrupt manager - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * */ MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") + "public API of mbed-os and is being removed in the future.") static void destroy(); /** Add a handler for an interrupt at the end of the handler list - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @param function the handler to add @@ -87,14 +87,15 @@ * The function object created for 'function' */ MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") - pFunctionPointer_t add_handler(void (*function)(void), IRQn_Type irq) { + "public API of mbed-os and is being removed in the future.") + pFunctionPointer_t add_handler(void (*function)(void), IRQn_Type irq) + { // Underlying call is thread safe return add_common(function, irq); } /** Add a handler for an interrupt at the beginning of the handler list - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @param function the handler to add @@ -104,14 +105,15 @@ * The function object created for 'function' */ MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") - pFunctionPointer_t add_handler_front(void (*function)(void), IRQn_Type irq) { + "public API of mbed-os and is being removed in the future.") + pFunctionPointer_t add_handler_front(void (*function)(void), IRQn_Type irq) + { // Underlying call is thread safe return add_common(function, irq, true); } /** Add a handler for an interrupt at the end of the handler list - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @param tptr pointer to the object that has the handler function @@ -123,14 +125,15 @@ */ template<typename T> MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") - pFunctionPointer_t add_handler(T* tptr, void (T::*mptr)(void), IRQn_Type irq) { + "public API of mbed-os and is being removed in the future.") + pFunctionPointer_t add_handler(T *tptr, void (T::*mptr)(void), IRQn_Type irq) + { // Underlying call is thread safe return add_common(tptr, mptr, irq); } /** Add a handler for an interrupt at the beginning of the handler list - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @param tptr pointer to the object that has the handler function @@ -142,14 +145,15 @@ */ template<typename T> MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") - pFunctionPointer_t add_handler_front(T* tptr, void (T::*mptr)(void), IRQn_Type irq) { + "public API of mbed-os and is being removed in the future.") + pFunctionPointer_t add_handler_front(T *tptr, void (T::*mptr)(void), IRQn_Type irq) + { // Underlying call is thread safe return add_common(tptr, mptr, irq, true); } /** Remove a handler from an interrupt - * @deprecated + * @deprecated * Do not use this function, this class is not part of the public API of mbed-os and is being removed in the future. * * @param handler the function object for the handler to remove @@ -159,7 +163,7 @@ * true if the handler was found and removed, false otherwise */ MBED_DEPRECATED_SINCE("mbed-os-5.6", "This class is not part of the " - "public API of mbed-os and is being removed in the future.") + "public API of mbed-os and is being removed in the future.") bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq); private: @@ -170,27 +174,29 @@ void unlock(); template<typename T> - pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) { + pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front = false) + { _mutex.lock(); int irq_pos = get_irq_index(irq); bool change = must_replace_vector(irq); pFunctionPointer_t pf = front ? _chains[irq_pos]->add_front(tptr, mptr) : _chains[irq_pos]->add(tptr, mptr); - if (change) + if (change) { NVIC_SetVector(irq, (uint32_t)&InterruptManager::static_irq_helper); + } _mutex.unlock(); return pf; } - pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front=false); + pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front = false); bool must_replace_vector(IRQn_Type irq); int get_irq_index(IRQn_Type irq); void irq_helper(); - void add_helper(void (*function)(void), IRQn_Type irq, bool front=false); + void add_helper(void (*function)(void), IRQn_Type irq, bool front = false); static void static_irq_helper(); - CallChain* _chains[NVIC_NUM_VECTORS]; - static InterruptManager* _instance; + CallChain *_chains[NVIC_NUM_VECTORS]; + static InterruptManager *_instance; PlatformMutex _mutex; };