]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/mout.h
Make the RPP layer thread safe
[pes-rpp/rpp-lib.git] / rpp / include / rpp / mout.h
1 /**
2  * Power Output (12V, 2A, Push/Pull) RPP API header file.
3  *
4  * @file mout.h
5  *
6  * @copyright Copyright (C) 2013 Czech Technical University in Prague
7  *
8  * @author Carlos Jenkins <carlos@jenkins.co.cr>
9  */
10
11
12 #ifndef __RPP_MOUT_H
13 #define __RPP_MOUT_H
14
15 /**
16  * MOUT module initialization.
17  *
18  * Call this method before using this module.
19  *
20  * This function is not thread safe. Do not call it from multiple threads.
21  *
22  * @return SUCCESS if initialization successful.\n
23  *         FAILURE if module already initialized.
24  */
25 int8_t rpp_mout_init();
26
27
28 /**
29  * Set the output of given pin to given value.
30  *
31  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
32  *
33  * This function will also verify if a faulty condition is detected. See return
34  * documentation below for details.
35  *
36  * @param[in] pin       The pin number to set [1-6].
37  * @param[in] val       The value to be set [HIGH|LOW].
38  *
39  * @return SUCCESS if pin could be set and verified.\n
40  *         -1 if pin number is out of range.\n
41  *         -2 if val is not HIGH or LOW.\n
42  *         -3 if pin could not be set. With current implementation this should
43  *            never happen.\n
44  *         -4 if pin is confirmed to be in trouble.
45  *            This normally indicates a hardware failure and that the driver
46  *            chip pulled the diagnostic pin.
47  */
48 int8_t rpp_mout_set(uint8_t pin, uint8_t val);
49
50
51 /**
52  * Get the cached value of the given pin set by rpp_mout_set().
53  *
54  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
55  *
56  * This will not read the value on the pin. To confirm if the output is
57  * correctly set call rpp_mout_diag() and confirm SUCCESS.
58  *
59  * @param[in] pin       The pin number to get cached value [1-6].
60  *
61  * @return HIGH or LOW cached from last rpp_mout_set() call for given pin.
62  *         -1 if pin number is out of range.
63  */
64 int8_t rpp_mout_get(uint8_t pin);
65
66
67 /**
68  * Reads the value on the given diagnostic pin.
69  *
70  * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0.
71  *
72  * Note that rpp_mout_set() calls this routine already before returning.
73  *
74  * @param[in] pin       The pin number to read [1-6].
75  *
76  * @return SUCCESS is output is operating normally.
77  *         FAILURE if a faulty condition was detected.
78  */
79 int8_t rpp_mout_diag(uint8_t pin);
80
81
82 #endif /* __RPP_MOUT_H */