touch screen handler for the microchip AR1020
Diff: ar1020.cpp
- Revision:
- 5:a5eba88e8c3e
- Parent:
- 4:510ea5b28a05
- Child:
- 6:a6971458d612
diff -r 510ea5b28a05 -r a5eba88e8c3e ar1020.cpp --- a/ar1020.cpp Thu Feb 24 14:00:17 2011 +0000 +++ b/ar1020.cpp Thu Feb 24 21:30:56 2011 +0000 @@ -52,10 +52,11 @@ bool ok=false; while (!ok) { + printf("power on AR1020\n"); _power->write(0); + wait_ms(400); + _power->write(1); wait_ms(200); - _power->write(1); - wait_ms(100); int r=cmd(0x13,NULL,0); printf("disable touch=%i\n",r); if (0!=r) @@ -72,6 +73,11 @@ printf("set mode=1 => %i\n",r); if (0!=r) continue; + + r=cmd(0x23,NULL,0 ); + printf("save regs => %i\n",r); + if (0!=r) + continue; r=cmd(0x12,NULL,0); printf("enable touch=%i\n",r); @@ -183,8 +189,11 @@ wait_us(100); if (1==_siq->read()) break; - if (t.read_ms()>1) + if (t.read_ms()>1000) + { + printf("timeout\n"); break; + } } char rhead=readByte(); wait_us(100); @@ -307,6 +316,12 @@ int AR1020::readCalibResponse() { while (true) { + while (true) { + wait_us(100); + if (1==_siq->read()) + break; + } + int r=readByte(); if (r!=0x55) { // printf("1=0x%x\n",r);