]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/adc.h
Make the RPP layer thread safe
[pes-rpp/rpp-lib.git] / rpp / include / rpp / adc.h
1 /**
2  * Analog Input RPP API header file.
3  *
4  * @file adc.h
5  *
6  * @copyright Copyright (C) 2013-2015 Czech Technical University in Prague
7  *
8  * @author Carlos Jenkins <carlos@jenkins.co.cr>
9  */
10
11
12 #ifndef __RPP_ADC_H
13 #define __RPP_ADC_H
14
15 /**
16  * ADC 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_adc_init();
26
27
28 #ifdef TARGET_TMS570_RPP
29 /**
30  * Get the current analog value on the given pin.
31  *
32  * The function is thread thread safe.
33  *
34  * @param[in] pin       The pin number to read [1-16].
35  *
36  * @return [0-4095] Value representing the analog value on given pin
37  *                   (ADC is 12bit resolution).\n
38  *          -1 if pin number is out of range.
39  */
40 #else
41 /**
42  * Get the current analog value on the given pin.
43  *
44  * The function is thread safe.
45  *
46  * @param[in] pin       The pin number to read [1-12].
47  *
48  * @return [0-4095] Value representing the analog value on given pin
49  *                   (ADC is 12bit resolution).\n
50  *          -1 if pin number is out of range.
51  */
52 #endif
53 int16_t rpp_adc_get(uint8_t pin);
54
55
56 /**
57  * Read and update analog cached values.
58  *
59  * The function is thread safe.
60  *
61  * @return SUCCESS when transaction was successful.\n
62  *         FAILURE if transaction could not be confirmed.
63  */
64 int8_t rpp_adc_update();
65
66
67 #endif /* __RPP_ADC_H */