Datasheet

41
9502A–AT42–07/08
AT42QT2160
9.8 GPIOs
By default, the dedicated GPIOs (GPIO1...GPIO3) are set as inputs. Make sure to drive (set to
outputs) these GPIOs if not used, as floating pins may consume unnecessary current.
By default, shared GPOs are push-pull outputs driven low when not measuring.
Table 9-1 shows a summary of the GPIO options, and the precedence of each setting.
9.9 Typical Initialization and Usage
Figure 9-1 on page 42 shows a typical example of communicating with the QT2160.
1. After a reset/power-up, wait for CHANGE
to go low, indicating the QT2160 has
initialized and is ready to communicate.
2. Send all the setup parameters that need to be changed from the startup default values.
Drive all unused GPIOs to outputs, to prevent unnecessary increase in current
consumption.
3. After setting up the QT2160, send a Calibrate command.
4. Read all status bytes once (address 2 to 6), to return the CHANGE
line to an inactive
state.
5. If CHANGE
line goes low, perform a read of the required status byte. All the status
bytes that have changed need to be read, to ensure that the CHANGE
line goes
inactive again.
6. Process the received byte accordingly.
7. Check the reset bit in the general status byte (address 2). If it is a 1, go to step 2 to
resend all the setup parameters, as a reset has occurred. If it is a 0, proceed to the next
step.
8. Repeat steps 5, 6 and 7. Steps 5 and 6 are the continuous normal operating loop
sequence after initialization.
GPIO
Direction
GPIO
PWM
GPIO
Drive
Wake Dedicated GPIO Function Shared GPO Function
0XXX
Input - read only in LP mode so CHANGE
event possible only in LP mode
Always output
0XX1
Input - read in LP and Sleep modes so
CHANGE
event possible in both modes
Always output
1 0 0 X Output - Gnd Output - Gnd
1 0 1 X Output - Vdd Output - Vdd
1 1 X X Output - PWM Output - PWM