Sensorian  1.0
C API Reference Guide Library
main.c
Go to the documentation of this file.
1 /****************************************************************************
2  * Copyright (C) 2015 Sensorian
3  * *
4  * This file is part of Sensorian. *
5  * *
6  * Sensorian is free software: you can redistribute it and/or modify it *
7  * under the terms of the GNU Lesser General Public License as published *
8  * by the Free Software Foundation, either version 3 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * Sensorian is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with Sensorian. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  ****************************************************************************/
20 
21 
31 #include <stdio.h>
32 #include "FXOS8700CQ.h"
33 #include "i2c.h"
34 
35 int main(int argc, char **argv)
36 {
37  I2C_Initialize(FXOS8700CQ_ADDRESS); //Initialize I2C and setup chip address
38  FXOS8700CQ_Initialize(); //Setup sensor in hybrid mode
39 
41 
42  char Int_SourceSystem = 0;
43  char Int_SourcePulse = 0;
44 
45  while(1)
46  {
47  Int_SourceSystem =FXOS8700CQ_ReadByte(INT_SOURCE); //Read interrupt source
48 
49  if((Int_SourceSystem & 0x08) == 0x08)
50  {
51  printf("Tap event detected.\r\n"); //Perform an Action since Pulse Flag has been Set
52  Int_SourcePulse = FXOS8700CQ_ReadByte(PULSE_SRC); //Read the Pulse Status Register to clear the system interrupt
53  printf("Pulse %02x.\r\n",Int_SourcePulse);
54  }
55  }
56 
57  I2C_Close(); //Return I2C pins to default status
58 
59  return 0;
60 }
#define FXOS8700CQ_ADDRESS
Definition: FXOS8700CQ.h:35
void I2C_Close(void)
Closes the I2C peripheral.
Definition: i2c.c:174
void FXOS8700CQ_ConfigureSingleTapMode(void)
Configure Single Tap mode.
Definition: FXOS8700CQ.c:467
#define INT_SOURCE
Definition: MemoryMap.h:42
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
Definition: i2c.c:36
I2C driver header.
void FXOS8700CQ_Initialize(void)
Initialize FXOS8700CQ, configure for an output rate of 200Hz with a +/- 2g scale. ...
Definition: FXOS8700CQ.c:42
int main(int argc, char **argv)
Definition: main.c:34
char FXOS8700CQ_ReadByte(char reg)
Starts up the sensor in Active mode.
Definition: FXOS8700CQ.c:539
#define PULSE_SRC
Definition: MemoryMap.h:60