| 1 | /* |
|---|
| 2 | * FreeTouch, a QTouch-compatible library - tested on ATSAMD21 only! |
|---|
| 3 | * The MIT License (MIT) |
|---|
| 4 | * |
|---|
| 5 | * Copyright (c) 2017 Limor 'ladyada' Fried for Adafruit Industries |
|---|
| 6 | * |
|---|
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
|---|
| 8 | * of this software and associated documentation files (the "Software"), to deal |
|---|
| 9 | * in the Software without restriction, including without limitation the rights |
|---|
| 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|---|
| 11 | * copies of the Software, and to permit persons to whom the Software is |
|---|
| 12 | * furnished to do so, subject to the following conditions: |
|---|
| 13 | * |
|---|
| 14 | * The above copyright notice and this permission notice shall be included in |
|---|
| 15 | * all copies or substantial portions of the Software. |
|---|
| 16 | * |
|---|
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|---|
| 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|---|
| 23 | * THE SOFTWARE. |
|---|
| 24 | */ |
|---|
| 25 | |
|---|
| 26 | #include "Adafruit_CPlay_FreeTouch.h" |
|---|
| 27 | |
|---|
| 28 | #if defined(__SAMD21G18A__) |
|---|
| 29 | |
|---|
| 30 | Adafruit_CPlay_FreeTouch::Adafruit_CPlay_FreeTouch(int p, oversample_t f, series_resistor_t r, freq_mode_t fh) { |
|---|
| 31 | pin = p; |
|---|
| 32 | oversample = f; |
|---|
| 33 | seriesres = r; |
|---|
| 34 | freqhop = fh; |
|---|
| 35 | compcap = 0x2000; |
|---|
| 36 | intcap = 0x3F; |
|---|
| 37 | yline = -1; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | bool Adafruit_CPlay_FreeTouch::begin(void) { |
|---|
| 41 | yline = getYLine(); // determine the Y0-15 # |
|---|
| 42 | |
|---|
| 43 | if (yline == -1) // not all pins have Y line |
|---|
| 44 | return false; |
|---|
| 45 | |
|---|
| 46 | setupClock(); |
|---|
| 47 | |
|---|
| 48 | ptcInitSettings(); |
|---|
| 49 | |
|---|
| 50 | enablePTC(false); |
|---|
| 51 | |
|---|
| 52 | enableWCOint(false); |
|---|
| 53 | enableEOCint(false); |
|---|
| 54 | |
|---|
| 55 | // enable the sensor, only done once per line |
|---|
| 56 | if (yline < 8) { |
|---|
| 57 | sync_config(); |
|---|
| 58 | QTOUCH_PTC->YENABLEL.reg |= 1 << yline; |
|---|
| 59 | sync_config(); |
|---|
| 60 | } else if (yline < 16) { |
|---|
| 61 | QTOUCH_PTC->YENABLEH.reg |= 1 << (yline - 8); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | enablePTC(true); |
|---|
| 65 | |
|---|
| 66 | return true; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | void Adafruit_CPlay_FreeTouch::setupClock(void) { |
|---|
| 70 | /* Setup and enable generic clock source for PTC module. |
|---|
| 71 | struct system_gclk_chan_config gclk_chan_conf; |
|---|
| 72 | system_gclk_chan_get_config_defaults(&gclk_chan_conf); |
|---|
| 73 | */ |
|---|
| 74 | |
|---|
| 75 | uint8_t channel = PTC_GCLK_ID; |
|---|
| 76 | uint8_t source_generator = 1; |
|---|
| 77 | |
|---|
| 78 | // original line: system_gclk_chan_set_config(PTC_GCLK_ID, &gclk_chan_conf); |
|---|
| 79 | uint32_t new_clkctrl_config = (channel << GCLK_CLKCTRL_ID_Pos); // from gclk.c |
|---|
| 80 | |
|---|
| 81 | // original line: gclk_chan_conf.source_generator = GCLK_GENERATOR_1; |
|---|
| 82 | /* Select the desired generic clock generator */ |
|---|
| 83 | new_clkctrl_config |= source_generator << GCLK_CLKCTRL_GEN_Pos; // from gclk.c |
|---|
| 84 | |
|---|
| 85 | /* Disable generic clock channel */ |
|---|
| 86 | // original line: system_gclk_chan_disable(channel); |
|---|
| 87 | noInterrupts(); |
|---|
| 88 | |
|---|
| 89 | /* Select the requested generator channel */ |
|---|
| 90 | *((uint8_t*)&GCLK->CLKCTRL.reg) = channel; |
|---|
| 91 | |
|---|
| 92 | /* Sanity check WRTLOCK */ |
|---|
| 93 | //Assert(!GCLK->CLKCTRL.bit.WRTLOCK); |
|---|
| 94 | |
|---|
| 95 | /* Switch to known-working source so that the channel can be disabled */ |
|---|
| 96 | uint32_t prev_gen_id = GCLK->CLKCTRL.bit.GEN; |
|---|
| 97 | GCLK->CLKCTRL.bit.GEN = 0; |
|---|
| 98 | |
|---|
| 99 | /* Disable the generic clock */ |
|---|
| 100 | GCLK->CLKCTRL.reg &= ~GCLK_CLKCTRL_CLKEN; |
|---|
| 101 | while (GCLK->CLKCTRL.reg & GCLK_CLKCTRL_CLKEN) { |
|---|
| 102 | /* Wait for clock to become disabled */ |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | /* Restore previous configured clock generator */ |
|---|
| 106 | GCLK->CLKCTRL.bit.GEN = prev_gen_id; |
|---|
| 107 | |
|---|
| 108 | //system_interrupt_leave_critical_section(); |
|---|
| 109 | interrupts(); |
|---|
| 110 | |
|---|
| 111 | /* Write the new configuration */ |
|---|
| 112 | GCLK->CLKCTRL.reg = new_clkctrl_config; |
|---|
| 113 | |
|---|
| 114 | // original line: system_gclk_chan_enable(PTC_GCLK_ID); |
|---|
| 115 | *((uint8_t*)&GCLK->CLKCTRL.reg) = channel; |
|---|
| 116 | GCLK->CLKCTRL.reg |= GCLK_CLKCTRL_CLKEN; /* Enable the generic clock */ |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | // original line: system_apb_clock_set_mask(SYSTEM_CLOCK_APB_APBC, PM_APBCMASK_PTC); |
|---|
| 120 | PM->APBCMASK.reg |= PM_APBCMASK_PTC; |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | uint16_t Adafruit_CPlay_FreeTouch::measure(void) { |
|---|
| 125 | uint16_t m; |
|---|
| 126 | |
|---|
| 127 | m = measureRaw(); |
|---|
| 128 | if (m == -1) return -1; |
|---|
| 129 | |
|---|
| 130 | // normalize the signal |
|---|
| 131 | switch (oversample) { |
|---|
| 132 | case OVERSAMPLE_1: return m; |
|---|
| 133 | case OVERSAMPLE_2: return m/2; |
|---|
| 134 | case OVERSAMPLE_4: return m/4; |
|---|
| 135 | case OVERSAMPLE_8: return m/8; |
|---|
| 136 | case OVERSAMPLE_16: return m/16; |
|---|
| 137 | case OVERSAMPLE_32: return m/32; |
|---|
| 138 | case OVERSAMPLE_64: return m/64; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | return -1; // shouldn't reach here but fail if we do! |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | uint16_t Adafruit_CPlay_FreeTouch::measureRaw(void) { |
|---|
| 145 | if (yline == -1) |
|---|
| 146 | return -1; |
|---|
| 147 | |
|---|
| 148 | runInStandby(true); |
|---|
| 149 | enablePTC(true); |
|---|
| 150 | // check if in progress |
|---|
| 151 | // set up NVIC if using INT (we're not) |
|---|
| 152 | enableWCOint(false); |
|---|
| 153 | clearWCOintFlag(); |
|---|
| 154 | clearEOCintFlag(); |
|---|
| 155 | // enable_eoc_int(); // not using irq (for now) |
|---|
| 156 | |
|---|
| 157 | // set up pin! |
|---|
| 158 | //Serial.print("Y Line #"); Serial.println(yline); |
|---|
| 159 | selectYLine(); |
|---|
| 160 | // set up sense resistor |
|---|
| 161 | setSeriesResistor(seriesres); |
|---|
| 162 | // set up prescalar |
|---|
| 163 | setOversampling(oversample); |
|---|
| 164 | // set up freq hopping |
|---|
| 165 | setFreqHopping(freqhop, hops); |
|---|
| 166 | // set up compensation cap + int (?) cap |
|---|
| 167 | setCompCap(compcap); |
|---|
| 168 | setIntCap(intcap); |
|---|
| 169 | |
|---|
| 170 | QTOUCH_PTC->BURSTMODE.reg = 0xA4; |
|---|
| 171 | |
|---|
| 172 | sync_config(); |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | return startPtcAcquire(); |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | uint16_t Adafruit_CPlay_FreeTouch::startPtcAcquire(void) { |
|---|
| 179 | ptcConfigIOpin(); |
|---|
| 180 | |
|---|
| 181 | ptcAcquire(); |
|---|
| 182 | |
|---|
| 183 | while (QTOUCH_PTC->CONVCONTROL.bit.CONVERT) { |
|---|
| 184 | yield(); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | sync_config(); |
|---|
| 188 | uint16_t result = QTOUCH_PTC->RESULT.reg; |
|---|
| 189 | |
|---|
| 190 | return result; |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | /*********************************** low level config **/ |
|---|
| 194 | |
|---|
| 195 | void Adafruit_CPlay_FreeTouch::selectYLine(void) { |
|---|
| 196 | |
|---|
| 197 | sync_config(); |
|---|
| 198 | if (yline < 8) { |
|---|
| 199 | QTOUCH_PTC->YSELECTL.reg = 1 << yline; |
|---|
| 200 | } else { |
|---|
| 201 | QTOUCH_PTC->YSELECTL.reg = 0; |
|---|
| 202 | } |
|---|
| 203 | |
|---|
| 204 | if (yline > 7) { |
|---|
| 205 | QTOUCH_PTC->YSELECTH.reg = 1 << (yline - 8); |
|---|
| 206 | } else { |
|---|
| 207 | QTOUCH_PTC->YSELECTH.reg = 0; |
|---|
| 208 | } |
|---|
| 209 | |
|---|
| 210 | sync_config(); |
|---|
| 211 | } |
|---|
| 212 | |
|---|
| 213 | int Adafruit_CPlay_FreeTouch::getYLine(void) { |
|---|
| 214 | int p = g_APinDescription[pin].ulPin; |
|---|
| 215 | if (g_APinDescription[pin].ulPort == PORTA) { |
|---|
| 216 | if ((p >= 2) && (p <= 7)) { |
|---|
| 217 | return (p - 2); |
|---|
| 218 | } |
|---|
| 219 | } |
|---|
| 220 | if (g_APinDescription[pin].ulPort == PORTB) { |
|---|
| 221 | if ((p >= 0) && (p <= 9)) { |
|---|
| 222 | return (p + 6); |
|---|
| 223 | } |
|---|
| 224 | } |
|---|
| 225 | |
|---|
| 226 | // not valid |
|---|
| 227 | return -1; |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | void Adafruit_CPlay_FreeTouch::setCompCap(uint16_t cc) { |
|---|
| 231 | compcap = cc & 0x3FFF; |
|---|
| 232 | |
|---|
| 233 | sync_config(); |
|---|
| 234 | QTOUCH_PTC->COMPCAPL.bit.VALUE = compcap & 0xFF; |
|---|
| 235 | QTOUCH_PTC->COMPCAPH.bit.VALUE = (compcap>>8) & 0x3F; |
|---|
| 236 | sync_config(); |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | void Adafruit_CPlay_FreeTouch::setIntCap(uint8_t ic) { |
|---|
| 240 | intcap = ic & 0x3F; |
|---|
| 241 | |
|---|
| 242 | sync_config(); |
|---|
| 243 | QTOUCH_PTC->INTCAP.bit.VALUE = intcap & 0x3F; |
|---|
| 244 | sync_config(); |
|---|
| 245 | } |
|---|
| 246 | |
|---|
| 247 | void Adafruit_CPlay_FreeTouch::setOversampling(oversample_t lvl) { |
|---|
| 248 | oversample = lvl; // back it up for later |
|---|
| 249 | |
|---|
| 250 | sync_config(); |
|---|
| 251 | QTOUCH_PTC->CONVCONTROL.bit.ADCACCUM = lvl; |
|---|
| 252 | sync_config(); |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | void Adafruit_CPlay_FreeTouch::setSeriesResistor(series_resistor_t res) { |
|---|
| 256 | seriesres = res; |
|---|
| 257 | |
|---|
| 258 | sync_config(); |
|---|
| 259 | QTOUCH_PTC->SERRES.bit.RESISTOR = res; |
|---|
| 260 | sync_config(); |
|---|
| 261 | } |
|---|
| 262 | |
|---|
| 263 | void Adafruit_CPlay_FreeTouch::setFreqHopping(freq_mode_t fh, freq_hop_t hs) { |
|---|
| 264 | freqhop = fh; |
|---|
| 265 | hops = hs; |
|---|
| 266 | |
|---|
| 267 | sync_config(); |
|---|
| 268 | if (fh == FREQ_MODE_NONE) { |
|---|
| 269 | QTOUCH_PTC->FREQCONTROL.bit.FREQSPREADEN = 0; |
|---|
| 270 | QTOUCH_PTC->FREQCONTROL.bit.SAMPLEDELAY = 0; |
|---|
| 271 | } else { |
|---|
| 272 | QTOUCH_PTC->FREQCONTROL.bit.FREQSPREADEN = 1; |
|---|
| 273 | QTOUCH_PTC->FREQCONTROL.bit.SAMPLEDELAY = hops; |
|---|
| 274 | } |
|---|
| 275 | sync_config(); |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | void Adafruit_CPlay_FreeTouch::ptcInitSettings(void) { |
|---|
| 280 | ptcConfigIOpin(); |
|---|
| 281 | |
|---|
| 282 | enablePTC(false); |
|---|
| 283 | |
|---|
| 284 | QTOUCH_PTC->UNK4C04.reg &= 0xF7; //MEMORY[0x42004C04] &= 0xF7u; |
|---|
| 285 | QTOUCH_PTC->UNK4C04.reg &= 0xFB; //MEMORY[0x42004C04] &= 0xFBu; |
|---|
| 286 | QTOUCH_PTC->UNK4C04.reg &= 0xFC; //MEMORY[0x42004C04] &= 0xFCu; |
|---|
| 287 | sync_config(); |
|---|
| 288 | QTOUCH_PTC->FREQCONTROL.reg &= 0x9F; //MEMORY[0x42004C0C] &= 0x9Fu; |
|---|
| 289 | sync_config(); |
|---|
| 290 | QTOUCH_PTC->FREQCONTROL.reg &= 0xEF; //MEMORY[0x42004C0C] &= 0xEFu; |
|---|
| 291 | sync_config(); |
|---|
| 292 | QTOUCH_PTC->FREQCONTROL.bit.SAMPLEDELAY = 0; //MEMORY[0x42004C0C] &= 0xF0u; |
|---|
| 293 | QTOUCH_PTC->CONTROLC.bit.INIT = 1; //MEMORY[0x42004C05] |= 1u; |
|---|
| 294 | QTOUCH_PTC->CONTROLA.bit.RUNINSTANDBY = 1; //MEMORY[0x42004C00] |= 4u; |
|---|
| 295 | sync_config(); |
|---|
| 296 | enablePTC(true); //MEMORY[0x42004C00] |= 2u; |
|---|
| 297 | |
|---|
| 298 | } |
|---|
| 299 | |
|---|
| 300 | void Adafruit_CPlay_FreeTouch::ptcConfigIOpin(void) { |
|---|
| 301 | uint32_t ulpin = g_APinDescription[pin].ulPin; |
|---|
| 302 | uint32_t ulport = g_APinDescription[pin].ulPort; |
|---|
| 303 | |
|---|
| 304 | PORT->Group[ulport].PINCFG[ulpin].reg = 0x3; // pmuxen + input |
|---|
| 305 | |
|---|
| 306 | uint8_t curr_pmux = (PORT->Group[ulport].PMUX[ulpin/2].reg); |
|---|
| 307 | |
|---|
| 308 | if (ulpin & 1) { |
|---|
| 309 | // pmuxodd |
|---|
| 310 | curr_pmux &= PORT_PMUX_PMUXE(0xF); // keep the even mux data |
|---|
| 311 | curr_pmux |= PORT_PMUX_PMUXO(0x1); // set to mux B |
|---|
| 312 | } else { |
|---|
| 313 | // pmuxeven |
|---|
| 314 | curr_pmux &= PORT_PMUX_PMUXO(0xF); // keep the odd mux data |
|---|
| 315 | curr_pmux |= PORT_PMUX_PMUXE(0x1); // set to mux B |
|---|
| 316 | } |
|---|
| 317 | PORT->Group[ulport].PMUX[ulpin/2].reg = curr_pmux; |
|---|
| 318 | } |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | void Adafruit_CPlay_FreeTouch::runInStandby(boolean en) { |
|---|
| 323 | sync_config(); |
|---|
| 324 | if (en) { |
|---|
| 325 | QTOUCH_PTC->CONTROLA.bit.RUNINSTANDBY = 1; |
|---|
| 326 | } else { |
|---|
| 327 | QTOUCH_PTC->CONTROLA.bit.RUNINSTANDBY = 0; |
|---|
| 328 | } |
|---|
| 329 | sync_config(); |
|---|
| 330 | } |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | void Adafruit_CPlay_FreeTouch::enablePTC(boolean en) { |
|---|
| 334 | sync_config(); |
|---|
| 335 | if (en) { |
|---|
| 336 | QTOUCH_PTC->CONTROLA.bit.ENABLE = 1; |
|---|
| 337 | } else { |
|---|
| 338 | QTOUCH_PTC->CONTROLA.bit.ENABLE = 0; |
|---|
| 339 | } |
|---|
| 340 | sync_config(); |
|---|
| 341 | } |
|---|
| 342 | |
|---|
| 343 | void Adafruit_CPlay_FreeTouch::enableWCOint(boolean en) { |
|---|
| 344 | sync_config(); |
|---|
| 345 | if (en) { |
|---|
| 346 | QTOUCH_PTC->INTENABLE.bit.WCO = 1; |
|---|
| 347 | } else { |
|---|
| 348 | QTOUCH_PTC->INTDISABLE.bit.WCO = 1; |
|---|
| 349 | } |
|---|
| 350 | sync_config(); |
|---|
| 351 | } |
|---|
| 352 | |
|---|
| 353 | void Adafruit_CPlay_FreeTouch::enableEOCint(boolean en) { |
|---|
| 354 | sync_config(); |
|---|
| 355 | if (en) { |
|---|
| 356 | QTOUCH_PTC->INTENABLE.bit.EOC = 1; |
|---|
| 357 | } else { |
|---|
| 358 | QTOUCH_PTC->INTDISABLE.bit.EOC = 1; |
|---|
| 359 | } |
|---|
| 360 | sync_config(); |
|---|
| 361 | } |
|---|
| 362 | |
|---|
| 363 | void Adafruit_CPlay_FreeTouch::clearWCOintFlag(void) { |
|---|
| 364 | sync_config(); |
|---|
| 365 | QTOUCH_PTC->INTFLAGS.bit.WCO = 1; |
|---|
| 366 | sync_config(); |
|---|
| 367 | } |
|---|
| 368 | |
|---|
| 369 | void Adafruit_CPlay_FreeTouch::clearEOCintFlag(void) { |
|---|
| 370 | sync_config(); |
|---|
| 371 | QTOUCH_PTC->INTFLAGS.bit.EOC = 1; |
|---|
| 372 | sync_config(); |
|---|
| 373 | } |
|---|
| 374 | |
|---|
| 375 | |
|---|
| 376 | void Adafruit_CPlay_FreeTouch::ptcAcquire(void) { |
|---|
| 377 | sync_config(); |
|---|
| 378 | QTOUCH_PTC->CONVCONTROL.bit.CONVERT = 1; |
|---|
| 379 | sync_config(); |
|---|
| 380 | } |
|---|
| 381 | |
|---|
| 382 | |
|---|
| 383 | void Adafruit_CPlay_FreeTouch::sync_config(void) { |
|---|
| 384 | while (QTOUCH_PTC->CONTROLB.bit.SYNCFLAG) ; |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | /**************************** DEBUGGING ASSIST *************************/ |
|---|
| 390 | void Adafruit_CPlay_FreeTouch::snapshotRegsAndPrint(uint32_t base, uint8_t numregs) { |
|---|
| 391 | volatile uint32_t addr = base; |
|---|
| 392 | uint8_t datas[255]; |
|---|
| 393 | |
|---|
| 394 | digitalWrite(LED_BUILTIN, HIGH); |
|---|
| 395 | for (uint8_t i=0; i<numregs; i++) { |
|---|
| 396 | datas[i] = *(uint8_t *)(addr+i); |
|---|
| 397 | } |
|---|
| 398 | digitalWrite(LED_BUILTIN, LOW); |
|---|
| 399 | printPTCregs(base, datas, numregs); |
|---|
| 400 | |
|---|
| 401 | for (uint8_t i=0; i<numregs; i++) { |
|---|
| 402 | // Serial.print("$"); Serial.print(addr+i, HEX); Serial.print("\t0x"); |
|---|
| 403 | // printHex(datas[i]); Serial.println(); |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | // Print a hex with leading zero |
|---|
| 409 | void Adafruit_CPlay_FreeTouch::printHex(uint8_t h, boolean newline) { |
|---|
| 410 | if (h < 0x10) Serial.print("0"); |
|---|
| 411 | Serial.print(h, HEX); |
|---|
| 412 | if (newline) Serial.println(); |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | void Adafruit_CPlay_FreeTouch::printPTCregs(uint32_t base, uint8_t *regs, uint8_t num) { |
|---|
| 416 | Serial.println("--------------------------------------------------------"); |
|---|
| 417 | for (uint8_t i=0; i<num; i++) { |
|---|
| 418 | switch (i + base) { |
|---|
| 419 | case 0x41004430: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 420 | Serial.print(" PMUX0:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 421 | case 0x41004431: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 422 | Serial.print(" PMUX1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 423 | case 0x41004432: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 424 | Serial.print(" PMUX2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 425 | case 0x41004433: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 426 | Serial.print(" PMUX3:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 427 | |
|---|
| 428 | case 0x41004440: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 429 | Serial.print(" PCFG0:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 430 | case 0x41004441: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 431 | Serial.print(" PCFG1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 432 | case 0x41004442: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 433 | Serial.print(" PCFG2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 434 | case 0x41004443: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 435 | Serial.print(" PCFG3:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 436 | case 0x41004444: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 437 | Serial.print(" PCFG4:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | case 0x42004C00: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 441 | Serial.print(" Control A:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 442 | case 0x42004C01: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 443 | Serial.print(" Sync: \t\t0x"); printHex(regs[i], true); break; |
|---|
| 444 | case 0x42004C04: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 445 | Serial.print(" Prescaler:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 446 | case 0x42004C05: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 447 | Serial.print(" Init: \t\t0x"); printHex(regs[i], true); break; |
|---|
| 448 | case 0x42004C08: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 449 | Serial.print(" Disable Irq:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 450 | case 0x42004C09: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 451 | Serial.print(" Enable Irq:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 452 | case 0x42004C0A: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 453 | Serial.print(" Flags: \t\t0x"); printHex(regs[i], true); break; |
|---|
| 454 | case 0x42004C0C: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 455 | Serial.print(" Freq Cntl:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 456 | case 0x42004C0D: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 457 | Serial.print(" Conv Cntl:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 458 | case 0x42004C10: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 459 | Serial.print(" Y Select1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 460 | case 0x42004C11: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 461 | Serial.print(" Y Select2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 462 | /* |
|---|
| 463 | case 0x42004C12: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 464 | Serial.print(" X Select1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 465 | case 0x42004C13: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 466 | Serial.print(" X Select2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 467 | */ |
|---|
| 468 | case 0x42004C14: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 469 | Serial.print(" Y Enable1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 470 | case 0x42004C15: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 471 | Serial.print(" Y Enable2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 472 | /* |
|---|
| 473 | case 0x42004C16: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 474 | Serial.print(" X Enable1:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 475 | case 0x42004C17: Serial.print("0x"); Serial.print(i+0x42004C00, HEX); |
|---|
| 476 | Serial.print(" X Enable2:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 477 | */ |
|---|
| 478 | case 0x42004C18: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 479 | Serial.print(" Compcap L:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 480 | case 0x42004C19: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 481 | Serial.print(" Compcap H:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 482 | case 0x42004C1A: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 483 | Serial.print(" Intcap: \t\t0x"); printHex(regs[i], true); break; |
|---|
| 484 | case 0x42004C1B: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 485 | Serial.print(" Sense res:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 486 | case 0x42004C1C: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 487 | Serial.print(" Result L:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 488 | case 0x42004C1D: Serial.print("0x"); Serial.print(i+base, HEX); |
|---|
| 489 | Serial.print(" Result H:\t\t0x"); printHex(regs[i], true); break; |
|---|
| 490 | |
|---|
| 491 | } |
|---|
| 492 | } |
|---|
| 493 | } |
|---|
| 494 | #endif |
|---|