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 * This function is not thread safe. Do not call it from multiple threads.
22 * @return SUCCESS if initialization successful.\n
23 * FAILURE if module already initialized.
25 int8_t rpp_din_init();
29 * Configure voltage reference levels for digital inputs using variable
30 * reference threshold.
32 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
34 * @param[in] refA [0-4095] value to set (DAC is 12bits) the reference
35 * voltage A (pins 12-15).
36 * @param[in] refB [0-4095] value to set (DAC is 12bits) the reference
37 * voltage B (pins 8-11).
39 * @return SUCCESS if successful.\n
40 * -1 if pin millivolts is out of range.
42 int8_t rpp_din_ref(uint16_t refA, uint16_t refB);
46 * Configure given pin.
48 * Call rpp_din_update() to commit configuration changes to the hardware.
50 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
52 * @param[in] pin The pin number to setup [0-15].
53 * @param[in] pull_up TRUE to setup pin as pull-up (a switch-to-ground device
54 * is connected) or FALSE to setup as pull-down
55 * (switch-to-battery).
56 * Note that pins [8-15] are pull-down only.
57 * @param[in] active TRUE to setup pin as active or FALSE to set it as
59 * @param[in] can_wake TRUE is given pin can wake module from sleep state and
60 * trigger an interrupt on MCU. FALSE otherwise.
62 * @return SUCCESS if successful.\n
63 * -1 if pin number is out of range.\n
64 * -2 if pull_type is requested for pins without this feature.
65 * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
67 int8_t rpp_din_setup(uint8_t pin, boolean_t pull_up,
68 boolean_t active, boolean_t can_wake);
72 * Get the current cached value of the switch state on the given pin.
74 * Call rpp_din_update() to update cached values.
76 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
78 * @param[in] pin The pin number to read [0-15].
80 * @return RPP_CLOSED or RPP_OPEN if successful.\n
81 * -1 if pin number is out of range.\n
82 * -2 if var_thr is requested for inputs without this feature.
83 * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
85 int8_t rpp_din_get(uint8_t pin);
89 * Get uncached logical value of the given pin read via comparator with programmable threshold.
91 * Inputs [8-11] use programmable threshold B and [12-15] use
92 * programmable threshold A.\n
94 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
98 * @param[in] pin The pin number to read [8-15].
100 * @return HIGH or LOW if successful.\n
101 * -1 if pin number is out of range.\n
102 * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
104 int8_t rpp_din_get_tr(uint8_t pin);
108 * Get the diagnostic cached value for given pin.
110 * Call rpp_din_update() to update cached values.
112 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
114 * @param[in] pin The pin number to read [0-15].
116 * @return HIGH or LOW if successful.\n
117 * -1 if pin number is out of range.
118 * -RPP_EBUSY if pin cannot be used as DIN (e.g. because it is used for IRC)
120 int8_t rpp_din_diag(uint8_t pin);
124 * Read and update cached values and diagnostic values of all pins. Also commit
125 * configuration changes.
127 * The function is thread safe, unless compiled with -DRPP_THREADSAFE=0
129 * @return SUCCESS when transaction was successful.\n
130 * FAILURE if transaction could not be confirmed.
132 int8_t rpp_din_update();
135 #endif /* __RPP_DIN_H */