Fast AnalogIn module which asks for a single non blocking reading and causes and interrupt when done.
Diff: NbAnalogIn.h
- Revision:
- 3:d4f99bc10643
- Parent:
- 2:336af413f75c
diff -r 336af413f75c -r d4f99bc10643 NbAnalogIn.h --- a/NbAnalogIn.h Mon Apr 03 10:59:17 2017 +0000 +++ b/NbAnalogIn.h Tue Apr 04 22:35:34 2017 +0000 @@ -14,13 +14,20 @@ public: - /** * Create a NbAnalogIn object, sets up ADC * * @param pin AnalogIn pin to connect to */ - NbAnalogIn( PinName pin, void (*irqfunc)() = 0 ); + NbAnalogIn( PinName pin ); + + /** + * Set interrupt options + * + * @param irqfunc - callback function executed at the end of interrupts + * @param priority - set interrupt priority level. -1 (default) leaves them unchanged + */ + void setInterrupt(void (*irqfunc)() = 0, int prio = -1); /** * does a single blocking read and returns a 12 bit output @@ -52,11 +59,6 @@ return read(); } - - // custom interrupt handler which, if set, is called after the internal - // interrupt handling - void (* cirq)(); - private: @@ -72,7 +74,9 @@ static void irq(); static NbAnalogIn* handlers[ADC_CHANNELS]; - + // custom interrupt handler which, if set, is called after the internal + // interrupt handling + void (* cirq)(); };