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.
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).
35 * @return SUCCESS if successful.\n
36 * -1 if pin millivolts is out of range.
38 int8_t rpp_din_ref(uint16_t refA, uint16_t refB);
42 * Configure given pin.
44 * Call rpp_din_update() to commit configuration changes to the hardware.
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
53 * @param[in] can_wake TRUE is given pin can wake module from sleep state and
54 * trigger an interrupt on MCU. FALSE otherwise.
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.
60 int8_t rpp_din_setup(uint8_t pin, boolean_t pull_type,
61 boolean_t active, boolean_t can_wake);
65 * Get the current cached value of the given pin.
67 * Call rpp_din_update() to update cached values.
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
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.
82 int8_t rpp_din_get(uint8_t pin, boolean_t var_thr);
86 * Get the diagnostic cached value for given pin.
88 * Call rpp_din_update() to update cached values.
90 * @param[in] pin The pin number to read [0-15].
92 * @return HIGH or LOW if successful.\n
93 * -1 if pin number is out of range.
95 int8_t rpp_din_diag(uint8_t pin);
99 * Read and update cached values and diagnostic values of all pins. Also commit
100 * configuration changes.
102 * @return SUCCESS when transaction was successful.\n
103 * FAILURE if transaction could not be confirmed.
105 int8_t rpp_din_update();
108 #endif /* __RPP_DIN_H */