]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/irc.h
Make the RPP layer thread safe
[pes-rpp/rpp-lib.git] / rpp / include / rpp / irc.h
1 /**
2  * IRC sensor signal input RPP API header file.
3  *
4  * @file irc.h
5  *
6  * @copyright Copyright (C) 2013-2014 Czech Technical University in Prague
7  *
8  * @author Karel Kočí
9  */
10
11 #ifndef __RPP_IRC_H_
12 #define __RPP_IRC_H_
13
14 /**
15  * IRC sensor 1 connected on DIN10 and DIN11
16  */
17 #define RPP_IRC_1 1U
18
19 /**
20  * IRC sensor 2 connected on DIN14 and DIN15
21  */
22 #define RPP_IRC_2 2U
23
24 /**
25  * IRC module initialization.
26  *
27  * This function is not thread safe. Do not call it from multiple threads.
28  *
29  * Call this function before using this module.
30  *
31  * @return SUCCESS    if initialization successful.\n
32  *         FAILURE    if module already initialized.
33  */
34 int8_t rpp_irc_init();
35
36 /**
37  * IRC enable
38  *
39  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
40  *
41  * Call this function to enable IRC.
42  * Reconfigures PINMUX register and enables N2HET program for specified IRC.
43  * After calling this method corresponding pins are not usable as DIN.
44  *
45  * @param[in] irc IRC sensor connection number.\n
46  *                RPP_IRC_1 IRC connected to DIN10, DIN11\n
47  *                RPP_IRC_2 IRC connected to DIN14, DIN15\n
48  *
49  * @return SUCCESS     if IRC start is successful.\n
50  *         -RPP_EINVAL if irc is out of range.\n
51  *         FAILURE     if modules is not initialized.
52  */
53 int8_t rpp_irc_enable(uint8_t irc);
54
55 /**
56  * Check IRC status.
57  *
58  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
59  *
60  * @param[in] irc IRC sensor connection number.\n
61  *                RPP_IRC_1 IRC connected to DIN10, DIN11\n
62  *                RPP_IRC_2 IRC connected to DIN14, DIN15\n
63  *
64  * @return 1           if IRC is running.\n
65  *         0           if IRC is not running.\n
66  *         -RPP_EINVAL if irc is out of range.\n
67  *         FAILURE     if module is not initialized
68  */
69 int8_t rpp_irc_status(uint8_t irc);
70
71 /**
72  * Get the current value.
73  *
74  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
75  *
76  * @param[in] irc IRC sensor connection number.\n
77  *                RPP_IRC_1 IRC connected to DIN10, DIN11\n
78  *                RPP_IRC_2 IRC connected to DIN14, DIN15\n
79  *
80  * @return Curent value or 0 if invalid irc is passed.
81  */
82 int32_t rpp_irc_get(uint8_t irc);
83
84 /**
85  * IRC disable
86  *
87  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
88  *
89  * Call this function to disable IRC.
90  * This function reenables the DIN functionality.
91  *
92  * @param[in] irc IRC sensor connection number.\n
93  *                RPP_IRC_1 IRC connected to DIN10, DIN11\n
94  *                RPP_IRC_2 IRC connected to DIN14, DIN15\n
95  *
96  * @return SUCCESS     if IRC disable is successful.\n
97  *         -RPP_EINVAL if irc is out of range.\n
98  *         FAILURE     if modules is not initialized.
99  */
100 int8_t rpp_irc_disable(uint8_t irc);
101
102 #endif /* __RPP_IRC_H_ */