Revision 119ec0d2

View differences:

include/AT42QT1050/v1/alld_AT42QT1050_v1.h
243 243
  apalExitStatus_t at42qt1050_lld_read_keyssignal(const AT42QT1050Driver* at42qt1050d, const uint8_t key, uint16_t* signal, const apalTime_t timeout);
244 244
  apalExitStatus_t at42qt1050_lld_read_referencedata(const AT42QT1050Driver* at42qt1050d, const uint8_t key, uint16_t* refdata, const apalTime_t timeout);
245 245

  
246
  apalExitStatus_t at42qt1050_lld_reset_safe(const AT42QT1050Driver* at42qt1050d, const bool wait4wakeup, const apalTime_t timeout);
247
  apalExitStatus_t at42qt1050_lld_reset(const AT42QT1050Driver* at42qt1050d, const apalTime_t timeout, const bool wait4wakeup);
248

  
246 249
  uint16_t at42qt1050_lld_pulse2samples(const uint8_t pulse);
247 250
  float at42qt1050_lld_samples2pulse(const uint16_t samples);
248 251
  uint16_t at42qt1050_lld_scale2scaling(const uint8_t scale);
source/AT42QT1050/v1/alld_AT42QT1050_v1.c
33 33
/******************************************************************************/
34 34
/* LOCAL DEFINITIONS                                                          */
35 35
/******************************************************************************/
36
#define AT42QT1050_LLD_WATCHDOGTIME_MAX         125000
37
#define AT42QT1050_LLD_INITIALIZATION_TIME_MAX   30000  
36 38

  
37 39
/******************************************************************************/
38 40
/* EXPORTED VARIABLES                                                         */
......
107 109
  apalDbgAssert(key < AT42QT1050_LLD_NUM_KEYS);
108 110
  apalDbgAssert(signal != NULL);
109 111

  
110
  const uint8_t txbuf = AT42QT1050_LLD_REG_KEYSIGNAL_0 + (2*key) + ((key > 1) ? 1 : 0);
112
  const uint8_t txbuf = AT42QT1050_LLD_REG_KEYSIGNAL_0 + (2*key) + ((key > 1) ? 2 : 0);
111 113
  uint8_t rxbuf[2];
112 114
  const apalExitStatus_t status = apalI2CMasterTransmit(at42qt1050d->i2cd, at42qt1050d->addr, &txbuf, 1, rxbuf, 2, timeout);
113 115
  *signal = (rxbuf[0] << 8) | rxbuf[1];
......
130 132
  apalDbgAssert(key < AT42QT1050_LLD_NUM_KEYS);
131 133
  apalDbgAssert(refdata != NULL);
132 134

  
133
  const uint8_t txbuf = AT42QT1050_LLD_REG_REFERENCEDATA_0 + (2*key) + ((key > 1) ? 1 : 0);
135
  const uint8_t txbuf = AT42QT1050_LLD_REG_REFERENCEDATA_0 + (2*key) + ((key > 1) ? 2 : 0);
134 136
  uint8_t rxbuf[2];
135 137
  const apalExitStatus_t status = apalI2CMasterTransmit(at42qt1050d->i2cd, at42qt1050d->addr, &txbuf, 1, rxbuf, 2, timeout);
136 138
  *refdata = (rxbuf[0] << 8) | rxbuf[1];
......
138 140
}
139 141

  
140 142
/**
143
 * @brief       Soft Reset of the device
144
 *
145
 * @param[in]   at42qt1050d   The AT42QT1050 driver to use.
146
 * @param[in]   timeout       Timeout for the function to return (in microseconds).
147
 * @param[in]   wait4wakeup   Wait for device wakeup (timeout must be > 155 ms)
148
 *
149
 * @return      Indicator whether the function call was successful or a timeout occurred.
150
 */
151
inline apalExitStatus_t at42qt1050_lld_reset_safe(const AT42QT1050Driver* at42qt1050d, const bool wait4wakeup, const apalTime_t timeout) {
152
  if(wait4wakeup)
153
    apalDbgAssert(timeout >= AT42QT1050_LLD_WATCHDOGTIME_MAX+AT42QT1050_LLD_INITIALIZATION_TIME_MAX);
154

  
155
  return at42qt1050_lld_reset(at42qt1050d, timeout-(AT42QT1050_LLD_WATCHDOGTIME_MAX+AT42QT1050_LLD_INITIALIZATION_TIME_MAX), wait4wakeup);
156
}
157

  
158
/**
159
 * @brief       Soft Reset of the device
160
 *
161
 * @param[in]   at42qt1050d   The AT42QT1050 driver to use.
162
 * @param[in]   timeout       Timeout for the i2c call (in microseconds).
163
 * @param[in]   wait4wakeup   Wait for device wakeup (155 ms)
164
 *
165
 * @return      Indicator whether the function call was successful or a timeout occurred.
166
 */
167
inline apalExitStatus_t at42qt1050_lld_reset(const AT42QT1050Driver* at42qt1050d, const apalTime_t timeout, const bool wait4wakeup) {
168
  apalDbgAssert(at42qt1050d != NULL && at42qt1050d->i2cd != NULL);
169

  
170
  const apalExitStatus_t status = at42qt1050_lld_write_reg(
171
	at42qt1050d, AT42QT1050_LLD_RESETCALIBRATE_RESET, AT42QT1050_LLD_RESETCALIBRATE_RESET, timeout);
172
  if(wait4wakeup)
173
	usleep(AT42QT1050_LLD_WATCHDOGTIME_MAX+AT42QT1050_LLD_INITIALIZATION_TIME_MAX); // watchdog timer+initialization -> datasheet
174
  return status;
175
}
176

  
177
/**
141 178
 * @brief   Convert a 4 bit pulse value to the representing number of samples.
142 179
 * @details Calculation: <#samples> = 2^(<pulse value>)
143 180
 *

Also available in: Unified diff