/* param base Quad Timer peripheral base address param channel Quad Timer channel number param capturePin Pin through which we receive the input signal to trigger the capture param inputPolarity true: invert polarity of the input signal, false: no inversion param reloadOnCapture true: reload the counter when an input capture occurs, false: no reload param captureMode Specifies which edge of the input signal triggers a capture  */
void QTMR_SetupInputCapture(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_input_source_t capturePin, bool inputPolarity, bool reloadOnCapture, qtmr_input_capture_edge_t captureMode)
/* param base Quad Timer peripheral base address param channel Quad Timer channel number param capturePin Pin through which we receive the input signal to trigger the capture param inputPolarity true: invert polarity of the input signal, false: no inversion param reloadOnCapture true: reload the counter when an input capture occurs, false: no reload param captureMode Specifies which edge of the input signal triggers a capture  */
void QTMR_SetupInputCapture(TMR_Type *base, qtmr_channel_selection_t channel, qtmr_input_source_t capturePin, bool inputPolarity, bool reloadOnCapture, qtmr_input_capture_edge_t captureMode)
{
    uint16_t reg;
    reg = base->CHANNEL[channel].CTRL & (uint16_t)(~TMR_CTRL_SCS_MASK);
    reg |= TMR_CTRL_SCS(capturePin);
    base->CHANNEL[channel].CTRL = reg;
    reg = base->CHANNEL[channel].SCTRL &
          (uint16_t)(~(TMR_SCTRL_IPS_MASK | TMR_SCTRL_CAPTURE_MODE_MASK | TMR_SCTRL_OEN_MASK));
    reg |= (TMR_SCTRL_IPS(inputPolarity) | TMR_SCTRL_CAPTURE_MODE(captureMode));
    base->CHANNEL[channel].SCTRL = reg;
    if (reloadOnCapture)
    {
        base->CHANNEL[channel].CSCTRL |= TMR_CSCTRL_ROC_MASK;
    }
    else
    {
        base->CHANNEL[channel].CSCTRL &= (uint16_t)(~TMR_CSCTRL_ROC_MASK);
    }
}