M480 BSP  V3.05.001
The Board Support Package for M480 Series
ecap.c
Go to the documentation of this file.
1 /**************************************************************************/
9 #include "NuMicro.h"
10 
11 
33 void ECAP_Open(ECAP_T* ecap, uint32_t u32FuncMask)
34 {
35  /* Clear Input capture mode*/
36  ecap->CTL0 = ecap->CTL0 & ~(ECAP_CTL0_CMPEN_Msk);
37 
38  /* Enable Input Capture and set mode */
39  ecap->CTL0 |= ECAP_CTL0_CAPEN_Msk | (u32FuncMask);
40 }
41 
42 
43 
50 void ECAP_Close(ECAP_T* ecap)
51 {
52  /* Disable Input Capture*/
53  ecap->CTL0 &= ~ECAP_CTL0_CAPEN_Msk;
54 }
55 
68 void ECAP_EnableINT(ECAP_T* ecap, uint32_t u32Mask)
69 {
70  /* Enable input channel interrupt */
71  ecap->CTL0 |= (u32Mask);
72 
73  /* Enable NVIC ECAP IRQ */
74  if(ecap == (ECAP_T*)ECAP0)
75  {
76  NVIC_EnableIRQ((IRQn_Type)ECAP0_IRQn);
77  }
78  else
79  {
80  NVIC_EnableIRQ((IRQn_Type)ECAP1_IRQn);
81  }
82 }
83 
96 void ECAP_DisableINT(ECAP_T* ecap, uint32_t u32Mask)
97 {
98  /* Disable input channel interrupt */
99  ecap->CTL0 &= ~(u32Mask);
100 
101  /* Disable NVIC ECAP IRQ */
102  if(ecap == (ECAP_T*)ECAP0)
103  {
104  NVIC_DisableIRQ((IRQn_Type)ECAP0_IRQn);
105  }
106  else
107  {
108  NVIC_DisableIRQ((IRQn_Type)ECAP1_IRQn);
109  }
110 }
111  /* end of group ECAP_EXPORTED_FUNCTIONS */
113  /* end of group ECAP_Driver */
115  /* end of group Standard_Driver */
117 
118 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
enum IRQn IRQn_Type
__IO uint32_t CTL0
Definition: ecap_reg.h:521
void ECAP_Open(ECAP_T *ecap, uint32_t u32FuncMask)
Enable ECAP function.
Definition: ecap.c:33
NuMicro peripheral access layer header file.
void ECAP_EnableINT(ECAP_T *ecap, uint32_t u32Mask)
This macro is used to enable input channel interrupt.
Definition: ecap.c:68
#define ECAP0
Definition: M480.h:419
#define ECAP_CTL0_CMPEN_Msk
Definition: ecap_reg.h:593
void ECAP_Close(ECAP_T *ecap)
Disable ECAP function.
Definition: ecap.c:50
#define ECAP_CTL0_CAPEN_Msk
Definition: ecap_reg.h:596
void ECAP_DisableINT(ECAP_T *ecap, uint32_t u32Mask)
This macro is used to disable input channel interrupt.
Definition: ecap.c:96