54#define PCA_CPS_MASK 0x0E
56#define PCA_PWM_EBS0_BIT 6
58#define PCA_PWM_EBS_MASK 0xC0
61#define PCA_CCP_S0_BIT 4
63#define PCA_CCP_S0_MSK 0x10
65#define PCA_CCP_S1_MSK 0x20
67#define PCA_CCP_SW_MASK (uint8_t)(PCA_CCP_S0_MSK | PCA_CCP_S1_MSK)
154#define pca_set_pin_group(group) \
156 bit_clr(P_SW1, PCA_CCP_SW_MASK); \
157 bit_set(P_SW1, (uint8_t)((group) << PCA_CCP_S0_BIT)); \
167#define pca_get_pin_group() ((pca_pin_group_t)(bit_shift_right(get_reg(P_SW1, (PCA_CCP_S0_MSK | PCA_CCP_S1_MSK)), PCA_CCP_S0_BIT)))
185#define pca_set_clock_source(src) \
187 bit_clr(CMOD, PCA_CPS_MASK); \
188 bit_set(CMOD, (uint8_t)((src) << PCA_CPS0_BIT)); \
198#define pca_get_clock_source() ((pca_clock_source_t)(bit_shift_right(get_reg(CMOD, PCA_CPS_MASK), PCA_CPS0_BIT)))
208#define pca_set_counter(value) \
210 CH = (uint8_t)bit_shift_right((uint16_t)(value), 8); \
211 CL = (uint8_t)(value); \
221#define pca_get_counter() ((uint16_t)(bit_shift_left((uint16_t)CH, 8) | (uint16_t)CL))
230#define pca_start() (CR = 1)
238#define pca_stop() (CR = 0)
247#define is_pca_running() (CR)
256#define pca_counter_run_in_idle() (bit_clr(CMOD,SBIT7))
264#define pca_counter_gate_off_in_idle() (bit_set(CMOD, SBIT7))
273#define is_pca_counter_gated_off_in_idle() (test_if_bit_set(CMOD, SBIT7))
288#define pca_clear_overflow_flag() (CF = 0)
297#define is_pca_overflow() (CF)
307#define pca_enable_overflow_interrupt() (bit_set(CMOD, SBIT0))
315#define pca_disable_overflow_interrupt() (bit_clr(CMOD, SBIT0))
324#define is_pca_overflow_interrupt_enabled() (test_if_bit_set(CMOD, SBIT0))
342#define pca_clear_module_flag(module) (CCF ## module = 0)
354#define is_pca_module_flag_set(module) (CCF ## module)
366#define pca_module_enable_interrupt(module) (bit_set(CCAPM ## module, SBIT0))
376#define pca_module_disable_interrupt(module) (bit_clr(CCAPM ## module, SBIT0))
387#define is_pca_module_interrupt_enabled(module) (test_if_bit_set(CCAPM ## module, SBIT0))
405#define pca_module_enable_comparator(module) (bit_set(CCAPM ## module, SBIT6))
415#define pca_module_disable_comparator(module) (bit_clr(CCAPM ## module, SBIT6))
426#define pca_module_enable_capture_positive(module) (bit_set(CCAPM ## module, SBIT5))
436#define pca_module_disable_capture_positive(module) (bit_clr(CCAPM ## module, SBIT5))
447#define pca_module_enable_capture_negative(module) (bit_set(CCAPM ## module, SBIT4))
457#define pca_module_disable_capture_negative(module) (bit_clr(CCAPM ## module, SBIT4))
468#define pca_module_enable_match(module) (bit_set(CCAPM ## module, SBIT3))
478#define pca_module_disable_match(module) (bit_clr(CCAPM ## module, SBIT3))
489#define pca_module_enable_toggle(module) (bit_set(CCAPM ## module, SBIT2))
499#define pca_module_disable_toggle(module) (bit_clr(CCAPM ## module, SBIT2))
511#define pca_module_set_compare(module, value) \
513 CCAP ## module ## H = (uint8_t)bit_shift_right((uint16_t)(value), 8); \
514 CCAP ## module ## L = (uint8_t)(value); \
535#define pca_module_get_capture(module) ((uint16_t)(bit_shift_left((uint16_t)CCAP ## module ## H, 8) | (uint16_t)CCAP ## module ## L))
561#define pca_module_pwm_init(module, resolution) \
563 bit_clr(PCA_PWM ## module, PCA_PWM_EBS_MASK); \
564 bit_set(PCA_PWM ## module, (uint8_t)((resolution) << PCA_PWM_EBS0_BIT)); \
565 bit_set(CCAPM ## module, SBIT1); \
576#define pca_module_pwm_disable(module) (bit_clr(CCAPM ## module, SBIT1))
587#define is_pca_module_pwm_enabled(module) (test_if_bit_set(CCAPM ## module, SBIT1))
603#define pca_module_pwm_set_duty(module, duty) \
605 CCAP ## module ## H = (uint8_t)(duty); \
606 CCAP ## module ## L = (uint8_t)(duty); \
620#define pca_module_pwm_set_duty_on_overflow(module, duty) (CCAP ## module ## H = (uint8_t)(duty))
pca_pwm_resolution_t
PCA module PWM output resolution.
Definition pca.h:128
pca_clock_source_t
PCA counter clock source.
Definition pca.h:96
pca_pin_group_t
PCA pin group.
Definition pca.h:78
@ PCA_PWM_7BIT
Definition pca.h:132
@ PCA_PWM_6BIT
Definition pca.h:134
@ PCA_PWM_8BIT
Definition pca.h:130
@ PCA_CLOCK_SYS_6
Definition pca.h:110
@ PCA_CLOCK_SYS
Definition pca.h:106
@ PCA_CLOCK_TIMER0
Definition pca.h:102
@ PCA_CLOCK_SYS_12
Definition pca.h:98
@ PCA_CLOCK_ECI
Definition pca.h:104
@ PCA_CLOCK_SYS_4
Definition pca.h:108
@ PCA_CLOCK_SYS_8
Definition pca.h:112
@ PCA_CLOCK_SYS_2
Definition pca.h:100
@ PCA_PIN_GROUP_1
Definition pca.h:80
@ PCA_PIN_GROUP_2
Definition pca.h:82
@ PCA_PIN_GROUP_3
Definition pca.h:84