config.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254
  1. /* ************************************************************************
  2. *
  3. * global configuration, setup and settings
  4. *
  5. * (c) 2012-2019 by Markus Reschke
  6. * based on code from Markus Frejek and Karl-Heinz Kübbeler
  7. *
  8. * ************************************************************************ */
  9. /* source management */
  10. #define CONFIG_H
  11. /*
  12. * For MCU specific settings (port and pin assignments) and LCD display
  13. * settings please edit:
  14. * - ATmega328: config_328.h
  15. * - ATmega324/644/1284: config_644.h
  16. */
  17. /* ************************************************************************
  18. * Hardware options
  19. * ************************************************************************ */
  20. /*
  21. * rotary encoder for user interface
  22. * - default pins: PD2 & PD3 (ATmega 328)
  23. * - could be in parallel with LCD module
  24. * - see ENCODER_PORT for port pins (config-<MCU>.h)
  25. * - uncomment to enable and also set ENCODER_PULSES & ENCODER_STEPS below
  26. * to match your rotary encoder
  27. */
  28. #define HW_ENCODER
  29. /*
  30. * Number of Gray code pulses per step or detent for the rotary encoder
  31. * - typical values: 2 or 4, rarely 1
  32. * - a rotary encoder's pulse is the complete sequence of 4 Gray code pulses
  33. * - adjust value to match your rotary encoder
  34. */
  35. #define ENCODER_PULSES 4
  36. /*
  37. * Number of detents or steps
  38. * - this is used by the detection of the rotary encoder's turning velocity
  39. * - it doesn't have to match exactly and also allows you to finetune the
  40. * the feedback (higher: slow down, lower: speed up)
  41. * - typical values: 20, 24 or 30
  42. * - adjust value to match your rotary encoder
  43. */
  44. #define ENCODER_STEPS 20
  45. /*
  46. * increase/decrease push buttons for user interface
  47. * - alternative for rotary encoder
  48. * - see KEY_PORT for port pins (config-<MCU>.h)
  49. * - uncomment to enable
  50. */
  51. //#define HW_INCDEC_KEYS
  52. /*
  53. * 2.5V voltage reference for Vcc check
  54. * - default pin: PC4 (ATmega 328)
  55. * - should be at least 10 times more precise than the voltage regulator
  56. * - see TP_REF for port pin (config-<MCU>.h)
  57. * - uncomment to enable and also adjust UREF_25 below for your voltage
  58. * reference
  59. */
  60. //#define HW_REF25 // Disabled because of MCP1702
  61. /*
  62. * Typical voltage of 2.5V voltage reference (in mV)
  63. * - see datasheet of the voltage reference
  64. * - or use >= 5.5 digit DMM to measure the voltage
  65. */
  66. #define UREF_25 2495
  67. /*
  68. * Probe protection relay for discharging caps
  69. * - default pin: PC4 (ATmega 328)
  70. * - low signal: short circuit probe pins
  71. * high signal via external reference: remove short circuit
  72. * - uncomment to enable
  73. */
  74. //#define HW_DISCHARGE_RELAY
  75. /*
  76. * voltage measurement up to 50V DC / Zener check
  77. * - default pin: PC3 (ATmega 328)
  78. * - 10:1 voltage divider
  79. * - DC-DC boost converter controled by test push button
  80. * - see TP_ZENER for port pin
  81. * - uncomment to enable
  82. */
  83. #define HW_ZENER
  84. /*
  85. * high resolution for Zener check
  86. * - 10mV instead of 0.1V
  87. * - uncomment to enable
  88. */
  89. #define ZENER_HIGH_RES
  90. /*
  91. * fixed signal output
  92. * - in case the MCU's OC1B pin is wired as dedicated signal output
  93. * instead of driving the Rl probe resistor for test pin #2
  94. * - uncomment to enable
  95. */
  96. //#define HW_FIXED_SIGNAL_OUTPUT
  97. /*
  98. * basic frequency counter
  99. * - default pin: T0 (PD4 ATmega 328)
  100. * - uses T0 directly as frequency input
  101. * - counts up to 1/4 of MCU clock rate
  102. * - might be in parallel with LCD module
  103. * - uncomment to enable
  104. */
  105. #define HW_FREQ_COUNTER_BASIC
  106. /*
  107. * extended frequency counter
  108. * - low and high frequency crystal oscillators
  109. * and buffered frequency input
  110. * - prescalers 1:1 and 16:1 (32:1)
  111. * - see COUNTER_PORT for port pins (config-<MCU>.h)
  112. * - requires a display with more than 2 text lines
  113. * - uncomment to enable
  114. * - select the circuit's prescaler setting: either 16:1 or 32:1
  115. */
  116. //#define HW_FREQ_COUNTER_EXT
  117. #define FREQ_COUNTER_PRESCALER 16 /* 16:1 */
  118. //#define FREQ_COUNTER_PRESCALER 32 /* 32:1 */
  119. /*
  120. * event counter
  121. * - default pin: T0 (PD4 ATmega 328)
  122. * - uses T0 directly as event/pulse input (rising edge)
  123. * - no shared operation with displays possible for T0
  124. * - requires additional keys (e.g. rotary encoder) and a display with
  125. * more than 5 lines
  126. * - only for MCU clock of 8, 16 or 20MHz
  127. * - uncomment to enable
  128. */
  129. //#define HW_EVENT_COUNTER
  130. /*
  131. * trigger output for event counter
  132. * - uses probe #2 as trigger output, probes #1 and #3 are Gnd
  133. * - sets trigger output to high while counting
  134. * - uncomment to enable
  135. */
  136. //#define EVENT_COUNTER_TRIGGER_OUT
  137. /*
  138. * IR remote control detection/decoder (via dedicated MCU pin)
  139. * - requires IR receiver module, e.g. TSOP series
  140. * - module is connected to fixed I/O pin
  141. * - see IR_PORT for port pin (config-<MCU>.h)
  142. * - uncomment to enable
  143. * - for additional protocols also enable SW_IR_RX_EXTRA
  144. */
  145. //#define HW_IR_RECEIVER
  146. /*
  147. * fixed cap for self-adjustment
  148. * - see TP_CAP and ADJUST_PORT for port pins (config-<MCU>.h)
  149. * - uncomment to enable
  150. */
  151. //#define HW_ADJUST_CAP
  152. /*
  153. * relay for parallel cap (sampling ADC)
  154. * - uncomment to enable (not implemented yet)
  155. */
  156. //#define HW_CAP_RELAY
  157. /* ************************************************************************
  158. * software options
  159. * ************************************************************************ */
  160. /*
  161. * PWM generator with simple user interface
  162. * - signal output via OC1B
  163. * - uncomment to enable
  164. */
  165. #define SW_PWM_SIMPLE
  166. /*
  167. * PWM generator with fancy user interface
  168. * - signal output via OC1B
  169. * - requires additional keys and display with more than 2 text lines
  170. * - uncomment to enable
  171. */
  172. //#define SW_PWM_PLUS
  173. /*
  174. * Inductance measurement
  175. * - uncomment to enable
  176. */
  177. #define SW_INDUCTOR
  178. /*
  179. * ESR measurement and in-circuit ESR measurement
  180. * - requires MCU clock >= 8 MHz
  181. * - choose SW_OLD_ESR for old method starting at 180nF
  182. * - uncomment to enable
  183. */
  184. #define SW_ESR
  185. //#define SW_OLD_ESR
  186. /*
  187. * check for rotary encoders
  188. * - uncomment to enable
  189. */
  190. //#define SW_ENCODER
  191. /*
  192. * squarewave signal generator
  193. * - signal output via OC1B
  194. * - requires additional keys
  195. * - uncomment to enable
  196. */
  197. #define SW_SQUAREWAVE
  198. /*
  199. * IR remote control detection/decoder (via probes)
  200. * - requires IR receiver module, e.g. TSOP series
  201. * - module will be connected to probe leads
  202. * - uncomment to enable
  203. */
  204. //#define SW_IR_RECEIVER // Disabled to be able to fit in memory
  205. /*
  206. * current limiting resistor for IR receiver module
  207. * - for 5V only modules
  208. * - Warning: any short circuit may destroy your MCU
  209. * - uncomment to disable resistor
  210. */
  211. //#define SW_IR_DISABLE_RESISTOR
  212. /*
  213. * additional protocols for IR remote control detection/decoder
  214. * - uncommon protocols which will increase flash memory usage ;)
  215. * - uncomment to enable
  216. */
  217. //#define SW_IR_RX_EXTRA
  218. /*
  219. * IR remote control sender
  220. * - signal output via OC1B
  221. * - requires additional keys and display with more than 4 text lines
  222. * - also requires an IR LED with a simple driver
  223. * - uncomment to enable
  224. */
  225. //#define SW_IR_TRANSMITTER
  226. /*
  227. * Alternative delay loop for IR remote control sender
  228. * - in case the the C compiler screws up the default delay loop
  229. * and causes incorrect pulse/pause timings
  230. * - uncomment to enable
  231. */
  232. //#define SW_IR_TX_ALTDELAY
  233. /*
  234. * additional protocols for IR remote control sender
  235. * - uncommon protocols which will increase flash memory usage ;)
  236. * - uncomment to enable
  237. */
  238. //#define SW_IR_TX_EXTRA
  239. /*
  240. * check for opto couplers
  241. * - uncomment to enable
  242. */
  243. #define SW_OPTO_COUPLER
  244. /*
  245. * check for Unijunction Transistors
  246. * - uncomment to enable
  247. */
  248. #define SW_UJT
  249. /*
  250. * Servo Check
  251. * - signal output via OC1B
  252. * - requires additional keys and display with more than 2 text lines
  253. * - uncomment to enable
  254. */
  255. //#define SW_SERVO
  256. /*
  257. * DS18B20 - OneWire temperature sensor
  258. * - uncomment to enable
  259. * - also enable ONEWIRE_PROBES or ONEWIRE_IO_PIN (see section 'Busses')
  260. */
  261. //#define SW_DS18B20
  262. /*
  263. * OneWire: read ROM codes of connected devices
  264. * - requires display with more than 2 text lines
  265. * - uncomment to enable
  266. * - also enable ONEWIRE_PROBES or ONEWIRE_IO_PIN (see section 'Busses')
  267. */
  268. //#define SW_ONEWIRE_SCAN
  269. /*
  270. * capacitor leakage check
  271. * - requires display with more than two lines
  272. * - uncomment to enable
  273. */
  274. //#define SW_CAP_LEAKAGE
  275. /*
  276. * display reverse hFE for BJTs
  277. * - hFE for collector and emitter reversed
  278. * - uncomment to enable
  279. */
  280. #define SW_REVERSE_HFE
  281. /*
  282. * monitor resistance and inductance on probes #1 and #3
  283. * - uncomment to enable
  284. */
  285. //#define SW_MONITOR_RL
  286. /*
  287. * monitor capacitance on probes #1 and #3
  288. * - uncomment to enable
  289. */
  290. //#define SW_MONITOR_C
  291. /*
  292. * DHT11, DHT22 and compatible humidity & temperature sensors
  293. * - uncomment to enable
  294. */
  295. //#define SW_DHTXX
  296. /*
  297. * display font for test purposes
  298. * - uncomment to enable
  299. */
  300. //#define SW_FONT_TEST
  301. /* ************************************************************************
  302. * workarounds for some testers
  303. * ************************************************************************ */
  304. /*
  305. * Disable hFE measurement with common collector circuit and Rl as
  306. * base resistor
  307. * - problem:
  308. * hFE values are too high because base voltage is measured too low
  309. * - affected testers:
  310. * Hiland M664 (under investigation)
  311. * - uncomment to enable
  312. */
  313. //#define NO_HFE_C_RL
  314. /* ************************************************************************
  315. * workarounds for some IDEs
  316. * ************************************************************************ */
  317. /*
  318. * Oscillator startup cycles (after wakeup from power-safe mode):
  319. * - typical values
  320. * - internal RC: 6
  321. * - full swing crystal: 16384 (also 256 or 1024 based on fuse settings)
  322. * - low power crystal: 16384 (also 256 or 1024 based on fuse settings)
  323. * - Please change value if it doesn't match your tester!
  324. */
  325. #ifndef OSC_STARTUP
  326. #define OSC_STARTUP 16384
  327. #endif
  328. /* ************************************************************************
  329. * user interface
  330. * ************************************************************************ */
  331. /*
  332. * Language of user interface. Available languages:
  333. * - English (default)
  334. * - Czech (based on ISO 8859-1)
  335. * - Czech 2 (with Czech characters based on ISO 8859-2)
  336. * - Danish
  337. * - German
  338. * - Polish (based on ISO 8859-1)
  339. * - Polish 2 (with Polish characters based on ISO 8859-2)
  340. * - Spanish
  341. * - Russian (with cyrillic characters based on Windows-1251)
  342. * - Russian 2 (with cyrillic characters based on Windows-1251)
  343. */
  344. #define UI_ENGLISH
  345. //#define UI_CZECH
  346. //#define UI_CZECH_2
  347. //#define UI_DANISH
  348. //#define UI_GERMAN
  349. //#define UI_ITALIAN
  350. //#define UI_POLISH
  351. //#define UI_POLISH_2
  352. //#define UI_SPANISH
  353. //#define UI_RUSSIAN
  354. //#define UI_RUSSIAN_2
  355. /*
  356. * Use comma instead of dot to indicate a decimal fraction.
  357. * - uncomment to enable
  358. */
  359. //#define UI_COMMA
  360. /*
  361. * Display temperatures in Fahrenheit instead of Celsius.
  362. * - uncomment to enable
  363. */
  364. //#define UI_FAHRENHEIT
  365. /*
  366. * Set the default operation mode to auto-hold.
  367. * - instead of continous mode
  368. * - uncomment to enable
  369. */
  370. #define UI_AUTOHOLD
  371. /*
  372. * Trigger the menu also by a short circuit of all three probes.
  373. * - former default behaviour
  374. * - uncomment to enable
  375. */
  376. //#define UI_SHORT_CIRCUIT_MENU
  377. /*
  378. * Show key hints instead of cursor if available.
  379. * - currently only "Menu/Test"
  380. * - requires additional keys and display with a sufficient number of
  381. * text lines (recommended: >= 8 lines)
  382. * - uncomment to enable
  383. */
  384. //#define UI_KEY_HINTS
  385. /*
  386. * Output components found also via TTL serial interface.
  387. * - uncomment to enable
  388. * - also enable SERIAL_BITBANG or SERIAL_HARDWARE (see section 'Busses')
  389. */
  390. //#define UI_SERIAL_COPY
  391. /*
  392. * Control tester via TTL serial interface.
  393. * - uncomment to enable
  394. * - also enable SERIAL_BITBANG or SERIAL_HARDWARE, plus SERIAL_RW
  395. * (see section 'Busses')
  396. */
  397. //#define UI_SERIAL_COMMANDS
  398. /*
  399. * Maximum time to wait after probing (in ms).
  400. * - applies to continuous mode only
  401. * - Time between printing the result and starting a new probing cycle.
  402. */
  403. #define CYCLE_DELAY 3000
  404. /*
  405. * Maximum number of probing runs without any component found in a row.
  406. * - applies to continuous mode only
  407. * - If this number is reached the tester will power off.
  408. * - When set to zero the tester will run only once and turn off
  409. * after CYCLE_DELAY.
  410. */
  411. #define CYCLE_MAX 5
  412. /*
  413. * Automatic power-off when no button is pressed for a while (in s).
  414. * - applies to auto-hold mode only
  415. * - uncomment to enable, also adjust timeout (in s)
  416. */
  417. #define POWER_OFF_TIMEOUT 60
  418. /*
  419. * color coding for probes
  420. * - requires color graphics LCD
  421. * - uncomment to enable
  422. * - edit colors.h to select correct probe colors
  423. */
  424. #define SW_PROBE_COLORS
  425. /*
  426. * main menu: power off tester
  427. * - uncomment to enable
  428. */
  429. #define SW_POWER_OFF
  430. /*
  431. * Round some values if appropriate.
  432. * - for
  433. * - DS18B20 (0.1 °C/F)
  434. * - uncomment to enable
  435. */
  436. //#define UI_ROUND_DS18B20
  437. /*
  438. * storage of firmware data (texts, tables etc)
  439. * - self-adjustment data is always stored in EEPROM
  440. * - fonts and symbols are always stored in Flash
  441. * - uncomment one
  442. */
  443. #define DATA_EEPROM /* store data in EEPROM */
  444. //#define DATA_FLASH /* store data in Flash */
  445. /* ************************************************************************
  446. * power management
  447. * ************************************************************************ */
  448. /*
  449. * Battery monitoring mode:
  450. * - BAT_NONE disable battery monitoring completely
  451. * - BAT_DIRECT direct measurement of battary voltage (< 5V)
  452. * - BAT_DIVIDER measurement via voltage divider
  453. * - uncomment one of the modes
  454. */
  455. //#define BAT_NONE
  456. //#define BAT_DIRECT
  457. #define BAT_DIVIDER
  458. /*
  459. * Unmonitored optional external power supply
  460. * - Some circuits supporting an additional external power supply are designed
  461. * in a way that prevents the battery monitoring to measure the voltage of
  462. * the external power supply. This would trigger the low battery shut-down.
  463. * The switch below will prevent the shut-down when the measured voltage is
  464. * below 0.9V (caused by the diode's leakage current).
  465. * - uncomment to enable
  466. */
  467. //#define BAT_EXT_UNMONITORED
  468. /*
  469. * Voltage divider for battery monitoring
  470. * - BAT_R1: top resistor in Ohms
  471. * - BAT_R2: bottom resistor in Ohms
  472. */
  473. #define BAT_R1 10000
  474. #define BAT_R2 3300
  475. /*
  476. * Voltage drop by reverse voltage protection diode and power management
  477. * transistor (in mV):
  478. * - or any other circuitry in the power section
  479. * - Get your DMM and measure the voltage drop!
  480. * - Schottky diode about 200mV / PNP BJT about 100mV.
  481. */
  482. #define BAT_OFFSET 290
  483. /*
  484. * Battery weak voltage (in mV).
  485. * - Tester warns if BAT_WEAK is reached.
  486. * - Voltage drop BAT_OFFSET is considered in calculation.
  487. */
  488. #define BAT_WEAK 7400
  489. /*
  490. * Battery low voltage (in mV).
  491. * - Tester powers off if BAT_LOW is reached.
  492. * - Voltage drop BAT_OFFSET is considered in calculation.
  493. */
  494. #define BAT_LOW 6400
  495. /*
  496. * Enter sleep mode when idle to save power.
  497. * - uncomment to enable
  498. */
  499. #define SAVE_POWER
  500. /* ************************************************************************
  501. * measurement settings and offsets
  502. * ************************************************************************ */
  503. /*
  504. * ADC voltage reference based on Vcc (in mV).
  505. */
  506. #define UREF_VCC 5001
  507. /*
  508. * Offset for the internal bandgap voltage reference (in mV): -100 up to 100
  509. * - To compensate any difference between real value and measured value.
  510. * - The ADC has a resolution of about 4.88mV for V_ref = 5V (Vcc) and
  511. * 1.07mV for V_ref = 1.1V (bandgap).
  512. * - Will be added to measured voltage of bandgap reference.
  513. */
  514. #define UREF_OFFSET 0
  515. /*
  516. * Exact values of probe resistors.
  517. * - Standard value for Rl is 680 Ohms.
  518. * - Standard value for Rh is 470k Ohms.
  519. */
  520. /* Rl in Ohms */
  521. #define R_LOW 680
  522. /* Rh in Ohms */
  523. #define R_HIGH 470000
  524. /*
  525. * Offset for systematic error of resistor measurement with Rh (470k)
  526. * in Ohms.
  527. * - if resistors >20k measure too high or low adjust the offset accordingly
  528. * - standard offset is 350 Ohms
  529. */
  530. #define RH_OFFSET 350
  531. /*
  532. * Resistance of probes (in 0.01 Ohms).
  533. * - default offset for PCB tracks and probe leads
  534. * - resistance of two probes in series
  535. * - assuming all probes have same/similar resistance
  536. * - will be updated by self-adjustment
  537. */
  538. #define R_ZERO 20
  539. /*
  540. * Use probe pair specific resistance offsets instead of an
  541. * average value for all probes.
  542. * - uncomment to enable
  543. */
  544. #define R_MULTIOFFSET
  545. /*
  546. * Capacitance of probes (in pF).
  547. * - default offset for MCU, PCB tracks and probe leads
  548. * - Examples:
  549. * capacitance length
  550. * -------------------------
  551. * 3pF about 10cm
  552. * 9pF about 30cm
  553. * 15pF about 50cm
  554. * - maximum value: 100
  555. * - will be updated by self-adjustment
  556. */
  557. #define C_ZERO 43
  558. /*
  559. * Use probe pair specific capacitance offsets instead of an
  560. * average value for all probes.
  561. * - uncomment to enable
  562. */
  563. //#define CAP_MULTIOFFSET
  564. /*
  565. * Maximum voltage at which we consider a capacitor being
  566. * discharged (in mV).
  567. */
  568. #define CAP_DISCHARGED 2
  569. /*
  570. * Correction factors for capacitors (in 0.1%)
  571. * - positive factor increases capacitance value
  572. * negative factor decreases capacitance value
  573. * - CAP_FACTOR_SMALL for caps < 4.7µF
  574. * - CAP_FACTOR_MID for caps 4.7 - 47µF
  575. * - CAP_FACTOR_LARGE for caps > 47µF
  576. */
  577. #define CAP_FACTOR_SMALL 0 /* no correction */
  578. #define CAP_FACTOR_MID -40 /* -4.0% */
  579. #define CAP_FACTOR_LARGE -90 /* -9.0% */
  580. /*
  581. * Number of ADC samples to perform for each mesurement.
  582. * - Valid values are in the range of 1 - 255.
  583. */
  584. #define ADC_SAMPLES 25
  585. /* ************************************************************************
  586. * MCU specific setup to support different AVRs
  587. * ************************************************************************ */
  588. /* MCU clock */
  589. #define CPU_FREQ F_CPU
  590. /*
  591. * ATmega 328/328P
  592. */
  593. #if defined(__AVR_ATmega328__)
  594. #include "config_328.h"
  595. /*
  596. * ATmega 324P/324PA/644/644P/644PA/1284/1284P
  597. */
  598. #elif defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644__) || defined(__AVR_ATmega1284__)
  599. #include "config_644.h"
  600. /*
  601. * missing or unsupported MCU
  602. */
  603. #else
  604. #error <<< No or wrong MCU type selected! >>>
  605. #endif
  606. /* ************************************************************************
  607. * Busses
  608. * ************************************************************************ */
  609. /*
  610. * I2C bus
  611. * - might be required by some hardware
  612. * - could be enabled already in display section (config_<MCU>.h)
  613. * - for bit-bang I2C port and pins see I2C_PORT (config_<MCU>.h)
  614. * - hardware I2C (TWI) uses automatically the proper MCU pins
  615. * - uncomment either I2C_BITBANG or I2C_HARDWARE to enable
  616. * - uncomment one of the bus speed modes
  617. */
  618. //#define I2C_BITBANG /* bit-bang I2C */
  619. //#define I2C_HARDWARE /* MCU's hardware TWI */
  620. //#define I2C_STANDARD_MODE /* 100kHz bus speed */
  621. //#define I2C_FAST_MODE /* 400kHz bus speed */
  622. //#define I2C_RW /* enable I2C read support (untested) */
  623. /*
  624. * SPI bus
  625. * - might be required by some hardware
  626. * - could be enabled already in display section (config_<MCU>.h)
  627. * - for bit-bang SPI port and pins see SPI_PORT (config_<MCU>.h)
  628. * - hardware SPI uses automatically the proper MCU pins
  629. * - uncomment either SPI_BITBANG or SPI_HARDWARE to enable
  630. */
  631. //#define SPI_BITBANG /* bit-bang SPI */
  632. //#define SPI_HARDWARE /* hardware SPI */
  633. //#define SPI_RW /* enable SPI read support */
  634. /*
  635. * TTL serial interface
  636. * - could be enabled already in display section (config_<MCU>.h)
  637. * - for bit-bang serial port and pins see SERIAL_PORT (config_<MCU>.h)
  638. * - hardware serial uses automatically the proper MCU pins
  639. * - uncomment either SERIAL_BITBANG or SERIAL_HARDWARE to enable
  640. */
  641. //#define SERIAL_BITBANG /* bit-bang serial */
  642. //#define SERIAL_HARDWARE /* hardware serial */
  643. //#define SERIAL_RW /* enable serial read support */
  644. /*
  645. * OneWire bus
  646. * - for dedicated I/O pin please see ONEWIRE_PORT (config_<MCU>.h)
  647. * - uncomment either ONEWIRE_PROBES or ONEWIRE_IO_PIN to enable
  648. */
  649. //#define ONEWIRE_PROBES /* via probes */
  650. //#define ONEWIRE_IO_PIN /* via dedicated I/O pin */
  651. /* ************************************************************************
  652. * ADC clock
  653. * ************************************************************************ */
  654. /*
  655. * ADC clock
  656. * - The ADC clock is 125000Hz by default.
  657. * - You could also set 250000Hz, but that exceeds the max. ADC clock
  658. * of 200kHz for 10 bit resolution!
  659. * - Special case for 20MHz MCU clock: 156250Hz
  660. */
  661. #if CPU_FREQ == 20000000
  662. /* 20MHz MCU clock */
  663. #define ADC_FREQ 156250
  664. #else
  665. /* all other MCU clocks */
  666. #define ADC_FREQ 125000
  667. #endif
  668. /*
  669. * define clock divider
  670. * - supports 1MHz, 2MHz, 4MHz, 8MHz, 16MHz and 20MHz MCU clocks
  671. * - we got only 7 fixed prescalers from 2 up to 128
  672. */
  673. /* 1MHz/250kHz */
  674. #if CPU_FREQ / ADC_FREQ == 4
  675. #define ADC_CLOCK_DIV (1 << ADPS1)
  676. #endif
  677. /* 1MHz/125kHz 2MHz/250kHz */
  678. #if CPU_FREQ / ADC_FREQ == 8
  679. #define ADC_CLOCK_DIV (1 << ADPS1) | (1 << ADPS0)
  680. #endif
  681. /* 2MHz/125kHz 4MHz/250kHz */
  682. #if CPU_FREQ / ADC_FREQ == 16
  683. #define ADC_CLOCK_DIV (1 << ADPS2)
  684. #endif
  685. /* 4MHz/125kHz 8MHz/250kHz */
  686. #if CPU_FREQ / ADC_FREQ == 32
  687. #define ADC_CLOCK_DIV (1 << ADPS2) | (1 << ADPS0)
  688. #endif
  689. /* 8MHz/125kHz 16MHz/250kHz */
  690. #if CPU_FREQ / ADC_FREQ == 64
  691. #define ADC_CLOCK_DIV (1 << ADPS2) | (1 << ADPS1)
  692. #endif
  693. /* 16MHz/125kHz 20MHz/156.25kHz */
  694. #if CPU_FREQ / ADC_FREQ == 128
  695. #define ADC_CLOCK_DIV (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0)
  696. #endif
  697. /* ************************************************************************
  698. * derived values
  699. * ************************************************************************ */
  700. /*
  701. * number of MCU cycles per µs
  702. * - min. 1 (for 1MHz)
  703. * - max. 20 (for 20MHz)
  704. */
  705. #define MCU_CYCLES_PER_US (CPU_FREQ / 1000000)
  706. /*
  707. * number of MCU cycles per ADC cycle
  708. * - min. 4
  709. * - max. 128
  710. */
  711. #define MCU_CYCLES_PER_ADC (CPU_FREQ / ADC_FREQ)
  712. /*
  713. * time of a MCU cycle (in 0.1 ns)
  714. */
  715. #define MCU_CYCLE_TIME (10000 / (CPU_FREQ / 1000000))
  716. /* ************************************************************************
  717. * options management
  718. * ************************************************************************ */
  719. /*
  720. * storage of program data (EEPROM/Flash)
  721. */
  722. #if defined (DATA_EEPROM)
  723. /* memory type */
  724. #define MEM_TYPE EEMEM
  725. /* read functions */
  726. #define DATA_read_byte(addr) eeprom_read_byte(addr)
  727. #define DATA_read_word(addr) eeprom_read_word(addr)
  728. #elif defined (DATA_FLASH)
  729. /* memory type */
  730. #define MEM_TYPE PROGMEM
  731. /* read functions */
  732. #define DATA_read_byte(addr) pgm_read_byte(addr)
  733. #define DATA_read_word(addr) pgm_read_word(addr)
  734. #endif
  735. /*
  736. * hardware/software options
  737. */
  738. /* additional keys */
  739. /* rotary encoder, increase/decrease push buttons or touch screen */
  740. #if defined (HW_ENCODER) || defined (HW_INCDEC_KEYS) | defined (HW_TOUCH)
  741. #define HW_KEYS
  742. #endif
  743. /* options which require additional keys */
  744. #ifndef HW_KEYS
  745. /* key hints */
  746. #ifdef UI_KEY_HINTS
  747. #undef UI_KEY_HINTS
  748. #endif
  749. /* PWM+ */
  750. #ifdef SW_PWM_PLUS
  751. #undef SW_PWM_PLUS
  752. #define SW_PWM_SIMPLE
  753. #endif
  754. /* squarewave generator */
  755. #ifdef SW_SQUAREWAVE
  756. #undef SW_SQUAREWAVE
  757. #endif
  758. /* Servo Check */
  759. #ifdef SW_SERVO
  760. #undef SW_SERVO
  761. #endif
  762. /* IR Sender */
  763. #ifdef SW_IR_TRANSMITTER
  764. #undef SW_IR_TRANSMITTER
  765. #endif
  766. #endif
  767. /* options which require a MCU clock >= 8MHz */
  768. #if CPU_FREQ < 8000000
  769. /* ESR measurement */
  770. #ifdef SW_ESR
  771. #undef SW_ESR
  772. #endif
  773. /* old ESR measurement */
  774. #ifdef SW_OLD_ESR
  775. #undef SW_OLD_ESR
  776. #endif
  777. #endif
  778. /* SPI */
  779. #if defined (SPI_BITBANG) || defined (SPI_HARDWARE)
  780. #define HW_SPI
  781. #endif
  782. /* 9-Bit SPI requires bit-bang mode */
  783. #ifdef SPI_9
  784. #ifndef SPI_BITBANG
  785. #error <<< 9-Bit SPI requires bit-bang mode! >>>
  786. #endif
  787. #endif
  788. /* I2C */
  789. #if defined (I2C_BITBANG) || defined (I2C_HARDWARE)
  790. #define HW_I2C
  791. #endif
  792. /* TTL serial */
  793. #if defined (SERIAL_BITBANG) || defined (SERIAL_HARDWARE)
  794. #define HW_SERIAL
  795. #endif
  796. /* VT100 display driver disables other options for serial interface */
  797. #ifdef LCD_VT100
  798. #ifdef UI_SERIAL_COPY
  799. #undef UI_SERIAL_COPY
  800. #endif
  801. #ifdef UI_SERIAL_COMMANDS
  802. #undef UI_SERIAL_COMMANDS
  803. #endif
  804. #endif
  805. /* options which require TTL serial */
  806. #ifndef HW_SERIAL
  807. #ifdef LCD_VT100
  808. #undef LCD_VT100
  809. #endif
  810. #ifdef UI_SERIAL_COPY
  811. #undef UI_SERIAL_COPY
  812. #endif
  813. #ifdef UI_SERIAL_COMMANDS
  814. #undef UI_SERIAL_COMMANDS
  815. #endif
  816. #endif
  817. /* options which require TTL serial RW */
  818. #ifndef SERIAL_RW
  819. #ifdef UI_SERIAL_COMMANDS
  820. #undef UI_SERIAL_COMMANDS
  821. #endif
  822. #endif
  823. /* OneWire: probe leads prevail */
  824. #ifdef ONEWIRE_PROBES
  825. #undef ONEWIRE_IO_PIN
  826. #endif
  827. #ifdef ONEWIRE_IO_PIN
  828. #undef ONEWIRE_PROBES
  829. #endif
  830. /* options which require OneWire */
  831. #if ! defined (ONEWIRE_PROBES) && ! defined (ONEWIRE_IO_PIN)
  832. #ifdef SW_DS18B20
  833. #undef SW_DS18B20
  834. #endif
  835. #endif
  836. /* touchscreen */
  837. #ifdef TOUCH_PORT
  838. #define HW_TOUCH
  839. #endif
  840. /* LCD module */
  841. #ifdef LCD_CONTRAST
  842. #define SW_CONTRAST
  843. #else
  844. #define LCD_CONTRAST 0
  845. #endif
  846. /* color coding for probes requires a color graphics display */
  847. #ifdef SW_PROBE_COLORS
  848. #ifndef LCD_COLOR
  849. #undef SW_PROBE_COLORS
  850. #endif
  851. #endif
  852. /* component symbols for fancy pinout */
  853. #if defined (SYMBOLS_24X24_H)
  854. #define SW_SYMBOLS
  855. #endif
  856. #if defined (SYMBOLS_24X24_HF) || defined (SYMBOLS_30X32_HF) || defined (SYMBOLS_32X32_HF)
  857. #define SW_SYMBOLS
  858. #endif
  859. #if defined (SYMBOLS_24X24_VFP)
  860. #define SW_SYMBOLS
  861. #endif
  862. #if defined (SYMBOLS_24X24_VP_F)
  863. #define SW_SYMBOLS
  864. #endif
  865. /* symbols require graphic display */
  866. #ifdef SW_SYMBOLS
  867. #ifndef LCD_GRAPHIC
  868. #undef SW_SYMBOLS
  869. #endif
  870. #endif
  871. /* frequency counter */
  872. #if defined (HW_FREQ_COUNTER_BASIC) || defined (HW_FREQ_COUNTER_EXT)
  873. #define HW_FREQ_COUNTER
  874. #endif
  875. /* IR detector/decoder: probe lead based decoder prevails */
  876. #ifdef SW_IR_RECEIVER
  877. #undef HW_IR_RECEIVER
  878. #endif
  879. #ifdef HW_IR_RECEIVER
  880. #undef SW_IR_RECEIVER
  881. #endif
  882. /* rounding for DS18B20 requires DS18B20 support */
  883. #ifdef UI_ROUND_DS18B20
  884. #ifndef SW_DS18B20
  885. #undef UI_ROUND_DS18B20
  886. #endif
  887. #endif
  888. /* ************************************************************************
  889. * EOF
  890. * ************************************************************************ */