📄 comparator_drv.h
字号:
//! Enable or Disable input capture of the Timer/Counter 1 on analog comparator
//! event
//! @{
#define Enable_comparator1_interrupt_capture() (AC1CON |= (1<<AC1ICE) )
#define Disable_comparator1_interrupt_capture() (AC1CON &= ~(1<<AC1ICE) )
//! @}
//! @defgroup Comparator1_negative_input_selection Comparator 1 Negative Input Selection
//! Select the Negative Input signal of the Comparator 1
//! @{
//! Set the negative input comparator 1 as Vref/6.40V
#define Set_comparator1_ni_vref_6_40() \
(AC1CON &= ~( (1<<AC1M2) | (1<<AC1M1) | (1<<AC1M0) ) )
//! Set Vref/3.20V as the negative input comparator 1
#define Set_comparator1_ni_vref_3_20() \
(AC1CON &= ~( (1<<AC1M2) | (1<<AC1M1) | (0<<AC1M0) ), \
AC1CON |= ( (0<<AC1M2) | (0<<AC1M1) | (1<<AC1M0) ) )
//! Set Vref/2.13V as the negative input comparator 1
#define Set_comparator1_ni_vref_2_13() \
(AC1CON &= ~( (1<<AC1M2) | (0<<AC1M1) | (1<<AC1M0) ), \
AC1CON |= ( (0<<AC1M2) | (1<<AC1M1) | (0<<AC1M0) ) )
//! Set Vref/1.60V as the negative input comparator 1
#define Set_comparator1_ni_vref_1_60() \
(AC1CON &= ~( (1<<AC1M2) | (0<<AC1M1) | (0<<AC1M0) ), \
AC1CON |= ( (0<<AC1M2) | (1<<AC1M1) | (1<<AC1M0) ) )
//! Set the ACMPM pin as the negative input comparator 1
#define Set_comparator1_ni_acmp() \
(AC1CON &= ~( (0<<AC1M2) | (1<<AC1M1) | (1<<AC1M0) ), \
AC1CON |= ( (1<<AC1M2) | (0<<AC1M1) | (0<<AC1M0) ) )
//! Set the DAC output as the negative input comparator 1
#define Set_comparator1_ni_dac() \
(AC1CON &= ~( (0<<AC1M2) | (1<<AC1M1) | (0<<AC1M0) ), \
AC1CON |= ( (1<<AC1M2) | (0<<AC1M1) | (1<<AC1M0) ) )
//! @}
//! @defgroup Turn_off_comparator1 Turn off the Comparator 1
//! Turn off the Comparator 1
//! @{
#define Disable_comparator1() (AC1CON &= ~(1<<AC1EN) )
//! @}
//! @}
//! @defgroup Comparator2_macros Comparator 2 Macros
//! Low level macros that permit the use of the Comparator 2 of the product.
//! @{
//! *** CONFIGURE THE COMPARATOR 2 ***
//! ****** AC2CON
//! 7 AC2EN : 1 Enable the comparator
//! 6 AC2IE : 1 Analog Comparator Interrupt Enable
//! 5:4 AC2IS1:0 : Analog comparator Interrupt selection
//! : 00 interrupt on output toggle
//! : 01 reserved
//! : 10 interrupt on output falling edge
//! : 11 interrupt on output rising edge
//! 3 Reserved : Not used
//! 2:0 AC2M2:0 : Comparator 1 Multiplexer register
//! : 000 Vref/6.40V
//! : 001 Vref/3.20V
//! : 010 Vref/2.13V
//! : 011 Vref/1.60V
//! : 100 Analog Comparator Negative Input pin (ACMPM pin)
//! : 101 DAC result
//! : 110 reserved
//! : 111 reserved
//! ****** END AC2CON
//! @defgroup Turn_on_comparator2 Turn on the Comparator 2
//! Turn on the Comparator 2
//! @{
#define Enable_comparator2() (AC2CON |= (1<<AC2EN) )
//! @}
//! @defgroup Comparator2_interrupt_enable Comparator 2 Interrupt Enable
//! Enable or Disable Comparator 2 Interrupt
//! @{
#define Enable_comparator2_interrupt() (AC2CON |= (1<<AC2IE) )
#define Disable_comparator2_interrupt() (AC2CON &= ~(1<<AC2IE) )
//! @}
//! @defgroup Comparator2_gain_configuration Comparator 2 Gain Configuration
//! Configure the value of the gain of the Comparator 2
//! @{
//! Comparator 2 interrupt on output toggle
#define Comparator2_it_on_output_toggle() \
(AC2CON &= ~( (1<<AC2IS1) | (1<<AC2IS0) ) )
//! Comparator 2 interrupt on_output falling edge
#define Comparator2_it_on_output_falling_edge() \
(AC2CON |= (1<<AC2IS1), \
AC2CON &= ~(1<<AC2IS0) )
//! Comparator 2 interrupt on_output rising edge
#define Comparator2_it_on_output_rising_edge() \
(AC2CON |= ((1<<AC2IS1) | (1<<AC2IS0)) )
//! @}
//! @defgroup Comparator2_negative_input_selection Comparator 2 Negative Input Selection
//! Select the Negative Input signal of the Comparator 2
//! @{
//! Set the negative input comparator 2 as Vref/6.40V
#define Set_comparator2_ni_vref_6_40() \
(AC2CON &= ~( (1<<AC2M2) | (1<<AC2M1) | (1<<AC2M0) ) )
//! Set Vref/3.20V as the negative input comparator 2
#define Set_comparator2_ni_vref_3_20() \
(AC2CON &= ~( (1<<AC2M2) | (1<<AC2M1) | (0<<AC2M0) ), \
AC2CON |= ( (0<<AC2M2) | (0<<AC2M1) | (1<<AC2M0) ) )
//! Set Vref/2.13V as the negative input comparator 2
#define Set_comparator2_ni_vref_2_13() \
(AC2CON &= ~( (1<<AC2M2) | (0<<AC2M1) | (1<<AC2M0) ), \
AC2CON |= ( (0<<AC2M2) | (1<<AC2M1) | (0<<AC2M0) ) )
//! Set Vref/1.60V as the negative input comparator 2
#define Set_comparator2_ni_vref_1_60() \
(AC2CON &= ~( (1<<AC2M2) | (0<<AC2M1) | (0<<AC2M0) ), \
AC2CON |= ( (0<<AC2M2) | (1<<AC2M1) | (1<<AC2M0) ) )
//! Set the ACMPM pin as the negative input comparator 2
#define Set_comparator2_ni_acmp() \
(AC2CON &= ~( (0<<AC2M2) | (1<<AC2M1) | (1<<AC2M0) ), \
AC2CON |= ( (1<<AC2M2) | (0<<AC2M1) | (0<<AC2M0) ) )
//! Set the DAC output as the negative input comparator 2
#define Set_comparator2_ni_dac() \
(AC2CON &= ~( (0<<AC2M2) | (1<<AC2M1) | (0<<AC2M0) ), \
AC2CON |= ( (1<<AC2M2) | (0<<AC2M1) | (1<<AC2M0) ) )
//! @}
//! @defgroup Turn_off_comparator2 Turn off the Comparator 2
//! Turn off the Comparator 2
//! @{
#define Disable_comparator2() (AC2CON &= ~(1<<AC2EN) )
//! @}
//! @}
//! @}
//_____ D E F I N I T I O N S ______________________________________________
//_____ F U N C T I O N S __________________________________________________
//! @defgroup Comparators_low_level_functions Comparators Low Level Functions
//! Comparators Low Level Functions
//! @{
//! Configures the Comparators accordingly to the Comparators Define Configuration
//! values,
//! Take care that you have to select the Analog comparator inputs as
//! analog inputs thanks to the DIDR0 and DIDR1 registers.
//!
//! @defgroup Comparator0_low_level_functions Comparator 0 Low Level Functions
//! Comparator 0 Low Level Functions
//! @{
void init_comparator0(void);
//! @}
//! @defgroup Comparator1_low_level_functions Comparator 1 Low Level Functions
//! Comparator 1 Low Level Functions
//! @{
void init_comparator1(void);
//! @}
//! @defgroup Comparator2_low_level_functions Comparator 2 Low Level Functions
//! Comparator 0 Low Level Functions
//! @{
void init_comparator2(void);
//! @}
//! @}
//! @}
#endif // COMPARATOR_DRV_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -