So I'm trying to understand how calling millis() and delay() (which calls micros()) interacts with other interrupts in the system.
unsigned long millis()
{
unsigned long m;
uint8_t oldSREG = SREG;
// disable interrupts while we read timer0_millis or we might get an
// inconsistent value (e.g. in the middle of a write to timer0_millis)
cli();
m = timer0_millis;
SREG = oldSREG;
return m;
}
This function calls cli() to disable interrupts, but it never calls sei() to re-enable interrupts. The same happens inside the micros() function. How do interrupts get re-enabled? Is the application that calls millis() or delay() responsible for calling sei() after the function call?