When you set a watch on a pin, does a change on the pin create an interrupt? In the routine that queues the watch do you clear the interrupt bit for the pin?
Yes to both...
Good point about clearing the interrupt flag.
Personally I'd probably leave setWatch to be just for pins, and would have a new function for IRQs (after all, things like 'edge' and 'debounce' make little sense for IRQs).
To be honest it all starts to get quite complicated. There are around 30 possible interrupts I think - I wonder whether it makes sense to just add built-in handlers for all the common ones which automatically clear the relevant flags.
Then you could just do E.on('IRQ15', function() { ... })
Just to add, if you're so inclined I think you can hack things together with Espruino as-is:
Use process.memory() to find the end of the stack, where there will be some RAM you can use
Use the Assembler to write some ARM assembly that clears the relevant flag and then toggles an IO pin
Manually copy that assembled code to the end of the stack as well
Now 'poke' the address of that code into the vector table
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Yes to both...
Good point about clearing the interrupt flag.
Personally I'd probably leave
setWatch
to be just for pins, and would have a new function for IRQs (after all, things like 'edge' and 'debounce' make little sense for IRQs).To be honest it all starts to get quite complicated. There are around 30 possible interrupts I think - I wonder whether it makes sense to just add built-in handlers for all the common ones which automatically clear the relevant flags.
Then you could just do
E.on('IRQ15', function() { ... })
Just to add, if you're so inclined I think you can hack things together with Espruino as-is:
process.memory()
to find the end of the stack, where there will be some RAM you can usesetWatch