My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lpc17xx_mcpwm.c 21KB

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