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 
28 #include <bcm2835.h>
29 #include "i2c.h"
30 #include "CAP1203.h"
31 #include "Utilities.h"
32 
33 int main(int argc, char **argv)
34 {
35  unsigned char button = 0x00;
36 
39 
40  int id = CAP1203_ReadID(); //Read ID of Capacitive touch controller
41  printf("Chip ID: 0x%04X. \r\n",id);
42 
43  while(1)
44  {
45  button = CAP1203_ReadPressedButton();
46 
47  if(button != 0)
48  {
49  printf("Button B%d pressed.\r\n" ,button);
50  }
51  delay_ms(500);
52 
53  }
54  I2C_Close();
55 
56  return 0;
57 }
58 
unsigned char CAP1203_ReadPressedButton(void)
Return id indicating which button was pressed.
Definition: CAP1203.c:159
void I2C_Close(void)
Closes the I2C peripheral.
Definition: i2c.c:174
void CAP1203_Initialize(void)
Basic configuration for the capacitive touch controller. Configures the sensor inactive mode and acti...
Definition: CAP1203.c:41
#define CAP1203ADDR
The I2C address of the CAP1203 capacitive touch controller.
Definition: CAP1203.h:36
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
Definition: i2c.c:36
int main(int argc, char **argv)
Definition: main.c:34
void delay_ms(unsigned int ms)
Delay in ms.
Definition: Utilities.c:39
unsigned int CAP1203_ReadID(void)
Returns product chip and manufacturing ID.
Definition: CAP1203.c:243
CAP1203 driver header.