/* This function is ISR for inputcapture interrupt. level: RT_TRUE denotes high level pulse, and RT_FALSE denotes low level pulse.  */
void rt_hw_inputcapture_isr(struct rt_inputcapture_device *inputcapture, rt_bool_t level)
/* This function is ISR for inputcapture interrupt. level: RT_TRUE denotes high level pulse, and RT_FALSE denotes low level pulse.  */
void rt_hw_inputcapture_isr(struct rt_inputcapture_device *inputcapture, rt_bool_t level)
{
    struct rt_inputcapture_data data;
    rt_size_t receive_size;
    if (inputcapture->ops->get_pulsewidth(inputcapture, &data.pulsewidth_us) != RT_EOK)
    {
        return;
    }
    data.is_high = level;
    if (rt_ringbuffer_put(inputcapture->ringbuff, (rt_uint8_t *)&data, sizeof(struct rt_inputcapture_data)) == 0)
    {
        LOG_W("inputcapture ringbuffer doesn't have enough space.");
    }
    receive_size =  rt_ringbuffer_data_len(inputcapture->ringbuff) / sizeof(struct rt_inputcapture_data);
    if (receive_size >= inputcapture->watermark)
    {
        if (inputcapture->parent.rx_indicate != RT_NULL)
            inputcapture->parent.rx_indicate(&inputcapture->parent, receive_size);
    }
}