Output the audio signal with filtering by graphic equalizer in the *.wav file on the SD card using onboard CODEC. SD カードの *.wav ファイルのオーディオ信号をグラフィック・イコライザを通して,ボードに搭載されているCODEC で出力する.
Dependencies: F746_GUI F746_SAI_IO SD_PlayerSkeleton FrequencyResponseDrawer
mbed_src_STM32F7/api/InterruptManager.h@24:f78f9d0ac262, 2017-04-10 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Apr 10 04:07:35 2017 +0000
- Revision:
- 24:f78f9d0ac262
- Parent:
- 16:cbb726ac20d8
25
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 16:cbb726ac20d8 | 1 | #ifndef MBED_INTERRUPTMANAGER_H |
MikamiUitOpen | 16:cbb726ac20d8 | 2 | #define MBED_INTERRUPTMANAGER_H |
MikamiUitOpen | 16:cbb726ac20d8 | 3 | |
MikamiUitOpen | 16:cbb726ac20d8 | 4 | #include "cmsis.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 5 | #include "CallChain.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 6 | #include <string.h> |
MikamiUitOpen | 16:cbb726ac20d8 | 7 | |
MikamiUitOpen | 16:cbb726ac20d8 | 8 | namespace mbed { |
MikamiUitOpen | 16:cbb726ac20d8 | 9 | |
MikamiUitOpen | 16:cbb726ac20d8 | 10 | /** Use this singleton if you need to chain interrupt handlers. |
MikamiUitOpen | 16:cbb726ac20d8 | 11 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 12 | * Example (for LPC1768): |
MikamiUitOpen | 16:cbb726ac20d8 | 13 | * @code |
MikamiUitOpen | 16:cbb726ac20d8 | 14 | * #include "InterruptManager.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 15 | * #include "mbed.h" |
MikamiUitOpen | 16:cbb726ac20d8 | 16 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 17 | * Ticker flipper; |
MikamiUitOpen | 16:cbb726ac20d8 | 18 | * DigitalOut led1(LED1); |
MikamiUitOpen | 16:cbb726ac20d8 | 19 | * DigitalOut led2(LED2); |
MikamiUitOpen | 16:cbb726ac20d8 | 20 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 21 | * void flip(void) { |
MikamiUitOpen | 16:cbb726ac20d8 | 22 | * led1 = !led1; |
MikamiUitOpen | 16:cbb726ac20d8 | 23 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 24 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 25 | * void handler(void) { |
MikamiUitOpen | 16:cbb726ac20d8 | 26 | * led2 = !led1; |
MikamiUitOpen | 16:cbb726ac20d8 | 27 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 28 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 29 | * int main() { |
MikamiUitOpen | 16:cbb726ac20d8 | 30 | * led1 = led2 = 0; |
MikamiUitOpen | 16:cbb726ac20d8 | 31 | * flipper.attach(&flip, 1.0); |
MikamiUitOpen | 16:cbb726ac20d8 | 32 | * InterruptManager::get()->add_handler(handler, TIMER3_IRQn); |
MikamiUitOpen | 16:cbb726ac20d8 | 33 | * } |
MikamiUitOpen | 16:cbb726ac20d8 | 34 | * @endcode |
MikamiUitOpen | 16:cbb726ac20d8 | 35 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 36 | class InterruptManager { |
MikamiUitOpen | 16:cbb726ac20d8 | 37 | public: |
MikamiUitOpen | 16:cbb726ac20d8 | 38 | /** Return the only instance of this class |
MikamiUitOpen | 16:cbb726ac20d8 | 39 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 40 | static InterruptManager* get(); |
MikamiUitOpen | 16:cbb726ac20d8 | 41 | |
MikamiUitOpen | 16:cbb726ac20d8 | 42 | /** Destroy the current instance of the interrupt manager |
MikamiUitOpen | 16:cbb726ac20d8 | 43 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 44 | static void destroy(); |
MikamiUitOpen | 16:cbb726ac20d8 | 45 | |
MikamiUitOpen | 16:cbb726ac20d8 | 46 | /** Add a handler for an interrupt at the end of the handler list |
MikamiUitOpen | 16:cbb726ac20d8 | 47 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 48 | * @param function the handler to add |
MikamiUitOpen | 16:cbb726ac20d8 | 49 | * @param irq interrupt number |
MikamiUitOpen | 16:cbb726ac20d8 | 50 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 51 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 52 | * The function object created for 'function' |
MikamiUitOpen | 16:cbb726ac20d8 | 53 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 54 | pFunctionPointer_t add_handler(void (*function)(void), IRQn_Type irq) { |
MikamiUitOpen | 16:cbb726ac20d8 | 55 | return add_common(function, irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 56 | } |
MikamiUitOpen | 16:cbb726ac20d8 | 57 | |
MikamiUitOpen | 16:cbb726ac20d8 | 58 | /** Add a handler for an interrupt at the beginning of the handler list |
MikamiUitOpen | 16:cbb726ac20d8 | 59 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 60 | * @param function the handler to add |
MikamiUitOpen | 16:cbb726ac20d8 | 61 | * @param irq interrupt number |
MikamiUitOpen | 16:cbb726ac20d8 | 62 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 63 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 64 | * The function object created for 'function' |
MikamiUitOpen | 16:cbb726ac20d8 | 65 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 66 | pFunctionPointer_t add_handler_front(void (*function)(void), IRQn_Type irq) { |
MikamiUitOpen | 16:cbb726ac20d8 | 67 | return add_common(function, irq, true); |
MikamiUitOpen | 16:cbb726ac20d8 | 68 | } |
MikamiUitOpen | 16:cbb726ac20d8 | 69 | |
MikamiUitOpen | 16:cbb726ac20d8 | 70 | /** Add a handler for an interrupt at the end of the handler list |
MikamiUitOpen | 16:cbb726ac20d8 | 71 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 72 | * @param tptr pointer to the object that has the handler function |
MikamiUitOpen | 16:cbb726ac20d8 | 73 | * @param mptr pointer to the actual handler function |
MikamiUitOpen | 16:cbb726ac20d8 | 74 | * @param irq interrupt number |
MikamiUitOpen | 16:cbb726ac20d8 | 75 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 76 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 77 | * The function object created for 'tptr' and 'mptr' |
MikamiUitOpen | 16:cbb726ac20d8 | 78 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 79 | template<typename T> |
MikamiUitOpen | 16:cbb726ac20d8 | 80 | pFunctionPointer_t add_handler(T* tptr, void (T::*mptr)(void), IRQn_Type irq) { |
MikamiUitOpen | 16:cbb726ac20d8 | 81 | return add_common(tptr, mptr, irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 82 | } |
MikamiUitOpen | 16:cbb726ac20d8 | 83 | |
MikamiUitOpen | 16:cbb726ac20d8 | 84 | /** Add a handler for an interrupt at the beginning of the handler list |
MikamiUitOpen | 16:cbb726ac20d8 | 85 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 86 | * @param tptr pointer to the object that has the handler function |
MikamiUitOpen | 16:cbb726ac20d8 | 87 | * @param mptr pointer to the actual handler function |
MikamiUitOpen | 16:cbb726ac20d8 | 88 | * @param irq interrupt number |
MikamiUitOpen | 16:cbb726ac20d8 | 89 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 90 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 91 | * The function object created for 'tptr' and 'mptr' |
MikamiUitOpen | 16:cbb726ac20d8 | 92 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 93 | template<typename T> |
MikamiUitOpen | 16:cbb726ac20d8 | 94 | pFunctionPointer_t add_handler_front(T* tptr, void (T::*mptr)(void), IRQn_Type irq) { |
MikamiUitOpen | 16:cbb726ac20d8 | 95 | return add_common(tptr, mptr, irq, true); |
MikamiUitOpen | 16:cbb726ac20d8 | 96 | } |
MikamiUitOpen | 16:cbb726ac20d8 | 97 | |
MikamiUitOpen | 16:cbb726ac20d8 | 98 | /** Remove a handler from an interrupt |
MikamiUitOpen | 16:cbb726ac20d8 | 99 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 100 | * @param handler the function object for the handler to remove |
MikamiUitOpen | 16:cbb726ac20d8 | 101 | * @param irq the interrupt number |
MikamiUitOpen | 16:cbb726ac20d8 | 102 | * |
MikamiUitOpen | 16:cbb726ac20d8 | 103 | * @returns |
MikamiUitOpen | 16:cbb726ac20d8 | 104 | * true if the handler was found and removed, false otherwise |
MikamiUitOpen | 16:cbb726ac20d8 | 105 | */ |
MikamiUitOpen | 16:cbb726ac20d8 | 106 | bool remove_handler(pFunctionPointer_t handler, IRQn_Type irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 107 | |
MikamiUitOpen | 16:cbb726ac20d8 | 108 | private: |
MikamiUitOpen | 16:cbb726ac20d8 | 109 | InterruptManager(); |
MikamiUitOpen | 16:cbb726ac20d8 | 110 | ~InterruptManager(); |
MikamiUitOpen | 16:cbb726ac20d8 | 111 | |
MikamiUitOpen | 16:cbb726ac20d8 | 112 | // We declare the copy contructor and the assignment operator, but we don't |
MikamiUitOpen | 16:cbb726ac20d8 | 113 | // implement them. This way, if someone tries to copy/assign our instance, |
MikamiUitOpen | 16:cbb726ac20d8 | 114 | // he will get an error at compile time. |
MikamiUitOpen | 16:cbb726ac20d8 | 115 | InterruptManager(const InterruptManager&); |
MikamiUitOpen | 16:cbb726ac20d8 | 116 | InterruptManager& operator =(const InterruptManager&); |
MikamiUitOpen | 16:cbb726ac20d8 | 117 | |
MikamiUitOpen | 16:cbb726ac20d8 | 118 | template<typename T> |
MikamiUitOpen | 16:cbb726ac20d8 | 119 | pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) { |
MikamiUitOpen | 16:cbb726ac20d8 | 120 | int irq_pos = get_irq_index(irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 121 | bool change = must_replace_vector(irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 122 | |
MikamiUitOpen | 16:cbb726ac20d8 | 123 | pFunctionPointer_t pf = front ? _chains[irq_pos]->add_front(tptr, mptr) : _chains[irq_pos]->add(tptr, mptr); |
MikamiUitOpen | 16:cbb726ac20d8 | 124 | if (change) |
MikamiUitOpen | 16:cbb726ac20d8 | 125 | NVIC_SetVector(irq, (uint32_t)&InterruptManager::static_irq_helper); |
MikamiUitOpen | 16:cbb726ac20d8 | 126 | return pf; |
MikamiUitOpen | 16:cbb726ac20d8 | 127 | } |
MikamiUitOpen | 16:cbb726ac20d8 | 128 | |
MikamiUitOpen | 16:cbb726ac20d8 | 129 | pFunctionPointer_t add_common(void (*function)(void), IRQn_Type irq, bool front=false); |
MikamiUitOpen | 16:cbb726ac20d8 | 130 | bool must_replace_vector(IRQn_Type irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 131 | int get_irq_index(IRQn_Type irq); |
MikamiUitOpen | 16:cbb726ac20d8 | 132 | void irq_helper(); |
MikamiUitOpen | 16:cbb726ac20d8 | 133 | void add_helper(void (*function)(void), IRQn_Type irq, bool front=false); |
MikamiUitOpen | 16:cbb726ac20d8 | 134 | static void static_irq_helper(); |
MikamiUitOpen | 16:cbb726ac20d8 | 135 | |
MikamiUitOpen | 16:cbb726ac20d8 | 136 | CallChain* _chains[NVIC_NUM_VECTORS]; |
MikamiUitOpen | 16:cbb726ac20d8 | 137 | static InterruptManager* _instance; |
MikamiUitOpen | 16:cbb726ac20d8 | 138 | }; |
MikamiUitOpen | 16:cbb726ac20d8 | 139 | |
MikamiUitOpen | 16:cbb726ac20d8 | 140 | } // namespace mbed |
MikamiUitOpen | 16:cbb726ac20d8 | 141 | |
MikamiUitOpen | 16:cbb726ac20d8 | 142 | #endif |
MikamiUitOpen | 16:cbb726ac20d8 | 143 |