Ticker callbacks are triggered from a timer interrupt, right? So they could occur at any time, even during a call to a library function. Which library functions are safe to re-enter?
I've got a ticker that fires 100 times a second, reads a value from an analog input (is that safe to re-enter?), does some processing with some data that's private to the ticker routine, and then occasionally needs to send out some output to the network. I've a feeling that will take longer than 1/100th of a second. If my ticker routine runs for longer than 1/100th of a second, will it get called again before it's finished? Argh!
Probably I should have the ticker pass a signal to the main code and have the main code send output to the network, which to be safe probably requires a buffer queue in between the ticker-routine and the output-sending routine, and that buffer queue will have data items that both the ticker-routine and the output-sending routine will need to access (head and tail of the queue, count of items). If these were threads I'd use locks, but the ticker-routine can't sleep while it waits for a lock.
Can I temporarily disable the ticker interrupt while the output-sending routine accesses the buffer queue, to ensure the ticker doesn't touch the queue while the output-sender is?
Rob.
Ticker callbacks are triggered from a timer interrupt, right? So they could occur at any time, even during a call to a library function. Which library functions are safe to re-enter?
I've got a ticker that fires 100 times a second, reads a value from an analog input (is that safe to re-enter?), does some processing with some data that's private to the ticker routine, and then occasionally needs to send out some output to the network. I've a feeling that will take longer than 1/100th of a second. If my ticker routine runs for longer than 1/100th of a second, will it get called again before it's finished? Argh!
Probably I should have the ticker pass a signal to the main code and have the main code send output to the network, which to be safe probably requires a buffer queue in between the ticker-routine and the output-sending routine, and that buffer queue will have data items that both the ticker-routine and the output-sending routine will need to access (head and tail of the queue, count of items). If these were threads I'd use locks, but the ticker-routine can't sleep while it waits for a lock.
Can I temporarily disable the ticker interrupt while the output-sending routine accesses the buffer queue, to ensure the ticker doesn't touch the queue while the output-sender is?
Rob.