]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/din.h
Fix PIN numbering in DIN reference documentation
[pes-rpp/rpp-lib.git] / rpp / include / rpp / din.h
1 /**
2  * Digital Input RPP API header file.
3  *
4  * @file din.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_DIN_H
13 #define __RPP_DIN_H
14
15 /**
16  * DIN module initialization.
17  *
18  * Call this method before using this module.
19  *
20  * @return SUCCESS if initialization successful.\n
21  *         FAILURE if module already initialized.
22  */
23 int8_t rpp_din_init();
24
25
26 /**
27  * Configure voltage reference levels for digital inputs using variable
28  * reference threshold.
29  *
30  * @param[in] refA      [0-4095] value to set (DAC is 12bits) the reference
31  *                      voltage A (pins 12-15).
32  * @param[in] refB      [0-4095] value to set (DAC is 12bits) the reference
33  *                      voltage B (pins 8-11).
34  *
35  * @return SUCCESS if successful.\n
36  *         -1 if pin millivolts is out of range.
37  */
38 int8_t rpp_din_ref(uint16_t refA, uint16_t refB);
39
40
41 /**
42  * Configure given pin.
43  *
44  * Call rpp_din_update() to commit configuration changes to the hardware.
45  *
46  * @param[in] pin       The pin number to setup [0-15].
47  * @param[in] pull_type TRUE to setup pin as pull-up (a switch-to-ground device
48  *                      is connected) or FALSE to setup as pull-down
49  *                      (switch-to-battery).
50  *                      Note that pins [8-15] are pull-down only.
51  * @param[in] active    TRUE to setup pin as active or FALSE to set it as
52  *                      tri-stated.
53  * @param[in] can_wake  TRUE is given pin can wake module from sleep state and
54  *                      trigger an interrupt on MCU. FALSE otherwise.
55  *
56  * @return SUCCESS if successful.\n
57  *         -1 if pin number is out of range.\n
58  *         -2 if pull_type is requested for pins without this feature.
59  */
60 int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type,
61                       boolean_t active, boolean_t can_wake);
62
63
64 /**
65  * Get the current cached value of the given pin.
66  *
67  * Call rpp_din_update() to update cached values.
68  *
69  * @param[in] pin       The pin number to read [0-15].
70  * @param[in] var_thr   TRUE to read from variable threshold uncached high speed
71  *                      channel. See rpp_din_ref().\n
72  *                      Note that only inputs [8-15] can use this option.\n
73  *                      Inputs [8-11] use variable threshold B and [12-15] use
74  *                      variable threshold A.\n
75  *                      FALSE to read from SPI cached value. All pins can use
76  *                      this option.
77  *
78  * @return HIGH or LOW if successful.\n
79  *         -1 if pin number is out of range.\n
80  *         -2 if var_thr is requested for inputs without this feature.
81  */
82 int8_t rpp_din_get(uint8_t pin, boolean_t var_thr);
83
84
85 /**
86  * Get the diagnostic cached value for given pin.
87  *
88  * Call rpp_din_update() to update cached values.
89  *
90  * @param[in] pin       The pin number to read [0-15].
91  *
92  * @return HIGH or LOW if successful.\n
93  *         -1 if pin number is out of range.
94  */
95 int8_t rpp_din_diag(uint8_t pin);
96
97
98 /**
99  * Read and update cached values and diagnostic values of all pins. Also commit
100  * configuration changes.
101  *
102  * @return SUCCESS when transaction was successful.\n
103  *         FAILURE if transaction could not be confirmed.
104  */
105 int8_t rpp_din_update();
106
107
108 #endif /* __RPP_DIN_H */