Fast AnalogIn module which asks for a single non blocking reading and causes and interrupt when done.

Revision:
3:d4f99bc10643
Parent:
2:336af413f75c
--- a/NbAnalogIn.cpp	Mon Apr 03 10:59:17 2017 +0000
+++ b/NbAnalogIn.cpp	Tue Apr 04 22:35:34 2017 +0000
@@ -26,12 +26,12 @@
 NbAnalogIn* NbAnalogIn::handlers[ADC_CHANNELS] = {0}; 
 volatile bool NbAnalogIn::converting = false; 
 
-NbAnalogIn::NbAnalogIn( PinName pin, void (*irqfunc)() ) {
+NbAnalogIn::NbAnalogIn( PinName pin) {
     
     NVIC_EnableIRQ(ADC_IRQn);
     NVIC_SetVector(ADC_IRQn, (uint32_t)irq);
     
-    cirq = irqfunc;
+ 
     
     channel = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
     if (channel == (uint32_t)NC)
@@ -65,6 +65,13 @@
     LPC_ADC->ADINTEN |= (1 << 8);
 }
 
+void NbAnalogIn::setInterrupt(void (*irqfunc)() , int prio) {
+    cirq = irqfunc;
+    
+    if( prio >=0 && prio <=32 ) {
+        NVIC_SetPriority(ADC_IRQn, prio);  //set priority of these interrupts
+    }
+}
 
 int NbAnalogIn::readBl() {