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_16F182X_H)
00060 #define __MTOUCH_HARDWARE_16F182X_H
00061
00062 #if !defined(_16F1829) && !defined(_16LF1829)
00063 #if !defined(_16F1828) && !defined(_16LF1828)
00064 #if !defined(_16F1827) && !defined(_16LF1827)
00065 #if !defined(_16F1826) && !defined(_16LF1826)
00066 #if !defined(_16F1825) && !defined(_16LF1825)
00067 #if !defined(_16F1824) && !defined(_16LF1824)
00068 #if !defined(_16F1823) && !defined(_16LF1823)
00069 #if !defined(_12F1822) && !defined(_12LF1822)
00070 #error The current mTouch hardware include file does not support this PIC microcontroller.
00071 #endif
00072 #endif
00073 #endif
00074 #endif
00075 #endif
00076 #endif
00077 #endif
00078 #endif
00079
00080 #if defined(_12F1822) || defined(_12LF1822)
00081 #if MTOUCH_NUMBER_SENSORS > 4
00082 #error The PIC12F/LF1822 is not able to support more than 4 sensors due to pinout limitations.
00083 #endif
00084 #endif
00085 #if defined(_16F1823) || defined(_16LF1823)
00086 #if MTOUCH_NUMBER_SENSORS > 9
00087 #error The PIC16F/LF1823 is not able to support more than 7 sensors due to memory constraints.
00088 #endif
00089 #endif
00090 #if defined(_16F1823) || defined(_16LF1823)
00091 #if MTOUCH_NUMBER_SENSORS > 8
00092 #error The PIC16F/LF1823 is not able to support more than 8 sensors due to pinout limitations.
00093 #endif
00094 #endif
00095 #if defined(_16F1824) || defined(_16LF1824)
00096 #if MTOUCH_NUMBER_SENSORS > 8
00097 #error The PIC16F/LF1824 is not able to support more than 8 sensors due to pinout limitations.
00098 #endif
00099 #endif
00100 #if defined(_16F1825) || defined(_16LF1825)
00101 #if MTOUCH_NUMBER_SENSORS > 8
00102 #error The PIC16F/LF1825 is not able to support more than 8 sensors due to pinout limitations.
00103 #endif
00104 #endif
00105 #if defined(_16F1826) || defined(_16LF1826)
00106 #if MTOUCH_NUMBER_SENSORS > 12
00107 #error The PIC16F/LF1826 is not able to support more than 12 sensors due to pinout limitations.
00108 #endif
00109 #endif
00110 #if defined(_16F1827) || defined(_16LF1827)
00111 #if MTOUCH_NUMBER_SENSORS > 12
00112 #error The PIC16F/LF1827 is not able to support more than 12 sensors due to pinout limitations.
00113 #endif
00114 #endif
00115 #if defined(_16F1828) || defined(_16LF1828)
00116 #if MTOUCH_NUMBER_SENSORS > 12
00117 #error The PIC16F/LF1828 is not able to support more than 12 sensors due to pinout limitations.
00118 #endif
00119 #endif
00120 #if defined(_16F1829) || defined(_16LF1829)
00121 #if MTOUCH_NUMBER_SENSORS > 12
00122 #error The PIC16F/LF1829 is not able to support more than 12 sensors due to pinout limitations.
00123 #endif
00124 #endif
00125
00126 #if ((MTOUCH_COMM_TYPE == MTOUCH_COMM_RS232_1WAY_ASCII) && !defined(MTOUCH_COMM_ASCII_SOFT_ENABLED)) || (MTOUCH_COMM_TYPE == MTOUCH_COMM_RS232_2WAY_BINARY)
00127 #if !defined(APFCON_INITIALIZED)
00128 #warning The mTouch comm module does not automatically set the APFCON# register. The TX pin may be selectable. This warning can be removed by defining the precompiler variable 'APFCON_INITIALIZED' in the mTouch_config.h file - verifying that you've initialized this register.
00129 #endif
00130 #endif
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 #define PIC_UART_AVAILABLE
00141 #define PIC_UART_BAUD_BITS 16
00142
00143 #define PIC_TIMER0_AVAILABLE
00144 #define PIC_TIMER1_AVAILABLE
00145 #define PIC_TIMER2_AVAILABLE
00146 #if !defined(_16F1823) && !defined(_16LF1823) && !defined(_12F1822) && !defined(_12LF1822)
00147 #define PIC_TIMER4_AVAILABLE
00148 #define PIC_TIMER6_AVAILABLE
00149 #endif
00150
00151
00152
00153
00154 #define PIC_ADC_BITS 10
00155 #define PIC_ADC_UNIMP_AVAILABLE
00156
00157 #define PIC_ADC_ADCS ADCON1bits.ADCS
00158 #define PIC_ADC_ADFM ADCON1bits.ADFM
00159 #define PIC_ADC_ADON ADCON0bits.ADON
00160
00161 #define PIC_ADC_ADCS_FOSC2 0b000
00162 #define PIC_ADC_ADCS_FOSC4 0b100
00163 #define PIC_ADC_ADCS_FOSC8 0b001
00164 #define PIC_ADC_ADCS_FOSC16 0b101
00165 #define PIC_ADC_ADCS_FOSC32 0b010
00166 #define PIC_ADC_ADCS_FOSC64 0b110
00167 #define PIC_ADC_ADCS_FRC 0b111
00168
00169 #define PIC_ADC_ADFM_RIGHT 1
00170 #define PIC_ADC_ADFM_LEFT 0
00171
00172 #if _XTAL_FREQ == 32000000
00173 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC32
00174 #define PIC_ADC_TAD 1
00175 #elif _XTAL_FREQ == 16000000
00176 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC16
00177 #define PIC_ADC_TAD 1
00178 #elif _XTAL_FREQ == 8000000
00179 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC8
00180 #define PIC_ADC_TAD 1
00181 #elif _XTAL_FREQ == 4000000
00182 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC4
00183 #define PIC_ADC_TAD 1
00184 #elif _XTAL_FREQ == 2000000
00185 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC2
00186 #define PIC_ADC_TAD 1
00187 #elif _XTAL_FREQ == 1000000
00188 #define PIC_ADC_SETCLK() PIC_ADC_ADCS = PIC_ADC_ADCS_FOSC2
00189 #define PIC_ADC_TAD 2
00190 #else
00191 #error No predefined ADC clock values for the chosen _XTAL_FREQ.
00192 #endif
00193
00194
00195
00196
00197
00198 #define PIC_DAC_AVAILABLE
00199 #define PIC_DACOUT_AVAILABLE
00200
00201 #if defined(_16F1827) || defined(_16LF1827) || defined(_16F1826) || defined(_16LF1826)
00202 #define PIC_DACOUT_TRIS_C TRISA2
00203 #define PIC_DACOUT_LAT_C LATA2
00204 #define PIC_DACOUT_LAT_ASM _LATA
00205 #define PIC_DACOUT_PIN 2
00206 #else
00207 #define PIC_DACOUT_TRIS_C TRISA0
00208 #define PIC_DACOUT_LAT_C LATA0
00209 #define PIC_DACOUT_LAT_ASM _LATA
00210 #define PIC_DACOUT_PIN 0
00211 #endif
00212
00213 #define PIC_DACCON0_VDD 0xC0
00214 #define PIC_DACCON1_VDD 0x1F
00215 #define PIC_DACCON0_VSS 0x80
00216 #define PIC_DACCON1_VSS 0x00
00217
00218 #define PIC_DACOUT_DACCON0_VSS 0xA0
00219 #define PIC_DACOUT_DACCON0_1_3RD_VDD 0xA0
00220 #define PIC_DACOUT_DACCON0_HALF_VDD 0xA0
00221 #define PIC_DACOUT_DACCON0_2_3RD_VDD 0xE0
00222 #define PIC_DACOUT_DACCON0_VDD 0xE0
00223
00224 #define PIC_DACOUT_DACCON1_VSS 0x00
00225 #define PIC_DACOUT_DACCON1_1_3RD_VDD 0x0B
00226 #define PIC_DACOUT_DACCON1_HALF_VDD 0x10
00227 #define PIC_DACOUT_DACCON1_2_3RD_VDD 0x16
00228 #define PIC_DACOUT_DACCON1_VDD 0x1F
00229
00230
00231
00232
00233 #define PIC_SWDTEN_AVAILABLE
00234 #define PIC_SWDTEN_OFF() WDTCONbits.SWDTEN = 0
00235 #define PIC_SWDTEN_ON() WDTCONbits.SWDTEN = 1
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245 #define MTOUCH_AD_AN0 0x01
00246 #define MTOUCH_AD_AN1 0x05
00247 #define MTOUCH_AD_AN2 0x09
00248 #define MTOUCH_AD_AN3 0x0D
00249
00250 #if !defined(_12F1822) && !defined(_12LF1822)
00251 #define MTOUCH_AD_AN4 0x11
00252 #define MTOUCH_AD_AN5 0x15
00253 #define MTOUCH_AD_AN6 0x19
00254 #define MTOUCH_AD_AN7 0x1D
00255 #endif
00256
00257 #if defined(_16F1826) || defined(_16LF1826) || \
00258 defined(_16F1827) || defined(_16LF1827) || \
00259 defined(_16F1828) || defined(_16LF1828) || \
00260 defined(_16F1829) || defined(_16LF1829)
00261
00262 #define MTOUCH_AD_AN8 0x21
00263 #define MTOUCH_AD_AN9 0x25
00264 #define MTOUCH_AD_AN10 0x29
00265 #define MTOUCH_AD_AN11 0x2D
00266 #endif
00267
00268 #define MTOUCH_AD_FVR_AND_GO 0x7F
00269 #define MTOUCH_AD_DAC_AND_GO 0x7B
00270 #define MTOUCH_AD_DAC_NOGO 0x79
00271 #define MTOUCH_AD_ISO_AND_GO 0x43
00272 #define MTOUCH_AD_ISO_NOGO 0x41
00273
00274
00275
00276 #if defined(_16F1826) || defined(_16LF1826) || \
00277 defined(_16F1827) || defined(_16LF1827)
00278
00279 #define MTOUCH_PIN_AN0 0
00280 #define MTOUCH_PIN_AN1 1
00281 #define MTOUCH_PIN_AN2 2
00282 #define MTOUCH_PIN_AN3 3
00283 #define MTOUCH_PIN_AN4 4
00284 #define MTOUCH_PIN_AN5 6
00285 #define MTOUCH_PIN_AN6 7
00286 #define MTOUCH_PIN_AN7 5
00287 #define MTOUCH_PIN_AN8 4
00288 #define MTOUCH_PIN_AN9 3
00289 #define MTOUCH_PIN_AN10 2
00290 #define MTOUCH_PIN_AN11 1
00291 #else
00292 #define MTOUCH_PIN_AN0 0
00293 #define MTOUCH_PIN_AN1 1
00294 #define MTOUCH_PIN_AN2 2
00295 #define MTOUCH_PIN_AN3 4
00296 #define MTOUCH_PIN_AN4 0
00297 #define MTOUCH_PIN_AN5 1
00298 #define MTOUCH_PIN_AN6 2
00299 #define MTOUCH_PIN_AN7 3
00300 #define MTOUCH_PIN_AN8 6
00301 #define MTOUCH_PIN_AN9 7
00302 #define MTOUCH_PIN_AN10 4
00303 #define MTOUCH_PIN_AN11 5
00304 #endif
00305
00306
00307 #if defined(_16F1826) || defined(_16LF1826) || \
00308 defined(_16F1827) || defined(_16LF1827)
00309
00310 #define MTOUCH_LETTER_AN0 A
00311 #define MTOUCH_LETTER_AN1 A
00312 #define MTOUCH_LETTER_AN2 A
00313 #define MTOUCH_LETTER_AN3 A
00314 #define MTOUCH_LETTER_AN4 A
00315 #define MTOUCH_LETTER_AN5 B
00316 #define MTOUCH_LETTER_AN6 B
00317 #define MTOUCH_LETTER_AN7 B
00318 #define MTOUCH_LETTER_AN8 B
00319 #define MTOUCH_LETTER_AN9 B
00320 #define MTOUCH_LETTER_AN10 B
00321 #define MTOUCH_LETTER_AN11 B
00322 #else
00323 #define MTOUCH_LETTER_AN0 A
00324 #define MTOUCH_LETTER_AN1 A
00325 #define MTOUCH_LETTER_AN2 A
00326 #define MTOUCH_LETTER_AN3 A
00327 #define MTOUCH_LETTER_AN4 C
00328 #define MTOUCH_LETTER_AN5 C
00329 #define MTOUCH_LETTER_AN6 C
00330 #define MTOUCH_LETTER_AN7 C
00331 #define MTOUCH_LETTER_AN8 C
00332 #define MTOUCH_LETTER_AN9 C
00333 #define MTOUCH_LETTER_AN10 B
00334 #define MTOUCH_LETTER_AN11 B
00335 #endif
00336
00337
00338 #endif
00339
00340