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 
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);
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 }
void pinModeOutput(PIN_t pin)
Configures the given pin as output.
Definition: Utilities.c:49
#define ALERT_PIN
Definition: Utilities.h:45
#define MFP_PIN
Definition: Utilities.h:47
PinLevel_t ReadPinStatus(PIN_t pin)
Configures the pins as input and returns the pin status.
Definition: Utilities.c:70
#define MPL_PIN
Definition: Utilities.h:42
int main(int argc, char **argv)
Definition: main.c:34
void delay_ms(unsigned int ms)
Delay in ms.
Definition: Utilities.c:39
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
#define ACLM_PIN
Definition: Utilities.h:44
#define LED_PIN
Definition: Utilities.h:46
#define LUX_PIN
Definition: Utilities.h:43