skydarc meneldoll / Mbed 2 deprecated IQS572_HelloWorld

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include <IQS5xx.h>
00003 
00004 /***** Object Declarations *****/
00005 IQS5xx trackPad(p28, p27, p17);
00006 
00007 DigitalOut led1(LED1);
00008 
00009 //DigitalIn rdy(p17);
00010 InterruptIn rdyInter(p17);
00011 
00012 void ISR1() { //this is the response to interrupt, i.e. the ISR
00013 
00014     uint8_t ui8TempData[30], i;
00015         
00016         trackPad.I2C_Read(GestureEvents0_adr, &trackPad.Data_Buff[0], 44);
00017         
00018         if((trackPad.Data_Buff[3] & SNAP_TOGGLE) != 0) {
00019             
00020             // If there was a change in a snap status, then read the snap status 
00021             // bytes additionally. Keep previous valus to identify a state change
00022             //
00023             trackPad.I2C_Read(SnapStatus_adr, &ui8TempData[0], 30);
00024             for(i = 0; i < 15; i++) {
00025                 trackPad.ui16PrevSnap[i] = trackPad.ui16SnapStatus[i];
00026                 trackPad.ui16SnapStatus[i] = ((uint16_t)(ui8TempData[2*i])<<8) + (uint16_t)ui8TempData[(2*i)+1];
00027             }
00028         }
00029         
00030         //
00031         // Terminate the communication session, so that the IQS5xx can continue 
00032         // with sensing and processing
00033         //
00034         trackPad.Close_Comms();
00035         //
00036         // Process received data 
00037         //
00038         trackPad.Process_XY();
00039 }
00040 
00041 int main() {
00042     
00043     //rdy.mode(PullUp);
00044     
00045     rdyInter.rise(&ISR1);
00046     
00047     trackPad.AcknowledgeReset();
00048     
00049     trackPad.checkVersion();
00050     
00051     while(1) {
00052         
00053         
00054 
00055         led1 = 1;
00056         wait(0.5);
00057         led1 = 0;
00058         wait(0.5);  
00059     }  
00060 }
00061