/* Initialize TIMER Interface. 1. Initializes the resources needed for the TIMER interface 2.registers event callback function.  */
timer_handle_t csi_timer_initialize(int32_t idx, timer_event_cb_t cb_event, void *arg)
/* Initialize TIMER Interface. 1. Initializes the resources needed for the TIMER interface 2.registers event callback function.  */
timer_handle_t csi_timer_initialize(int32_t idx, timer_event_cb_t cb_event, void *arg)
{
    if (idx < 0 || idx >= CONFIG_TIMER_NUM) {
        return NULL;
    }
    uint32_t base = 0u;
    uint32_t irq = 0u;
    int32_t real_idx = target_get_timer(idx, &base, &irq);
    if (real_idx != idx) {
        return NULL;
    }
    dw_timer_priv_t *timer_priv = &timer_instance[idx];
    timer_priv->base = base;
    timer_priv->irq  = irq;
    timer_priv->arg  = arg;
    dw_timer_reg_t *addr = (dw_timer_reg_t *)(timer_priv->base);
    timer_priv->timeout = DW_TIMER_INIT_DEFAULT_VALUE;
    timer_deactive_control(addr);
    timer_priv->cb_event = cb_event;
    drv_nvic_enable_irq(timer_priv->irq);
    return (timer_handle_t)timer_priv;
}