lpc-field

Template project for programming NXP's LPC1768 MCUs
git clone git://git.mdnr.space/lpc-field
Log | Files | Refs | README | LICENSE

lpc17xx_mcpwm.c (21037B)


      1 /**********************************************************************
      2 * $Id$		lpc17xx_mcpwm.c				2010-05-21
      3 *//**
      4 * @file		lpc17xx_mcpwm.c
      5 * @brief	Contains all functions support for Motor Control PWM firmware
      6 * 			library on LPC17xx
      7 * @version	2.0
      8 * @date		21. May. 2010
      9 * @author	NXP MCU SW Application Team
     10 *
     11 * Copyright(C) 2010, NXP Semiconductor
     12 * All rights reserved.
     13 *
     14 ***********************************************************************
     15 * Software that is described herein is for illustrative purposes only
     16 * which provides customers with programming information regarding the
     17 * products. This software is supplied "AS IS" without any warranties.
     18 * NXP Semiconductors assumes no responsibility or liability for the
     19 * use of the software, conveys no license or title under any patent,
     20 * copyright, or mask work right to the product. NXP Semiconductors
     21 * reserves the right to make changes in the software without
     22 * notification. NXP Semiconductors also make no representation or
     23 * warranty that such application will be suitable for the specified
     24 * use without further testing or modification.
     25 * Permission to use, copy, modify, and distribute this software and its
     26 * documentation is hereby granted, under NXP Semiconductors'
     27 * relevant copyright in the software, without fee, provided that it
     28 * is used in conjunction with NXP Semiconductors microcontrollers.  This
     29 * copyright, permission, and disclaimer notice must appear in all copies of
     30 * this code.
     31 **********************************************************************/
     32 
     33 /* Peripheral group ----------------------------------------------------------- */
     34 /** @addtogroup MCPWM
     35  * @{
     36  */
     37 
     38 /* Includes ------------------------------------------------------------------- */
     39 #include "lpc17xx_mcpwm.h"
     40 #include "lpc17xx_clkpwr.h"
     41 
     42 /* If this source file built with example, the LPC17xx FW library configuration
     43  * file in each example directory ("lpc17xx_libcfg.h") must be included,
     44  * otherwise the default FW library configuration file must be included instead
     45  */
     46 #ifdef __BUILD_WITH_EXAMPLE__
     47 #include "lpc17xx_libcfg.h"
     48 #else
     49 #include "lpc17xx_libcfg_default.h"
     50 #endif /* __BUILD_WITH_EXAMPLE__ */
     51 
     52 
     53 #ifdef _MCPWM
     54 
     55 /* Public Functions ----------------------------------------------------------- */
     56 /** @addtogroup MCPWM_Public_Functions
     57  * @{
     58  */
     59 
     60 /*********************************************************************//**
     61  * @brief		Initializes the MCPWM peripheral
     62  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected,
     63  * 				Should be: LPC_MCPWM
     64  * @return		None
     65  **********************************************************************/
     66 void MCPWM_Init(LPC_MCPWM_TypeDef *MCPWMx)
     67 {
     68 
     69 	/* Turn On MCPWM PCLK */
     70 	CLKPWR_ConfigPPWR (CLKPWR_PCONP_PCMC, ENABLE);
     71 	/* As default, peripheral clock for MCPWM module
     72 	 * is set to FCCLK / 2 */
     73 	// CLKPWR_SetPCLKDiv(CLKPWR_PCLKSEL_MC, CLKPWR_PCLKSEL_CCLK_DIV_2);
     74 
     75 	MCPWMx->MCCAP_CLR = MCPWM_CAPCLR_CAP(0) | MCPWM_CAPCLR_CAP(1) | MCPWM_CAPCLR_CAP(2);
     76 	MCPWMx->MCINTFLAG_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \
     77 							| MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \
     78 							| MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2);
     79 	MCPWMx->MCINTEN_CLR = MCPWM_INT_ILIM(0) | MCPWM_INT_ILIM(1) | MCPWM_INT_ILIM(2) \
     80 							| MCPWM_INT_IMAT(0) | MCPWM_INT_IMAT(1) | MCPWM_INT_IMAT(2) \
     81 							| MCPWM_INT_ICAP(0) | MCPWM_INT_ICAP(1) | MCPWM_INT_ICAP(2);
     82 }
     83 
     84 
     85 /*********************************************************************//**
     86  * @brief		Configures each channel in MCPWM peripheral according to the
     87  * 				specified parameters in the MCPWM_CHANNEL_CFG_Type.
     88  * @param[in]	MCPWMx 			Motor Control PWM peripheral selected
     89  * 								should be: LPC_MCPWM
     90  * @param[in]	channelNum		Channel number, should be: 0..2.
     91  * @param[in]	channelSetup	Pointer to a MCPWM_CHANNEL_CFG_Type structure
     92 *                    			that contains the configuration information for the
     93 *                    			specified MCPWM channel.
     94  * @return		None
     95  **********************************************************************/
     96 void MCPWM_ConfigChannel(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channelNum,
     97 						MCPWM_CHANNEL_CFG_Type * channelSetup)
     98 {
     99 	if (channelNum <= 2) {
    100 		if (channelNum == 0) {
    101 			MCPWMx->MCTIM0 = channelSetup->channelTimercounterValue;
    102 			MCPWMx->MCPER0 = channelSetup->channelPeriodValue;
    103 			MCPWMx->MCPW0 = channelSetup->channelPulsewidthValue;
    104 		} else if (channelNum == 1) {
    105 			MCPWMx->MCTIM1 = channelSetup->channelTimercounterValue;
    106 			MCPWMx->MCPER1 = channelSetup->channelPeriodValue;
    107 			MCPWMx->MCPW1 = channelSetup->channelPulsewidthValue;
    108 		} else if (channelNum == 2) {
    109 			MCPWMx->MCTIM2 = channelSetup->channelTimercounterValue;
    110 			MCPWMx->MCPER2 = channelSetup->channelPeriodValue;
    111 			MCPWMx->MCPW2 = channelSetup->channelPulsewidthValue;
    112 		} else {
    113 			return;
    114 		}
    115 
    116 		if (channelSetup->channelType /* == MCPWM_CHANNEL_CENTER_MODE */){
    117 			MCPWMx->MCCON_SET = MCPWM_CON_CENTER(channelNum);
    118 		} else {
    119 			MCPWMx->MCCON_CLR = MCPWM_CON_CENTER(channelNum);
    120 		}
    121 
    122 		if (channelSetup->channelPolarity /* == MCPWM_CHANNEL_PASSIVE_HI */){
    123 			MCPWMx->MCCON_SET = MCPWM_CON_POLAR(channelNum);
    124 		} else {
    125 			MCPWMx->MCCON_CLR = MCPWM_CON_POLAR(channelNum);
    126 		}
    127 
    128 		if (channelSetup->channelDeadtimeEnable /* == ENABLE */){
    129 			MCPWMx->MCCON_SET = MCPWM_CON_DTE(channelNum);
    130 			MCPWMx->MCDEADTIME &= ~(MCPWM_DT(channelNum, 0x3FF));
    131 			MCPWMx->MCDEADTIME |= MCPWM_DT(channelNum, channelSetup->channelDeadtimeValue);
    132 		} else {
    133 			MCPWMx->MCCON_CLR = MCPWM_CON_DTE(channelNum);
    134 		}
    135 
    136 		if (channelSetup->channelUpdateEnable /* == ENABLE */){
    137 			MCPWMx->MCCON_CLR = MCPWM_CON_DISUP(channelNum);
    138 		} else {
    139 			MCPWMx->MCCON_SET = MCPWM_CON_DISUP(channelNum);
    140 		}
    141 	}
    142 }
    143 
    144 
    145 /*********************************************************************//**
    146  * @brief		Write to MCPWM shadow registers - Update the value for period
    147  * 				and pulse width in MCPWM peripheral.
    148  * @param[in]	MCPWMx 			Motor Control PWM peripheral selected
    149  * 								Should be: LPC_MCPWM
    150  * @param[in]	channelNum		Channel Number, should be: 0..2.
    151  * @param[in]	channelSetup	Pointer to a MCPWM_CHANNEL_CFG_Type structure
    152 *                    			that contains the configuration information for the
    153 *                    			specified MCPWM channel.
    154  * @return		None
    155  **********************************************************************/
    156 void MCPWM_WriteToShadow(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channelNum,
    157 								MCPWM_CHANNEL_CFG_Type *channelSetup)
    158 {
    159 	if (channelNum == 0){
    160 		MCPWMx->MCPER0 = channelSetup->channelPeriodValue;
    161 		MCPWMx->MCPW0 = channelSetup->channelPulsewidthValue;
    162 	} else if (channelNum == 1) {
    163 		MCPWMx->MCPER1 = channelSetup->channelPeriodValue;
    164 		MCPWMx->MCPW1 = channelSetup->channelPulsewidthValue;
    165 	} else if (channelNum == 2) {
    166 		MCPWMx->MCPER2 = channelSetup->channelPeriodValue;
    167 		MCPWMx->MCPW2 = channelSetup->channelPulsewidthValue;
    168 	}
    169 }
    170 
    171 
    172 
    173 /*********************************************************************//**
    174  * @brief		Configures capture function in MCPWM peripheral
    175  * @param[in]	MCPWMx 			Motor Control PWM peripheral selected
    176  * 								Should be: LPC_MCPWM
    177  * @param[in]	channelNum		MCI (Motor Control Input pin) number
    178  * 								Should be: 0..2
    179  * @param[in]	captureConfig	Pointer to a MCPWM_CAPTURE_CFG_Type structure
    180 *                    			that contains the configuration information for the
    181 *                    			specified MCPWM capture.
    182  * @return
    183  **********************************************************************/
    184 void MCPWM_ConfigCapture(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channelNum,
    185 						MCPWM_CAPTURE_CFG_Type *captureConfig)
    186 {
    187 	if (channelNum <= 2) {
    188 
    189 		if (captureConfig->captureFalling /* == ENABLE */) {
    190 			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
    191 		} else {
    192 			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_CAPMCI_FE(captureConfig->captureChannel, channelNum);
    193 		}
    194 
    195 		if (captureConfig->captureRising /* == ENABLE */) {
    196 			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
    197 		} else {
    198 			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_CAPMCI_RE(captureConfig->captureChannel, channelNum);
    199 		}
    200 
    201 		if (captureConfig->timerReset /* == ENABLE */){
    202 			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_RT(captureConfig->captureChannel);
    203 		} else {
    204 			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_RT(captureConfig->captureChannel);
    205 		}
    206 
    207 		if (captureConfig->hnfEnable /* == ENABLE */){
    208 			MCPWMx->MCCAPCON_SET = MCPWM_CAPCON_HNFCAP(channelNum);
    209 		} else {
    210 			MCPWMx->MCCAPCON_CLR = MCPWM_CAPCON_HNFCAP(channelNum);
    211 		}
    212 	}
    213 }
    214 
    215 
    216 /*********************************************************************//**
    217  * @brief		Clears current captured value in specified capture channel
    218  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    219  * 							Should be: LPC_MCPWM
    220  * @param[in]	captureChannel	Capture channel number, should be: 0..2
    221  * @return		None
    222  **********************************************************************/
    223 void MCPWM_ClearCapture(LPC_MCPWM_TypeDef *MCPWMx, uint32_t captureChannel)
    224 {
    225 	MCPWMx->MCCAP_CLR = MCPWM_CAPCLR_CAP(captureChannel);
    226 }
    227 
    228 /*********************************************************************//**
    229  * @brief		Get current captured value in specified capture channel
    230  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected,
    231  * 							Should be: LPC_MCPWM
    232  * @param[in]	captureChannel	Capture channel number, should be: 0..2
    233  * @return		None
    234  **********************************************************************/
    235 uint32_t MCPWM_GetCapture(LPC_MCPWM_TypeDef *MCPWMx, uint32_t captureChannel)
    236 {
    237 	if (captureChannel == 0){
    238 		return (MCPWMx->MCCR0);
    239 	} else if (captureChannel == 1) {
    240 		return (MCPWMx->MCCR1);
    241 	} else if (captureChannel == 2) {
    242 		return (MCPWMx->MCCR2);
    243 	}
    244 	return (0);
    245 }
    246 
    247 
    248 /*********************************************************************//**
    249  * @brief		Configures Count control in MCPWM peripheral
    250  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    251  * 							Should be: LPC_MCPWM
    252  * @param[in]	channelNum	Channel number, should be: 0..2
    253  * @param[in]	countMode	Count mode, should be:
    254  * 							- ENABLE: Enables count mode.
    255  * 							- DISABLE: Disable count mode, the channel is in timer mode.
    256  * @param[in]	countConfig	Pointer to a MCPWM_COUNT_CFG_Type structure
    257 *                    		that contains the configuration information for the
    258 *                    		specified MCPWM count control.
    259  * @return		None
    260  **********************************************************************/
    261 void MCPWM_CountConfig(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channelNum,
    262 					uint32_t countMode, MCPWM_COUNT_CFG_Type *countConfig)
    263 {
    264 	if (channelNum <= 2) {
    265 		if (countMode /* == ENABLE */){
    266 			MCPWMx->MCCNTCON_SET = MCPWM_CNTCON_CNTR(channelNum);
    267 			if (countConfig->countFalling /* == ENABLE */) {
    268 				MCPWMx->MCCNTCON_SET = MCPWM_CNTCON_TCMCI_FE(countConfig->counterChannel,channelNum);
    269 			} else {
    270 				MCPWMx->MCCNTCON_CLR = MCPWM_CNTCON_TCMCI_FE(countConfig->counterChannel,channelNum);
    271 			}
    272 			if (countConfig->countRising /* == ENABLE */) {
    273 				MCPWMx->MCCNTCON_SET = MCPWM_CNTCON_TCMCI_RE(countConfig->counterChannel,channelNum);
    274 			} else {
    275 				MCPWMx->MCCNTCON_CLR = MCPWM_CNTCON_TCMCI_RE(countConfig->counterChannel,channelNum);
    276 			}
    277 		} else {
    278 			MCPWMx->MCCNTCON_CLR = MCPWM_CNTCON_CNTR(channelNum);
    279 		}
    280 	}
    281 }
    282 
    283 
    284 /*********************************************************************//**
    285  * @brief		Start MCPWM activity for each MCPWM channel
    286  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    287  * 							Should be: LPC_MCPWM
    288  * @param[in]	channel0	State of this command on channel 0:
    289  * 							- ENABLE: 'Start' command will effect on channel 0
    290  * 							- DISABLE: 'Start' command will not effect on channel 0
    291  * @param[in]	channel1	State of this command on channel 1:
    292  * 							- ENABLE: 'Start' command will effect on channel 1
    293  * 							- DISABLE: 'Start' command will not effect on channel 1
    294  * @param[in]	channel2	State of this command on channel 2:
    295  * 							- ENABLE: 'Start' command will effect on channel 2
    296  * 							- DISABLE: 'Start' command will not effect on channel 2
    297  * @return		None
    298  **********************************************************************/
    299 void MCPWM_Start(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channel0,
    300 					uint32_t channel1, uint32_t channel2)
    301 {
    302 	uint32_t regVal = 0;
    303 	regVal = (channel0 ? MCPWM_CON_RUN(0) : 0) | (channel1 ? MCPWM_CON_RUN(1) : 0) \
    304 				| (channel2 ? MCPWM_CON_RUN(2) : 0);
    305 	MCPWMx->MCCON_SET = regVal;
    306 }
    307 
    308 
    309 /*********************************************************************//**
    310  * @brief		Stop MCPWM activity for each MCPWM channel
    311  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    312  * 							Should be: LPC_MCPWM
    313  * @param[in]	channel0	State of this command on channel 0:
    314  * 							- ENABLE: 'Stop' command will effect on channel 0
    315  * 							- DISABLE: 'Stop' command will not effect on channel 0
    316  * @param[in]	channel1	State of this command on channel 1:
    317  * 							- ENABLE: 'Stop' command will effect on channel 1
    318  * 							- DISABLE: 'Stop' command will not effect on channel 1
    319  * @param[in]	channel2	State of this command on channel 2:
    320  * 							- ENABLE: 'Stop' command will effect on channel 2
    321  * 							- DISABLE: 'Stop' command will not effect on channel 2
    322  * @return		None
    323  **********************************************************************/
    324 void MCPWM_Stop(LPC_MCPWM_TypeDef *MCPWMx, uint32_t channel0,
    325 		uint32_t channel1, uint32_t channel2)
    326 {
    327 	uint32_t regVal = 0;
    328 	regVal = (channel0 ? MCPWM_CON_RUN(0) : 0) | (channel1 ? MCPWM_CON_RUN(1) : 0) \
    329 				| (channel2 ? MCPWM_CON_RUN(2) : 0);
    330 	MCPWMx->MCCON_CLR = regVal;
    331 }
    332 
    333 
    334 /*********************************************************************//**
    335  * @brief		Enables/Disables 3-phase AC motor mode on MCPWM peripheral
    336  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    337  * 							Should be: LPC_MCPWM
    338  * @param[in]	acMode		State of this command, should be:
    339  * 							- ENABLE.
    340  * 							- DISABLE.
    341  * @return		None
    342  **********************************************************************/
    343 void MCPWM_ACMode(LPC_MCPWM_TypeDef *MCPWMx, uint32_t acMode)
    344 {
    345 	if (acMode){
    346 		MCPWMx->MCCON_SET = MCPWM_CON_ACMODE;
    347 	} else {
    348 		MCPWMx->MCCON_CLR = MCPWM_CON_ACMODE;
    349 	}
    350 }
    351 
    352 
    353 /*********************************************************************//**
    354  * @brief		Enables/Disables 3-phase DC motor mode on MCPWM peripheral
    355  * @param[in]	MCPWMx 			Motor Control PWM peripheral selected
    356  * 								Should be: LPC_MCPWM
    357  * @param[in]	dcMode			State of this command, should be:
    358  * 								- ENABLE.
    359  * 								- DISABLE.
    360  * @param[in]	outputInvered	Polarity of the MCOB outputs for all 3 channels,
    361  * 								should be:
    362  * 								- ENABLE: The MCOB outputs have opposite polarity
    363  * 									from the MCOA outputs.
    364  * 								- DISABLE: The MCOB outputs have the same basic
    365  * 									polarity as the MCOA outputs.
    366  * @param[in]	outputPattern	A value contains bits that enables/disables the specified
    367  * 								output pins route to the internal MCOA0 signal, should be:
    368 								- MCPWM_PATENT_A0: 	 MCOA0 tracks internal MCOA0
    369 								- MCPWM_PATENT_B0: 	 MCOB0 tracks internal MCOA0
    370 								- MCPWM_PATENT_A1: 	 MCOA1 tracks internal MCOA0
    371 								- MCPWM_PATENT_B1: 	 MCOB1 tracks internal MCOA0
    372 								- MCPWM_PATENT_A2: 	 MCOA2 tracks internal MCOA0
    373 								- MCPWM_PATENT_B2: 	 MCOB2 tracks internal MCOA0
    374  * @return		None
    375  *
    376  * Note: all these outputPatent values above can be ORed together for using as input parameter.
    377  **********************************************************************/
    378 void MCPWM_DCMode(LPC_MCPWM_TypeDef *MCPWMx, uint32_t dcMode,
    379 					uint32_t outputInvered, uint32_t outputPattern)
    380 {
    381 	if (dcMode){
    382 		MCPWMx->MCCON_SET = MCPWM_CON_DCMODE;
    383 	} else {
    384 		MCPWMx->MCCON_CLR = MCPWM_CON_DCMODE;
    385 	}
    386 
    387 	if (outputInvered) {
    388 		MCPWMx->MCCON_SET = MCPWM_CON_INVBDC;
    389 	} else {
    390 		MCPWMx->MCCON_CLR = MCPWM_CON_INVBDC;
    391 	}
    392 
    393 	MCPWMx->MCCCP = outputPattern;
    394 }
    395 
    396 
    397 /*********************************************************************//**
    398  * @brief		Configures the specified interrupt in MCPWM peripheral
    399  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    400  * 							Should be: LPC_MCPWM
    401  * @param[in]	ulIntType	Interrupt type, should be:
    402  * 							- MCPWM_INTFLAG_LIM0: Limit interrupt for channel (0)
    403  * 							- MCPWM_INTFLAG_MAT0: Match interrupt for channel (0)
    404  * 							- MCPWM_INTFLAG_CAP0: Capture interrupt for channel (0)
    405  * 							- MCPWM_INTFLAG_LIM1: Limit interrupt for channel (1)
    406  * 							- MCPWM_INTFLAG_MAT1: Match interrupt for channel (1)
    407  * 							- MCPWM_INTFLAG_CAP1: Capture interrupt for channel (1)
    408  * 							- MCPWM_INTFLAG_LIM2: Limit interrupt for channel (2)
    409  * 							- MCPWM_INTFLAG_MAT2: Match interrupt for channel (2)
    410  * 							- MCPWM_INTFLAG_CAP2: Capture interrupt for channel (2)
    411  * 							- MCPWM_INTFLAG_ABORT: Fast abort interrupt
    412  * @param[in]	NewState	New State of this command, should be:
    413  * 							- ENABLE.
    414  * 							- DISABLE.
    415  * @return		None
    416  *
    417  * Note: all these ulIntType values above can be ORed together for using as input parameter.
    418  **********************************************************************/
    419 void MCPWM_IntConfig(LPC_MCPWM_TypeDef *MCPWMx, uint32_t ulIntType, FunctionalState NewState)
    420 {
    421 	if (NewState) {
    422 		MCPWMx->MCINTEN_SET = ulIntType;
    423 	} else {
    424 		MCPWMx->MCINTEN_CLR = ulIntType;
    425 	}
    426 }
    427 
    428 
    429 /*********************************************************************//**
    430  * @brief		Sets/Forces the specified interrupt for MCPWM peripheral
    431  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected
    432  * 							Should be LPC_MCPWM
    433  * @param[in]	ulIntType	Interrupt type, should be:
    434  * 							- MCPWM_INTFLAG_LIM0: Limit interrupt for channel (0)
    435  * 							- MCPWM_INTFLAG_MAT0: Match interrupt for channel (0)
    436  * 							- MCPWM_INTFLAG_CAP0: Capture interrupt for channel (0)
    437  * 							- MCPWM_INTFLAG_LIM1: Limit interrupt for channel (1)
    438  * 							- MCPWM_INTFLAG_MAT1: Match interrupt for channel (1)
    439  * 							- MCPWM_INTFLAG_CAP1: Capture interrupt for channel (1)
    440  * 							- MCPWM_INTFLAG_LIM2: Limit interrupt for channel (2)
    441  * 							- MCPWM_INTFLAG_MAT2: Match interrupt for channel (2)
    442  * 							- MCPWM_INTFLAG_CAP2: Capture interrupt for channel (2)
    443  * 							- MCPWM_INTFLAG_ABORT: Fast abort interrupt
    444  * @return		None
    445  * Note: all these ulIntType values above can be ORed together for using as input parameter.
    446  **********************************************************************/
    447 void MCPWM_IntSet(LPC_MCPWM_TypeDef *MCPWMx, uint32_t ulIntType)
    448 {
    449 	MCPWMx->MCINTFLAG_SET = ulIntType;
    450 }
    451 
    452 
    453 /*********************************************************************//**
    454  * @brief		Clear the specified interrupt pending for MCPWM peripheral
    455  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected,
    456  * 							should be: LPC_MCPWM
    457  * @param[in]	ulIntType	Interrupt type, should be:
    458  * 							- MCPWM_INTFLAG_LIM0: Limit interrupt for channel (0)
    459  * 							- MCPWM_INTFLAG_MAT0: Match interrupt for channel (0)
    460  * 							- MCPWM_INTFLAG_CAP0: Capture interrupt for channel (0)
    461  * 							- MCPWM_INTFLAG_LIM1: Limit interrupt for channel (1)
    462  * 							- MCPWM_INTFLAG_MAT1: Match interrupt for channel (1)
    463  * 							- MCPWM_INTFLAG_CAP1: Capture interrupt for channel (1)
    464  * 							- MCPWM_INTFLAG_LIM2: Limit interrupt for channel (2)
    465  * 							- MCPWM_INTFLAG_MAT2: Match interrupt for channel (2)
    466  * 							- MCPWM_INTFLAG_CAP2: Capture interrupt for channel (2)
    467  * 							- MCPWM_INTFLAG_ABORT: Fast abort interrupt
    468  * @return		None
    469  * Note: all these ulIntType values above can be ORed together for using as input parameter.
    470  **********************************************************************/
    471 void MCPWM_IntClear(LPC_MCPWM_TypeDef *MCPWMx, uint32_t ulIntType)
    472 {
    473 	MCPWMx->MCINTFLAG_CLR = ulIntType;
    474 }
    475 
    476 
    477 /*********************************************************************//**
    478  * @brief		Check whether if the specified interrupt in MCPWM is set or not
    479  * @param[in]	MCPWMx 		Motor Control PWM peripheral selected,
    480  * 							should be: LPC_MCPWM
    481  * @param[in]	ulIntType	Interrupt type, should be:
    482  * 							- MCPWM_INTFLAG_LIM0: Limit interrupt for channel (0)
    483  * 							- MCPWM_INTFLAG_MAT0: Match interrupt for channel (0)
    484  * 							- MCPWM_INTFLAG_CAP0: Capture interrupt for channel (0)
    485  * 							- MCPWM_INTFLAG_LIM1: Limit interrupt for channel (1)
    486  * 							- MCPWM_INTFLAG_MAT1: Match interrupt for channel (1)
    487  * 							- MCPWM_INTFLAG_CAP1: Capture interrupt for channel (1)
    488  * 							- MCPWM_INTFLAG_LIM2: Limit interrupt for channel (2)
    489  * 							- MCPWM_INTFLAG_MAT2: Match interrupt for channel (2)
    490  * 							- MCPWM_INTFLAG_CAP2: Capture interrupt for channel (2)
    491  * 							- MCPWM_INTFLAG_ABORT: Fast abort interrupt
    492  * @return		None
    493  **********************************************************************/
    494 FlagStatus MCPWM_GetIntStatus(LPC_MCPWM_TypeDef *MCPWMx, uint32_t ulIntType)
    495 {
    496 	return ((MCPWMx->MCINTFLAG & ulIntType) ? SET : RESET);
    497 }
    498 
    499 /**
    500  * @}
    501  */
    502 
    503 #endif /* _MCPWM */
    504 
    505 /**
    506  * @}
    507  */
    508 
    509 /* --------------------------------- End Of File ------------------------------ */