KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gpio.h
Go to the documentation of this file.
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : gpio.h
11  * Created : 5 mrt. 2013
12  * Author : Vincent van Beveren
13  */
14 
15 
16 #ifndef GPIO_H_
17 #define GPIO_H_
18 
19 /**
20  * @file
21  *
22  * @ingroup wbdrivers
23  *
24  * GPIO Driver.
25  */
26 
27 #include <stdint.h>
28 #include <stdbool.h>
29 
30 /**
31  * Defines direction of GPIO.
32  */
33 typedef enum
34 {
35  gpioInput, ///< GPIO is input
36  gpioOutput ///< GPIO is output
37 } GpioPinDir;
38 
39 /**
40  * Defines GPIO pins.
41  */
42 #define GPIO_AHRS_ENABLE 0 ///< Enable the Compass
43 #define GPIO_BLINK_LED 1 ///< Led which blink to say I'm alive
44 #define GPIO_SUICIDE 7 ///< Reset the CLB
45 
46 /**
47  * Initializes the GPIO. Sets all devices to output and off.
48  */
49 void gpioInit();
50 
51 /**
52  * Configure PIN directionality.
53  *
54  * @param pin The pin number.
55  * @param dir The direction.
56  */
57 void gpioPinConf(int pin, GpioPinDir dir);
58 
59 /**
60  * Sets the pin state.
61  *
62  * @param pin The pin to set.
63  * @param high true - Set it high (on), or false - off.
64  */
65 void gpioPinSet(int pin, bool high);
66 
67 /**
68  * Gets the PIN value, if set as input.
69  *
70  * @param pin The pin number.
71  *
72  * @return The pin value.
73  */
74 bool gpioPinGet(int pin);
75 
76 /**
77  * Set the complete bitmask on the gpio pins.
78  *
79  * @param mask The pins to set and clear (1 - set, 0 - clear).
80  */
81 void gpioSetValue(uint32_t mask);
82 
83 /**
84  * Read all gpio pins at once.
85  *
86  * @return The input of all ports as bit mask. 1 - high, 0 - low.
87  */
88 uint32_t gpioGetValue();
89 
90 
91 #endif /* GPIO_H_ */
92 
void gpioPinConf(int pin, GpioPinDir dir)
Configure PIN directionality.
Definition: gpio.c:26
uint32_t gpioGetValue()
Read all gpio pins at once.
Definition: gpio.c:56
GpioPinDir
Defines direction of GPIO.
Definition: gpio.h:33
void gpioPinSet(int pin, bool high)
Sets the pin state.
Definition: gpio.c:35
GPIO is output.
Definition: gpio.h:36
void gpioInit()
Initializes the GPIO.
Definition: gpio.c:21
GPIO is input.
Definition: gpio.h:35
bool gpioPinGet(int pin)
Gets the PIN value, if set as input.
Definition: gpio.c:45
void gpioSetValue(uint32_t mask)
Set the complete bitmask on the gpio pins.
Definition: gpio.c:50