]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/include/rpp/din.h
Finished to implement AIN RPP API.
[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  * Call this method before using this module.
18  *
19  * @return SUCCESS if initialization successful.
20  *          FAILURE if module already initialized.
21  */
22 int8_t rpp_din_init();
23
24
25 /**
26  * Configure pull type for given pin.
27  *
28  * @param[in] pin       The pin number to setup [1-16].
29  * @param[in] pull_type TRUE to setup pin as pull-up (a switch-to-ground device
30  *                      is connected) or FALSE to setup as pull-down
31  *                      (switch-to-battery).
32  *                      Note that pins [9-16] are pull-down only.
33  * @param[in] active    TRUE to setup pin as active or FALSE to set it as
34  *                      tri-stated.
35  * @param[in] can_wake  TRUE is given pin can wake module from sleep state and
36  *                      trigger an interrupt on MCU. FALSE otherwise.
37  *
38  * @return SUCCESS if successful.
39  *         -1 if pin number is out of range.
40  *         -2 if pull_type is requested for pins without this feature.
41  */
42 int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type,
43                       boolean_t active, boolean_t can_wake);
44
45
46 /**
47  * Get the current cached value of the given pin.
48  * Call rpp_din_update() to update cached values.
49  *
50  * @param[in] pin       The pin number to read [1-16].
51  * @param[in] var_thr   Use variable threshold uncached high speed channel to
52  *                      read the value (True), or use SPI cached value (False).
53  *                      Note that only inputs [8-16] can use this option. Inputs
54  *                      [8-11] use variable threshold B and [12-16] use variable
55  *                      threshold B.
56  *
57  * @return HIGH or LOW if successful.
58  *         -1 if pin number is out of range.
59  *         -2 if var_thr is requested for inputs without this feature.
60  */
61 int8_t rpp_din_get(uint8_t pin, boolean_t var_thr);
62
63
64 /**
65  * Get the diagnostic cached value for given pin.
66  * Call rpp_din_update() to update cached values.
67  *
68  * @param[in] pin       The pin number to read [1-16].
69  *
70  * @return HIGH or LOW if successful.
71  *         -1 if pin number is out of range.
72  */
73 int8_t rpp_din_diag(uint8_t pin);
74
75
76 /**
77  * Read and update cached values and diagnostic values of all pins. Also commit
78  * changes on pin configurations.
79  *
80  * @return SUCCESS when transaction was successful.
81  *          FAILURE if transaction could not be confirmed.
82  */
83 int8_t rpp_din_update();
84
85
86 #endif /* __RPP_DIN_H */