Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00058
00059 #if !defined(__MTOUCH_HARDWARE_16F151X_H)
00060 #define __MTOUCH_HARDWARE_16F151X_H
00061
00062 #if !defined(_16F1516) && !defined(_16LF1516)
00063 #if !defined(_16F1517) && !defined(_16LF1517)
00064 #if !defined(_16F1518) && !defined(_16LF1518)
00065 #if !defined(_16F1519) && !defined(_16LF1519)
00066 #error The current mTouch hardware include file does not support this PIC microcontroller.
00067 #endif
00068 #endif
00069 #endif
00070 #endif
00071
00072 #if defined(_16F1516) || defined(_16LF1516)
00073 #if MTOUCH_NUMBER_SENSORS > 17
00074 #error The PIC16F/LF1516 is not able to support more than 17 sensors due to pinout limitations.
00075 #endif
00076 #endif
00077 #if defined(_16F1517) || defined(_16LF1517)
00078 #if MTOUCH_NUMBER_SENSORS > 22
00079 #error The PIC16F/LF1517 is not able to support more than 22 sensors due to memory limitations.
00080 #endif
00081 #endif
00082 #if defined(_16F1518) || defined(_16LF1518)
00083 #if MTOUCH_NUMBER_SENSORS > 17
00084 #error The PIC16F/LF1518 is not able to support more than 17 sensors due to pinout limitations.
00085 #endif
00086 #endif
00087 #if defined(_16F1519) || defined(_16LF1519)
00088 #if MTOUCH_NUMBER_SENSORS > 22
00089 #error The PIC16F/LF1519 is not able to support more than 22 sensors due to memory limitations.
00090 #endif
00091 #endif
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 #define PIC_UART_AVAILABLE
00102 #define PIC_UART_BAUD_BITS 16
00103
00104 #define PIC_TIMER0_AVAILABLE
00105 #define PIC_TIMER1_AVAILABLE
00106 #define PIC_TIMER2_AVAILABLE
00107
00108
00109
00110
00111 #define PIC_ADC_BITS 10
00112
00113 #if defined(_16F1516) || defined(_16F1518)
00114 #define PIC_ADC_UNIMP_AVAILABLE
00115 #endif
00116
00117 #define PIC_ADC_ADCS ADCON1bits.ADCS
00118 #define PIC_ADC_ADFM ADCON1bits.ADFM
00119 #define PIC_ADC_ADON ADCON0bits.ADON
00120
00121 #define PIC_ADC_ADCS_FOSC2 0b000
00122 #define PIC_ADC_ADCS_FOSC4 0b100
00123 #define PIC_ADC_ADCS_FOSC8 0b001
00124 #define PIC_ADC_ADCS_FOSC16 0b101
00125 #define PIC_ADC_ADCS_FOSC32 0b010
00126 #define PIC_ADC_ADCS_FOSC64 0b110
00127 #define PIC_ADC_ADCS_FRC 0b111
00128
00129 #define PIC_ADC_ADFM_RIGHT 1
00130 #define PIC_ADC_ADFM_LEFT 0
00131
00132 #if _XTAL_FREQ == 16000000
00133 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC16
00134 #define PIC_ADC_TAD 1
00135 #elif _XTAL_FREQ == 8000000
00136 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC8
00137 #define PIC_ADC_TAD 1
00138 #elif _XTAL_FREQ == 4000000
00139 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC4
00140 #define PIC_ADC_TAD 1
00141 #elif _XTAL_FREQ == 2000000
00142 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC2
00143 #define PIC_ADC_TAD 1
00144 #elif _XTAL_FREQ == 1000000
00145 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC2
00146 #define PIC_ADC_TAD 2
00147 #else
00148 #error No predefined ADC clock values for the chosen _XTAL_FREQ.
00149 #endif
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 #define PIC_SWDTEN_AVAILABLE
00160 #define PIC_SWDTEN_OFF() WDTCONbits.SWDTEN = 0
00161 #define PIC_SWDTEN_ON() WDTCONbits.SWDTEN = 1
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 #define MTOUCH_AD_AN0 0x01
00172 #define MTOUCH_AD_AN1 0x05
00173 #define MTOUCH_AD_AN2 0x09
00174 #define MTOUCH_AD_AN3 0x0D
00175 #define MTOUCH_AD_AN4 0x11
00176
00177 #define MTOUCH_AD_AN8 0x21
00178 #define MTOUCH_AD_AN9 0x25
00179 #define MTOUCH_AD_AN10 0x29
00180 #define MTOUCH_AD_AN11 0x2D
00181 #define MTOUCH_AD_AN12 0x31
00182 #define MTOUCH_AD_AN13 0x35
00183 #define MTOUCH_AD_AN14 0x39
00184 #define MTOUCH_AD_AN15 0x3D
00185 #define MTOUCH_AD_AN16 0x41
00186 #define MTOUCH_AD_AN17 0x45
00187 #define MTOUCH_AD_AN18 0x49
00188 #define MTOUCH_AD_AN19 0x4D
00189
00190 #if defined(_16F1517) || defined(_16LF1517) || \
00191 defined(_16F1519) || defined(_16LF1519)
00192 #define MTOUCH_AD_AN20 0x51
00193 #define MTOUCH_AD_AN21 0x55
00194 #define MTOUCH_AD_AN22 0x59
00195 #define MTOUCH_AD_AN23 0x5D
00196 #define MTOUCH_AD_AN24 0x61
00197 #define MTOUCH_AD_AN25 0x65
00198 #define MTOUCH_AD_AN26 0x69
00199 #define MTOUCH_AD_AN27 0x6D
00200
00201 #define MTOUCH_AD_AN5 0x15
00202 #define MTOUCH_AD_AN6 0x19
00203 #define MTOUCH_AD_AN7 0x1D
00204 #endif
00205
00206 #define MTOUCH_AD_FVR_AND_GO 0x7F
00207 #define MTOUCH_AD_DAC_NOGO 0x79
00208 #define MTOUCH_AD_ISO_AND_GO 0x73
00209 #define MTOUCH_AD_ISO_NOGO 0x71
00210
00211 #define MTOUCH_PIN_AN0 0
00212 #define MTOUCH_PIN_AN1 1
00213 #define MTOUCH_PIN_AN2 2
00214 #define MTOUCH_PIN_AN3 3
00215 #define MTOUCH_PIN_AN4 5
00216 #define MTOUCH_PIN_AN5 0
00217 #define MTOUCH_PIN_AN6 1
00218 #define MTOUCH_PIN_AN7 2
00219 #define MTOUCH_PIN_AN8 2
00220 #define MTOUCH_PIN_AN9 3
00221 #define MTOUCH_PIN_AN10 1
00222 #define MTOUCH_PIN_AN11 4
00223 #define MTOUCH_PIN_AN12 0
00224 #define MTOUCH_PIN_AN13 5
00225 #define MTOUCH_PIN_AN14 2
00226 #define MTOUCH_PIN_AN15 3
00227 #define MTOUCH_PIN_AN16 4
00228 #define MTOUCH_PIN_AN17 5
00229 #define MTOUCH_PIN_AN18 6
00230 #define MTOUCH_PIN_AN19 7
00231 #define MTOUCH_PIN_AN20 0
00232 #define MTOUCH_PIN_AN21 1
00233 #define MTOUCH_PIN_AN22 2
00234 #define MTOUCH_PIN_AN23 3
00235 #define MTOUCH_PIN_AN24 4
00236 #define MTOUCH_PIN_AN25 5
00237 #define MTOUCH_PIN_AN26 6
00238 #define MTOUCH_PIN_AN27 7
00239
00240 #define MTOUCH_LETTER_AN0 A
00241 #define MTOUCH_LETTER_AN1 A
00242 #define MTOUCH_LETTER_AN2 A
00243 #define MTOUCH_LETTER_AN3 A
00244 #define MTOUCH_LETTER_AN4 A
00245 #define MTOUCH_LETTER_AN5 E
00246 #define MTOUCH_LETTER_AN6 E
00247 #define MTOUCH_LETTER_AN7 E
00248 #define MTOUCH_LETTER_AN8 B
00249 #define MTOUCH_LETTER_AN9 B
00250 #define MTOUCH_LETTER_AN10 B
00251 #define MTOUCH_LETTER_AN11 B
00252 #define MTOUCH_LETTER_AN12 B
00253 #define MTOUCH_LETTER_AN13 B
00254 #define MTOUCH_LETTER_AN14 C
00255 #define MTOUCH_LETTER_AN15 C
00256 #define MTOUCH_LETTER_AN16 C
00257 #define MTOUCH_LETTER_AN17 C
00258 #define MTOUCH_LETTER_AN18 C
00259 #define MTOUCH_LETTER_AN19 C
00260 #define MTOUCH_LETTER_AN20 D
00261 #define MTOUCH_LETTER_AN21 D
00262 #define MTOUCH_LETTER_AN22 D
00263 #define MTOUCH_LETTER_AN23 D
00264 #define MTOUCH_LETTER_AN24 D
00265 #define MTOUCH_LETTER_AN25 D
00266 #define MTOUCH_LETTER_AN26 D
00267 #define MTOUCH_LETTER_AN27 D
00268
00269
00270 #endif
00271
00272