Sensorian
1.0
C API Reference Guide Library
Main Page
Related Pages
Modules
Data Structures
Files
Examples
File List
Globals
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
37
I2C_Initialize
(
CAP1203ADDR
);
38
CAP1203_Initialize
();
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
CAP1203_ReadPressedButton
unsigned char CAP1203_ReadPressedButton(void)
Return id indicating which button was pressed.
Definition:
CAP1203.c:159
I2C_Close
void I2C_Close(void)
Closes the I2C peripheral.
Definition:
i2c.c:174
CAP1203_Initialize
void CAP1203_Initialize(void)
Basic configuration for the capacitive touch controller. Configures the sensor inactive mode and acti...
Definition:
CAP1203.c:41
CAP1203ADDR
#define CAP1203ADDR
The I2C address of the CAP1203 capacitive touch controller.
Definition:
CAP1203.h:36
Utilities.h
I2C_Initialize
void I2C_Initialize(unsigned char address)
Initializes the I2C peripheral.
Definition:
i2c.c:36
main
int main(int argc, char **argv)
Definition:
main.c:34
i2c.h
delay_ms
void delay_ms(unsigned int ms)
Delay in ms.
Definition:
Utilities.c:39
CAP1203_ReadID
unsigned int CAP1203_ReadID(void)
Returns product chip and manufacturing ID.
Definition:
CAP1203.c:243
CAP1203.h
CAP1203 driver header.
CAP1203
Example1
main.c
Generated on Sun Jul 12 2015 20:25:27 for Sensorian by
1.8.9.1