Exemplo n.º 1
0
/*********************************************************************//**
 * @brief		Configures capture function in MCPWM peripheral
 * @param[in]	MCPWMx 			Motor Control PWM peripheral selected
 * 								Should be: LPC_MCPWM
 * @param[in]	channelNum		MCI (Motor Control Input pin) number
 * 								Should be: 0..2
 * @param[in]	captureConfig	Pointer to a MCPWM_CAPTURE_CFG_Type structure
*                    			that contains the configuration information for the
*                    			specified MCPWM capture.
 * @return
 **********************************************************************/
void MCPWM_ConfigCapture(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channelNum,
						MCPWM_CAPTURE_CFG_Type *captureConfig)
{
	if ((channelNum >= 0) && (channelNum <= 2)) {

		if (captureConfig->captureFalling /* == ENABLE */) {
			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
		} else {
			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
		}

		if (captureConfig->captureRising /* == ENABLE */) {
			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
		} else {
			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
		}

		if (captureConfig->timerReset /* == ENABLE */){
			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_RT(captureConfig->captureChannel);
		} else {
			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_RT(captureConfig->captureChannel);
		}

		if (captureConfig->hnfEnable /* == ENABLE */){
			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_HNFCAP(channelNum);
		} else {
			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_HNFCAP(channelNum);
		}
	}
}
Exemplo n.º 2
0
/*********************************************************************//**
 * @brief		Configures capture function in MCPWM peripheral
 * @param[in]	MCPWMx 	Motor Control PWM peripheral selected, should be: LPC_MCPWM
 * @param[in]	channelNum	MCI (Motor Control Input pin) number, should be: 0..2
 * @param[in]	captureConfig	Pointer to a MCPWM_CAPTURE_CFG_Type structure
 * 				that contains the configuration information for the
 * 				specified MCPWM capture.
 * @return
 **********************************************************************/
void MCPWM_ConfigCapture(LPC_MCPWM_Type *MCPWMx, uint32_t channelNum,
                         MCPWM_CAPTURE_CFG_Type *captureConfig)
{
    if ((channelNum <= MCPWM_CHANNEL_2)) {

        if (captureConfig->captureFalling == ENABLE) {
            MCPWMx->CAPCON_SET = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
        } else {
            MCPWMx->CAPCON_CLR = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
        }

        if (captureConfig->captureRising == ENABLE) {
            MCPWMx->CAPCON_SET = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
        } else {
            MCPWMx->CAPCON_CLR = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
        }

        if (captureConfig->timerReset == ENABLE) {
            MCPWMx->CAPCON_SET = MCPWM_CAPCON_RT(captureConfig->captureChannel);
        } else {
            MCPWMx->CAPCON_CLR = MCPWM_CAPCON_RT(captureConfig->captureChannel);
        }

        if (captureConfig->hnfEnable == ENABLE) {
            MCPWMx->CAPCON_SET = MCPWM_CAPCON_HNFCAP(channelNum);
        } else {
            MCPWMx->CAPCON_CLR = MCPWM_CAPCON_HNFCAP(channelNum);
        }
    }
}