I didn't know that CW2. Somewhere I read the timing could be off by 4us
Well, it certainly takes some time for the native interrupt handler to execute, but I don't have any numbers
I guess it also depends on what you consider low level code, as pin logic certainly could be considered really low level code
I guess in principle yes, but there is no code executed in the similar way like CPU executes its instructions. The pin
Is there any reason to re-use an event handler other than to save memory, and we are talking about a very tiny routine as discussed.
Personally, I sometimes re-use event handler when I need to handle multiple buttons, like this
... InterruptPort button1 = new InterruptPort(Pins.GPIO_PIN_D0, ...); InterruptPort button2 = new InterruptPort(Pins.GPIO_PIN_D1, ...); InterruptPort button3 = new InterruptPort(Pins.GPIO_PIN_D2, ...); ... button1.OnInterrupt += button_Interrupt; button2.OnInterrupt += button_Interrupt; button3.OnInterrupt += button_Interrupt; ... void button_Interrupt(uint data1, uint state, DateTime time) { var pin = (Cpu.Pin)data1; var on = (state != 0); switch(pin) { case Pins.GPIO_PIN_D0: ... break; case Pins.GPIO_PIN_D1: ... break; ... } // Or use data1 as array index, collection key etc. }It also makes diagnostic/troubleshooting easier in certain cases.