27 #ifndef LPC17XX_PWM_H_
28 #define LPC17XX_PWM_H_
51 #define PWM_IR_PWMMRn(n) ((uint32_t)((n<4)?(1<<n):(1<<(n+4))))
53 #define PWM_IR_PWMCAPn(n) ((uint32_t)(1<<(n+4)))
55 #define PWM_IR_BITMASK ((uint32_t)(0x0000073F))
61 #define PWM_TCR_BITMASK ((uint32_t)(0x0000000B))
62 #define PWM_TCR_COUNTER_ENABLE ((uint32_t)(1<<0))
63 #define PWM_TCR_COUNTER_RESET ((uint32_t)(1<<1))
64 #define PWM_TCR_PWM_ENABLE ((uint32_t)(1<<3))
70 #define PWM_CTCR_BITMASK ((uint32_t)(0x0000000F))
72 #define PWM_CTCR_MODE(n) ((uint32_t)(n&0x03))
74 #define PWM_CTCR_SELECT_INPUT(n) ((uint32_t)((n&0x03)<<2))
80 #define PWM_MCR_BITMASK ((uint32_t)(0x001FFFFF))
82 #define PWM_MCR_INT_ON_MATCH(n) ((uint32_t)(1<<(((n&0x7)<<1)+(n&0x07))))
84 #define PWM_MCR_RESET_ON_MATCH(n) ((uint32_t)(1<<(((n&0x7)<<1)+(n&0x07)+1)))
86 #define PWM_MCR_STOP_ON_MATCH(n) ((uint32_t)(1<<(((n&0x7)<<1)+(n&0x07)+2)))
92 #define PWM_CCR_BITMASK ((uint32_t)(0x0000003F))
94 #define PWM_CCR_CAP_RISING(n) ((uint32_t)(1<<(((n&0x2)<<1)+(n&0x1))))
96 #define PWM_CCR_CAP_FALLING(n) ((uint32_t)(1<<(((n&0x2)<<1)+(n&0x1)+1)))
98 #define PWM_CCR_INT_ON_CAP(n) ((uint32_t)(1<<(((n&0x2)<<1)+(n&0x1)+2)))
104 #define PWM_PCR_BITMASK (uint32_t)0x00007E7C
106 #define PWM_PCR_PWMSELn(n) ((uint32_t)(((n&0x7)<2) ? 0 : (1<<n)))
108 #define PWM_PCR_PWMENAn(n) ((uint32_t)(((n&0x7)<1) ? 0 : (1<<(n+8))))
114 #define PWM_LER_BITMASK ((uint32_t)(0x0000007F))
116 #define PWM_LER_EN_MATCHn_LATCH(n) ((uint32_t)((n<7) ? (1<<n) : 0))
120 #define PARAM_PWMx(n) (((uint32_t *)n)==((uint32_t *)LPC_PWM1))
123 #define PARAM_PWM1_MATCH_CHANNEL(n) ((n>=0) && (n<=6))
126 #define PARAM_PWM1_CHANNEL(n) ((n>=1) && (n<=6))
129 #define PARAM_PWM1_EDGE_MODE_CHANNEL(n) ((n>=2) && (n<=6))
132 #define PARAM_PWM1_CAPTURE_CHANNEL(n) ((n==0) || (n==1))
135 #define PARAM_PWM_INTSTAT(n) ((n==PWM_INTSTAT_MR0) || (n==PWM_INTSTAT_MR1) || (n==PWM_INTSTAT_MR2) \
136 || (n==PWM_INTSTAT_MR3) || (n==PWM_INTSTAT_MR4) || (n==PWM_INTSTAT_MR5) \
137 || (n==PWM_INTSTAT_MR6) || (n==PWM_INTSTAT_CAP0) || (n==PWM_INTSTAT_CAP1))
221 #define PARAM_PWM_TC_MODE(n) ((n==PWM_MODE_TIMER) || (n==PWM_MODE_COUNTER))
231 #define PARAM_PWM_TIMER_PRESCALE(n) ((n==PWM_TIMER_PRESCALE_TICKVAL) || (n==PWM_TIMER_PRESCALE_USVAL))
240 #define PARAM_PWM_COUNTER_INPUTSEL(n) ((n==PWM_COUNTER_PCAP1_0) || (n==PWM_COUNTER_PCAP1_1))
249 #define PARAM_PWM_COUNTER_EDGE(n) ((n==PWM_COUNTER_RISING) || (n==PWM_COUNTER_FALLING) \
250 || (n==PWM_COUNTER_ANY))
260 #define PARAM_PWM_CHANNEL_EDGE(n) ((n==PWM_CHANNEL_SINGLE_EDGE) || (n==PWM_CHANNEL_DUAL_EDGE))
270 #define PARAM_PWM_MATCH_UPDATE(n) ((n==PWM_MATCH_UPDATE_NOW) || (n==PWM_MATCH_UPDATE_NEXT_RST))
312 uint32_t MatchValue, uint8_t UpdateType);