2 * Digital Input RPP API header file.
6 * @copyright Copyright (C) 2013 Czech Technical University in Prague
8 * @author Carlos Jenkins <carlos@jenkins.co.cr>
16 * DIN module initialization.
18 * Call this method before using this module.
20 * @return SUCCESS if initialization successful.\n
21 * FAILURE if module already initialized.
23 int8_t rpp_din_init();
27 * Configure voltage reference levels for digital inputs using variable
28 * reference threshold.
32 * @param[in] refA [0-12000] voltage (in millivolts) to set the reference
33 * voltage A (pins 13-16).
34 * @param[in] refB [0-12000] voltage (in millivolts) to set the reference
35 * voltage B (pins 9-12).
38 * @return SUCCESS if successful.\n
39 * -1 if pin millivolts is out of range.
41 int8_t rpp_din_ref(uint16_t refA, uint16_t refB);
45 * Configure given pin.
47 * @param[in] pin The pin number to setup [1-16].
48 * @param[in] pull_type TRUE to setup pin as pull-up (a switch-to-ground device
49 * is connected) or FALSE to setup as pull-down
50 * (switch-to-battery).
51 * Note that pins [9-16] are pull-down only.
52 * @param[in] active TRUE to setup pin as active or FALSE to set it as
54 * @param[in] can_wake TRUE is given pin can wake module from sleep state and
55 * trigger an interrupt on MCU. FALSE otherwise.
57 * @return SUCCESS if successful.\n
58 * -1 if pin number is out of range.\n
59 * -2 if pull_type is requested for pins without this feature.
61 int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type,
62 boolean_t active, boolean_t can_wake);
66 * Get the current cached value of the given pin.
68 * Call rpp_din_update() to update cached values.
70 * @param[in] pin The pin number to read [1-16].
71 * @param[in] var_thr TRUE to read from variable threshold uncached high speed
72 * channel. See rpp_din_ref().\n
73 * Note that only inputs [9-16] can use this option.\n
74 * Inputs [9-12] use variable threshold B and [13-16] use
75 * variable threshold B.\n
76 * FALSE to read from SPI cached value. All pins can use
79 * @return HIGH or LOW if successful.\n
80 * -1 if pin number is out of range.\n
81 * -2 if var_thr is requested for inputs without this feature.
83 int8_t rpp_din_get(uint8_t pin, boolean_t var_thr);
87 * Get the diagnostic cached value for given pin.
89 * Call rpp_din_update() to update cached values.
91 * @param[in] pin The pin number to read [1-16].
93 * @return HIGH or LOW if successful.\n
94 * -1 if pin number is out of range.
96 int8_t rpp_din_diag(uint8_t pin);
100 * Read and update cached values and diagnostic values of all pins. Also commit
101 * changes on pin configurations.
103 * @return SUCCESS when transaction was successful.\n
104 * FAILURE if transaction could not be confirmed.
106 int8_t rpp_din_update();
109 #endif /* __RPP_DIN_H */