![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
this is a first compilation of a library for IQS5xx. For now, it work with the iqs572ev02 devellopment board. The code is inspired with the sample code provide by Azotech. I have some issu with the interrupt pin RDY, which seem to be high even I don't touch de board.
main.cpp@1:65f5b13e6177, 2020-01-01 (annotated)
- Committer:
- skydarc
- Date:
- Wed Jan 01 12:58:46 2020 +0000
- Revision:
- 1:65f5b13e6177
- Parent:
- 0:4907da2299a4
- Child:
- 2:bd4b620316aa
just minor change
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
skydarc | 0:4907da2299a4 | 1 | #include "mbed.h" |
skydarc | 0:4907da2299a4 | 2 | #include <IQS5xx.h> |
skydarc | 0:4907da2299a4 | 3 | |
skydarc | 0:4907da2299a4 | 4 | /***** Object Declarations *****/ |
skydarc | 0:4907da2299a4 | 5 | IQS5xx trackPad(p28, p27, p17); |
skydarc | 0:4907da2299a4 | 6 | |
skydarc | 0:4907da2299a4 | 7 | DigitalOut led1(LED1); |
skydarc | 0:4907da2299a4 | 8 | DigitalOut led3(LED3); |
skydarc | 0:4907da2299a4 | 9 | DigitalOut led4(LED4); |
skydarc | 0:4907da2299a4 | 10 | |
skydarc | 0:4907da2299a4 | 11 | DigitalIn rdy(p17); |
skydarc | 0:4907da2299a4 | 12 | //InterruptIn rdyInter(p17); |
skydarc | 0:4907da2299a4 | 13 | |
skydarc | 0:4907da2299a4 | 14 | void ISR1() { //this is the response to interrupt, i.e. the ISR |
skydarc | 0:4907da2299a4 | 15 | led3 = !led3; |
skydarc | 0:4907da2299a4 | 16 | } |
skydarc | 0:4907da2299a4 | 17 | |
skydarc | 0:4907da2299a4 | 18 | int main() { |
skydarc | 0:4907da2299a4 | 19 | |
skydarc | 1:65f5b13e6177 | 20 | rdy.mode(PullUp); |
skydarc | 0:4907da2299a4 | 21 | |
skydarc | 0:4907da2299a4 | 22 | //rdyInter.rise(&ISR1); |
skydarc | 0:4907da2299a4 | 23 | |
skydarc | 0:4907da2299a4 | 24 | trackPad.AcknowledgeReset(); |
skydarc | 0:4907da2299a4 | 25 | |
skydarc | 0:4907da2299a4 | 26 | trackPad.checkVersion(); |
skydarc | 0:4907da2299a4 | 27 | |
skydarc | 0:4907da2299a4 | 28 | while(1) { |
skydarc | 0:4907da2299a4 | 29 | |
skydarc | 0:4907da2299a4 | 30 | uint8_t ui8TempData[30], i; |
skydarc | 0:4907da2299a4 | 31 | |
skydarc | 0:4907da2299a4 | 32 | while(!rdy) { |
skydarc | 0:4907da2299a4 | 33 | led4 = 1; |
skydarc | 0:4907da2299a4 | 34 | wait(0.05); |
skydarc | 0:4907da2299a4 | 35 | led4 = 0; |
skydarc | 0:4907da2299a4 | 36 | wait(0.05); |
skydarc | 0:4907da2299a4 | 37 | } |
skydarc | 0:4907da2299a4 | 38 | |
skydarc | 0:4907da2299a4 | 39 | trackPad.I2C_Read(GestureEvents0_adr, &trackPad.Data_Buff[0], 44); |
skydarc | 0:4907da2299a4 | 40 | |
skydarc | 0:4907da2299a4 | 41 | if((trackPad.Data_Buff[3] & SNAP_TOGGLE) != 0) { |
skydarc | 0:4907da2299a4 | 42 | |
skydarc | 0:4907da2299a4 | 43 | // If there was a change in a snap status, then read the snap status |
skydarc | 0:4907da2299a4 | 44 | // bytes additionally. Keep previous valus to identify a state change |
skydarc | 0:4907da2299a4 | 45 | // |
skydarc | 0:4907da2299a4 | 46 | trackPad.I2C_Read(SnapStatus_adr, &ui8TempData[0], 30); |
skydarc | 0:4907da2299a4 | 47 | for(i = 0; i < 15; i++) { |
skydarc | 0:4907da2299a4 | 48 | trackPad.ui16PrevSnap[i] = trackPad.ui16SnapStatus[i]; |
skydarc | 0:4907da2299a4 | 49 | trackPad.ui16SnapStatus[i] = ((uint16_t)(ui8TempData[2*i])<<8) + (uint16_t)ui8TempData[(2*i)+1]; |
skydarc | 0:4907da2299a4 | 50 | } |
skydarc | 0:4907da2299a4 | 51 | } |
skydarc | 0:4907da2299a4 | 52 | |
skydarc | 0:4907da2299a4 | 53 | // |
skydarc | 0:4907da2299a4 | 54 | // Terminate the communication session, so that the IQS5xx can continue |
skydarc | 0:4907da2299a4 | 55 | // with sensing and processing |
skydarc | 0:4907da2299a4 | 56 | // |
skydarc | 0:4907da2299a4 | 57 | trackPad.Close_Comms(); |
skydarc | 0:4907da2299a4 | 58 | // |
skydarc | 0:4907da2299a4 | 59 | // Process received data |
skydarc | 0:4907da2299a4 | 60 | // |
skydarc | 0:4907da2299a4 | 61 | trackPad.Process_XY(); |
skydarc | 0:4907da2299a4 | 62 | |
skydarc | 0:4907da2299a4 | 63 | led1 = 1; |
skydarc | 0:4907da2299a4 | 64 | wait(0.01); |
skydarc | 0:4907da2299a4 | 65 | led1 = 0; |
skydarc | 0:4907da2299a4 | 66 | wait(0.01); |
skydarc | 0:4907da2299a4 | 67 | } |
skydarc | 0:4907da2299a4 | 68 | } |
skydarc | 0:4907da2299a4 | 69 |