/* Returns the timer counter. NOTE: if the timer is a 16-bit timer, only the lower 16 bits are valid. If the timer is a 64-bit timer, only the low 32-bits are returned. */
uint32_t hal_timer_read(int timer_num)
/* Returns the timer counter. NOTE: if the timer is a 16-bit timer, only the lower 16 bits are valid. If the timer is a 64-bit timer, only the low 32-bits are returned. */
uint32_t hal_timer_read(int timer_num)
{
    int rc;
    uint32_t tcntr;
    struct nrf52_hal_timer *bsptimer;
    NRF52_HAL_TIMER_RESOLVE(timer_num, bsptimer);
    if (bsptimer->tmr_rtc) {
        tcntr = hal_timer_read_bsptimer(bsptimer);
    } else {
        tcntr = nrf_read_timer_cntr(bsptimer->tmr_reg);
    }
    return tcntr;
    err:
    assert(0);
    rc = 0;
    return rc;
}