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