/* Function for initializing Timer 0 in 24 bit timer mode with 1 us resolution.  */
static void timer0_init(uint8_t delayms)
/* Function for initializing Timer 0 in 24 bit timer mode with 1 us resolution.  */
static void timer0_init(uint8_t delayms)
{
    NRF_TIMER0->TASKS_STOP = 1;
    NRF_TIMER0->SHORTS     = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled << TIMER_SHORTS_COMPARE0_CLEAR_Pos);
    NRF_TIMER0->MODE       = TIMER_MODE_MODE_Timer;
    NRF_TIMER0->BITMODE    = (TIMER_BITMODE_BITMODE_24Bit << TIMER_BITMODE_BITMODE_Pos);
    NRF_TIMER0->PRESCALER  = 4;
    NRF_TIMER0->INTENSET   = (TIMER_INTENSET_COMPARE0_Set << TIMER_INTENSET_COMPARE0_Pos);
    NRF_TIMER0->CC[0]       = (uint32_t)delayms * 1000;
    NRF_TIMER0->TASKS_START = 1;
}