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
30
#include <bcm2835.h>
31
#include <stdio.h>
32
#include "
Utilities.h
"
33
34
int
main
(
int
argc,
char
**argv)
35
{
36
if
(!bcm2835_init())
//Configure I2C pins
37
{
38
printf(
"BCM libray error.\n"
);
39
}
40
unsigned
char
pval = 0;
41
printf(
"GPIO read pin status.\r\n"
);
42
43
while
(1)
44
{
45
pval =
ReadPinStatus
(
MFP_PIN
);
46
printf(
"MFP pin level is %d\r\n"
,pval);
47
delay_ms
(1000);
48
pval =
ReadPinStatus
(
MPL_PIN
);
49
printf(
"MPL pin level is %d\r\n"
,pval);
50
delay_ms
(1000);
51
pval =
ReadPinStatus
(
LUX_PIN
);
52
printf(
"LUX pin level is %d\r\n"
,pval);
53
delay_ms
(1000);
54
pval =
ReadPinStatus
(
ALERT_PIN
);
55
printf(
"ALERT pin level is %d\r\n"
,pval);
56
delay_ms
(1000);
57
58
pval =
ReadPinStatus
(
LED_PIN
);
59
printf(
"LED pin level is %d\r\n"
,pval);
60
delay_ms
(1000);
61
pinModeOutput
(
LED_PIN
);
62
digitalWrite
(
LED_PIN
,
LOWLEVEL
);
63
delay_ms
(1000);
64
pval =
ReadPinStatus
(
LED_PIN
);
65
printf(
"LED pin level is %d\r\n"
,pval);
66
67
pval =
ReadPinStatus
(
ACLM_PIN
);
68
printf(
"ACLM pin level is %d\r\n"
,pval);
69
delay_ms
(1000);
70
}
71
72
bcm2835_close();
73
return
0;
74
}
pinModeOutput
void pinModeOutput(PIN_t pin)
Configures the given pin as output.
Definition:
Utilities.c:49
ALERT_PIN
#define ALERT_PIN
Definition:
Utilities.h:45
Utilities.h
MFP_PIN
#define MFP_PIN
Definition:
Utilities.h:47
LOWLEVEL
Definition:
Utilities.h:39
ReadPinStatus
PinLevel_t ReadPinStatus(PIN_t pin)
Configures the pins as input and returns the pin status.
Definition:
Utilities.c:70
MPL_PIN
#define MPL_PIN
Definition:
Utilities.h:42
main
int main(int argc, char **argv)
Definition:
main.c:34
delay_ms
void delay_ms(unsigned int ms)
Delay in ms.
Definition:
Utilities.c:39
digitalWrite
void digitalWrite(PIN_t pin, unsigned char level)
Write a logic level to the pin. The pin should be confgured as output.
Definition:
Utilities.c:60
ACLM_PIN
#define ACLM_PIN
Definition:
Utilities.h:44
LED_PIN
#define LED_PIN
Definition:
Utilities.h:46
LUX_PIN
#define LUX_PIN
Definition:
Utilities.h:43
LED
Example4
main.c
Generated on Sun Jul 12 2015 20:25:27 for Sensorian by
1.8.9.1