-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgpio_manager.cpp
61 lines (52 loc) · 1.52 KB
/
gpio_manager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* @Author: Jakub Witowski
* @Project name: iBeacon
* @File name: gpio_manager.cpp
*/
/* ==================================================================== */
/* ========================== include files =========================== */
/* ==================================================================== */
#include "gpio_manager.h"
/* ==================================================================== */
/* ======================== global variables ========================== */
/* ==================================================================== */
/* Gpio handler */
Gpio_Manager gpio;
/* ==================================================================== */
/* ============================ functions ============================= */
/* ==================================================================== */
/*
* This function initializes GPIOs
*/
void Gpio_Manager::Gpio_Init()
{
for(uint8_t pin_id = 0; pin_id < GPIO_REMOTE_USED; pin_id++)
{
/* Set used GPIO's as output */
pinMode(GpioPin[pin_id], OUTPUT);
}
}
/*
* This prints current GPIO's state
*/
void Gpio_Manager::Gpio_DebugPrint()
{
int pin_state;
for(uint8_t pin_id = 0; pin_id < GPIO_REMOTE_USED; pin_id++)
{
Serial.printf("GPIO -> ");
Serial.print(GpioPin[pin_id]);
Serial.printf(": ");
/* Read pin state */
pin_state = digitalRead(GpioPin[pin_id]);
if(0 == pin_state)
{
Serial.printf("OFF\r\n");
}
else
{
Serial.printf("ON\r\n");
}
}
}
/* EOF */