00001
00016
00017
00018
00019
00020 #include "config.h"
00021 #include "comparator_drv.h"
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00038 #ifdef USE_COMP0
00039
00040 void init_comparator0(void)
00041 {
00042 # if (COMPARATOR0_IT == 1)
00043 Enable_comparator0_interrupt();
00044 # elif (COMPARATOR0_IT == 0)
00045 Disable_comparator0_interrupt();
00046 # else
00047 # error (COMPARATOR0_IT should be 0 or 1... See config.h file)
00048 # endif
00049
00050
00051 # if (COMPARATOR0_IT_EVENT == 3)
00052 Comparator0_it_on_output_rising_edge();
00053 # elif (COMPARATOR0_IT_EVENT == 2)
00054 Comparator0_it_on_output_falling_edge();
00055 # elif (COMPARATOR0_IT_EVENT == 0)
00056 Comparator0_it_on_output_toggle();
00057 # else
00058 # error (COMPARATOR0_IT_EVENT should be 0, 2 or 3... See config.h file)
00059 # endif
00060
00061 # if (COMPARATOR0_NEGATIVE_INPUT == 5)
00062 Set_comparator0_ni_dac();
00063 # elif (COMPARATOR0_NEGATIVE_INPUT == 4)
00064 Set_comparator0_ni_acmp();
00065 # elif (COMPARATOR0_NEGATIVE_INPUT == 3)
00066 Set_comparator0_ni_vref_1_60();
00067 # elif (COMPARATOR0_NEGATIVE_INPUT == 2)
00068 Set_comparator0_ni_vref_2_13();
00069 # elif (COMPARATOR0_NEGATIVE_INPUT == 1)
00070 Set_comparator0_ni_vref_3_20();
00071 # elif (COMPARATOR0_NEGATIVE_INPUT == 0)
00072 Set_comparator0_ni_vref_6_40();
00073 # else
00074 # error (COMPARATOR0_NEGATIVE_INPUT should be 0, 1, 2, 3, 4 or 5... See config.h file)
00075 # endif
00076 Enable_comparator0();
00077 }
00078 #endif // USE_COMP0
00079
00085 #ifdef USE_COMP1
00086
00087 void init_comparator1(void)
00088 {
00089 Enable_comparator1();
00090 # if (COMPARATOR1_IT == 1)
00091 Enable_comparator1_interrupt();
00092 # elif (COMPARATOR1_IT == 0)
00093 Disable_comparator1_interrupt();
00094 # else
00095 # error (COMPARATOR1_IT should be 0 or 1... See config.h file)
00096 # endif
00097
00098
00099 # if (COMPARATOR1_IT_EVENT == 3)
00100 Comparator1_it_on_output_rising_edge();
00101 # elif (COMPARATOR1_IT_EVENT == 2)
00102 Comparator1_it_on_output_falling_edge();
00103 # elif (COMPARATOR1_IT_EVENT == 0)
00104 Comparator1_it_on_output_toggle();
00105 # else
00106 # error (COMPARATOR1_IT_EVENT should be 0, 2 or 3... See config.h file)
00107 # endif
00108
00109 # if (COMPARATOR1_NEGATIVE_INPUT == 5)
00110 Set_comparator1_ni_dac();
00111 # elif (COMPARATOR1_NEGATIVE_INPUT == 4)
00112 Set_comparator1_ni_acmp();
00113 # elif (COMPARATOR1_NEGATIVE_INPUT == 3)
00114 Set_comparator1_ni_vref_1_60();
00115 # elif (COMPARATOR1_NEGATIVE_INPUT == 2)
00116 Set_comparator1_ni_vref_2_13();
00117 # elif (COMPARATOR1_NEGATIVE_INPUT == 1)
00118 Set_comparator1_ni_vref_3_20();
00119 # elif (COMPARATOR1_NEGATIVE_INPUT == 0)
00120 Set_comparator1_ni_vref_6_40();
00121 # else
00122 # error (COMPARATOR1_NEGATIVE_INPUT should be 0, 1, 2, 3, 4 or 5... See config.h file)
00123 # endif
00124 }
00125 #endif // USE_COMP1
00126
00132 #ifdef USE_COMP2
00133
00134 void init_comparator2(void)
00135 {
00136 Enable_comparator2();
00137 # if (COMPARATOR2_IT == 1)
00138 Enable_comparator2_interrupt();
00139 # elif (COMPARATOR2_IT == 0)
00140 Disable_comparator2_interrupt();
00141 # else
00142 # error (COMPARATOR2_IT should be 0 or 1... See config.h file)
00143 # endif
00144
00145
00146 # if (COMPARATOR2_IT_EVENT == 3)
00147 Comparator2_it_on_output_rising_edge();
00148 # elif (COMPARATOR2_IT_EVENT == 2)
00149 Comparator2_it_on_output_falling_edge();
00150 # elif (COMPARATOR2_IT_EVENT == 0)
00151 Comparator2_it_on_output_toggle();
00152 # else
00153 # error (COMPARATOR2_IT_EVENT should be 0, 2 or 3... See config.h file)
00154 # endif
00155
00156 # if (COMPARATOR2_NEGATIVE_INPUT == 5)
00157 Set_comparator2_ni_dac();
00158 # elif (COMPARATOR2_NEGATIVE_INPUT == 4)
00159 Set_comparator2_ni_acmp();
00160 # elif (COMPARATOR2_NEGATIVE_INPUT == 3)
00161 Set_comparator2_ni_vref_1_60();
00162 # elif (COMPARATOR2_NEGATIVE_INPUT == 2)
00163 Set_comparator2_ni_vref_2_13();
00164 # elif (COMPARATOR2_NEGATIVE_INPUT == 1)
00165 Set_comparator2_ni_vref_3_20();
00166 # elif (COMPARATOR2_NEGATIVE_INPUT == 0)
00167 Set_comparator2_ni_vref_6_40();
00168 # else
00169 # error (COMPARATOR2_NEGATIVE_INPUT should be 0, 1, 2, 3, 4 or 5... See config.h file)
00170 # endif
00171 }
00172 #endif // USE_COMP2