BERGSONNE

Sense.CAP

Capacitive trackpad driver for the Sense.CAP tile (IQS7211A).

Vibe Settings

What Studio’s Vibe interface lets you change on this tile, in plain language or from the tile inspector. Each one is an argument of a driver function below, so the same setting is available from Blocks, the DSL and C. Basic settings are shown by default; advanced ones sit behind the inspector’s Advanced toggle.

SettingTierValuesDefaultFunction
Surface layoutbasicNo surface: nothing sensed, 2x3 trackpad (bench-tuned), 2x3 as six buttons, 3-segment slider on RX3, 4-segment slider, RX6 as TxNo surface: nothing sensedset_layout(layout)
Touch sensitivitybasicFirm touches only (multipliers x2), Less sensitive (x1.5), As tuned for the surface, More sensitive (x0.75), Light touches (x0.5)As tuned for the surfaceset_sensitivity(level)
Power profilebasicAlways active (10 ms in every mode), Responsive, Balanced, Low powerResponsiveset_power_profile(profile)
Touch-set multiplieradvanced1 to 2558set_touch_multipliers(set_mult)
Touch-clear multiplieradvanced0 to 2555set_touch_multipliers(clear_mult)
Active report periodadvanced10 to 1000 ms10set_active_rate(ms)
Idle time before low poweradvanced0 to 3600 s20set_idle_timeout(seconds)
Wake on proximityadvancedon / offoffset_alp_wake(enable)
Proximity wake thresholdadvanced1 to 100020set_alp_threshold(threshold)
Mirror Xadvancedon / offoffset_flip_x(enable)
Mirror Yadvancedon / offoffset_flip_y(enable)
Swap X and Yadvancedon / offoffset_switch_xy(enable)
X resolutionadvanced0 to 655350set_resolution(x_res)
Y resolutionadvanced0 to 655350set_resolution(y_res)
Tap timeadvanced50 to 2000 ms300set_tap_time(ms)
Hold timeadvanced0 to 5000 ms300set_hold_time(ms)
Swipe distanceadvanced0 to 655350set_swipe_distance(px)
Swipe angleadvanced1 to 75 deg45set_swipe_angle(degrees)
Gesture engineadvancedDriver recognizers, Chip gesture engineDriver recognizersset_gesture_source(source)

Examples

Polling example (Cores SDK)

  tile_t pad;
  sense_cap_cfg_t cfg = { .millis = my_millis, .mclr = my_mclr, .reset_on_init = 1,
                          .layout = SENSE_CAP_LAYOUT_GRID_2X3 };
  tile_sense_cap_init(core_tiles_pal(&core_i2c1), 0, &pad, &cfg);   // ~0.1 s
  while (1) {
      tile_sense_cap_process(&pad);  // finishes baseline, layout and ATI first
      if (tile_sense_cap_get_num_fingers(&pad) > 0)
          printf("x=%u y=%u\n", tile_sense_cap_get_finger_x(&pad, 0),
                                tile_sense_cap_get_finger_y(&pad, 0));
      core_delay_ms(10);
  }

Custom surface example (blocking)

  sense_cap_surface_t s = SENSE_CAP_SURFACE_DEFAULTS;  // the 2x3 grid
  s.tuning.touch_set_mult = 4;  s.tuning.touch_clear_mult = 2;
  s.alp.enable = 0;
  if (tile_sense_cap_configure_surface(&pad, &s) != SENSE_CAP_OK) { ... }

API reference

Initialization

tile_sense_cap_find

uint8_t tile_sense_cap_find(tiles_pal_t *hal, uint8_t instance)

Reads the product number, asking for a communication window when the chip answers 0xEEEE (a bare address probe goes unanswered outside a window). Blocks up to ~0.4 s. no-window marker; 0 if nothing answered.

hal
Tiles HAL handle (I2C bus)
instance
Device instance (only 0 exists)

Returns 1 if the chip reported product 763, or answered with the

tile_sense_cap_init

void tile_sense_cap_init(tiles_pal_t *hal, uint8_t instance, tile_t *tile, const sense_cap_cfg_t *cfg)

Identifies the chip (product 763) and returns: the tile is READY, and the baseline (see the file header) is a job that surface_poll() or process() advance, one register transaction per call, until is_surface_ready() returns 1. With cfg.layout set, the same job also applies and tunes that layout. Setters called meanwhile are queued into the job. A baseline that does not verify is reported by surface_poll() / process() (the error, and TILE_ON_ERROR) and leaves is_surface_ready() at 0; the tile stays READY (only a chip that is not found sets ERROR). Never software-resets the chip. Blocking: the product read, which waits at most ~0.4 s for a communication window (typically one transaction). With cfg.reset_on_init it pulses MCLR first and waits for the boot instead (0.1 s, at most ~0.7 s). Without it, a chip that does not answer gets one MCLR pulse if cfg.mclr is set (worst case ~1.1 s, chip absent). Blocking use: `while (tile_sense_cap_surface_poll(&pad) == SENSE_CAP_BUSY) core_delay_ms(2);` or configure_surface(), which also finishes the baseline.

hal
Tiles HAL handle (I2C bus)
instance
Device instance (only 0 exists)
tile
Tile handle to initialize
cfg
Optional config. NULL for defaults.

Lifecycle

tile_sense_cap_set_layout

Studio
sense_cap_result_t tile_sense_cap_set_layout(tile_t *tile, sense_cap_layout_t layout)

Starts applying a preset: GRID_2X3 is the bench-tuned 2x3 trackpad (X 0-511, Y 0-255); BUTTONS_2X3 is the same wiring read as six channel touch states; SLIDER_1X3 uses RX3 across TX11/TX9/TX8 (X 0-511); SLIDER_1X4 adds RX6 as a fourth Tx (X 0-767). Only GRID_2X3 is bench-tuned. Call process() (or surface_poll()) until is_surface_ready(); the ATI takes a second or two. NONE stops sensing; it is ready once its registers verify.

layout
Preset (init: NONE)

Returns SENSE_CAP_OK when started, or an error.

tile_sense_cap_surface_poll

Studio
sense_cap_result_t tile_sense_cap_surface_poll(tile_t *tile)

Each call makes at most one register transaction, whose wait for a communication window is capped at one Active report period + 2 ms (20 ms at most): ~12 ms plus the transaction at the 10 ms Active rate. Returns SENSE_CAP_BUSY until the job is done (baseline verified; with a surface, applied and tuned). process() calls it for you while a job runs. Nothing to do: SENSE_CAP_OK.

Returns SENSE_CAP_OK when done, SENSE_CAP_BUSY, or the job's error.

tile_sense_cap_is_surface_ready

Studio
uint8_t tile_sense_cap_is_surface_ready(tile_t *tile)

1 once no baseline / surface job or ATI is pending and the last job verified the register image; with a surface (any layout but NONE) it must also have been applied with the ATI converged. With layout NONE it becomes 1 as soon as the baseline from init() is applied. 0 again while a new job (set_layout(), a setter's re-sync after a chip reset) or an ATI runs, and after a failed job.

Returns 1 if ready, 0 otherwise.

tile_sense_cap_ati_start

Studio
sense_cap_result_t tile_sense_cap_ati_start(tile_t *tile, sense_cap_ati_target_t target)

Trackpad ATI runs when the trackpad is next sensed; ALP ATI only runs in LP1/LP2 (§5.6.3), so the driver holds the chip in LP1 under manual control for it and then hands mode control back. Re-run after any mechanical change (cover, enclosure). Advance with ati_poll().

target
Trackpad, ALP or both

Returns SENSE_CAP_OK when queued, or SENSE_CAP_ERR_STATE if a job runs.

tile_sense_cap_ati_poll

Studio
sense_cap_result_t tile_sense_cap_ati_poll(tile_t *tile)

Stays off the bus for 100 ms after queuing, then checks at most every 50 ms whether the re-ATI bit has cleared (the chip clears it when the algorithm completes, §5.6.3), so it never starves the ATI. The verdict is every sensed channel within 25% of the target; up to three rounds. One register transaction per call, like surface_poll().

Returns SENSE_CAP_OK, SENSE_CAP_BUSY, SENSE_CAP_ERR_ATI or another error.

tile_sense_cap_hw_reset

Studio
sense_cap_result_t tile_sense_cap_hw_reset(tile_t *tile)

Pulls MCLR low for 2 ms (at least 250 ns needed, Table 4.2), releases it and waits for the chip to boot (0.1 s, at most ~0.7 s), then starts re-applying the baseline and the stored surface (finish with surface_poll() or process()). Recovers a chip that no longer answers I2C. Needs a tile that init() has seen (READY, or ERROR after a failed init); to reset before init, set cfg.reset_on_init. without cfg.mclr, SENSE_CAP_ERR_STATE before init(), or SENSE_CAP_ERR_NOT_FOUND.

Returns SENSE_CAP_OK once the chip is back, SENSE_CAP_ERR_NO_CALLBACK

tile_sense_cap_reset

Studio
sense_cap_result_t tile_sense_cap_reset(tile_t *tile)

The reset takes effect when the window closes. Waits for the reboot, clears the cached data, then starts re-applying the baseline and the stored surface (finish with surface_poll() or process()).

Returns SENSE_CAP_OK once the chip is back, or an error.

tile_sense_cap_get_version_major

Studio
uint16_t tile_sense_cap_get_version_major(tile_t *tile)

Firmware major version (cached at init).

Returns Major version from register 0x01

tile_sense_cap_get_version_minor

Studio
uint16_t tile_sense_cap_get_version_minor(tile_t *tile)

Firmware minor version (cached at init).

Returns Minor version from register 0x02

tile_sense_cap_get_settings_version

Studio
uint16_t tile_sense_cap_get_settings_version(tile_t *tile)

High byte settings major, low byte minor (§10.1.1). Live read.

Returns Raw 16-bit settings version, or 0 on failure

gapRDY / event-driven operationHW-gated (rev a): the IQS7211A's RDY (ball C3) is not routed, and tile pad 3 carries MCLR instead (the layout was drawn for the IQS7211E, whose A5 ball combines RDY and MCLR). The driver runs polled only: Comms Request mode with event mode on and every event source off, so the chip opens a window only when the host asks. Interrupt-driven wake on touch needs a board revision that routes RDY.
gapHardware reset from StudioDriver-deferred: the tile's pad 3 is the chip's MCLR (4.7k pull-up on the tile, chip pull-up 180-240k, Table 4.2). The platform layer has no GPIO write, so a C program passes cfg.mclr (drive low / release) and calls hw_reset() or sets cfg.reset_on_init; a Studio program cannot supply the pin yet, so hw_reset() returns SENSE_CAP_ERR_NO_CALLBACK there. Software reset (reset()) covers every case where the chip still answers I2C.

Runtime

tile_sense_cap_process

Studio
sense_cap_result_t tile_sense_cap_process(tile_t *tile)

Call from the main loop, ideally once per report period. One read attempt of 0x10-0x1B: when the window is not open yet it asks for one and returns SENSE_CAP_BUSY without waiting. After a good read it asks for the next window straight away (in the awake modes), so the next call usually lands. Runs the touch recognizers, fires callbacks and handles a chip reset. A Show Reset flag the chip will not clear costs one more capped transaction (a Config Settings check, or a re-ack once a second). While the baseline / surface job or an ATI runs it advances that instead (surface_poll(): one transaction, capped wait) and returns SENSE_CAP_BUSY until it finishes. Worst case per call: ~12 ms plus one I2C transaction at the 10 ms Active rate (window wait capped at 20 ms whatever the rates), except right after a chip reset (see the file header). SENSE_CAP_ERR_RESET (chip reset seen; re-applying), or an error.

Returns SENSE_CAP_OK (new data, or a job just finished), SENSE_CAP_BUSY,

tile_sense_cap_on_event

Studio
void tile_sense_cap_on_event(tile_t *tile, sense_cap_event_cb_t cb, void *ctx)

Register or change the event callback.

cb
Callback (NULL to disable)
ctx
User context passed to the callback

tile_sense_cap_get_touch_events

Studio
uint16_t tile_sense_cap_get_touch_events(tile_t *tile)

Read and clear the accumulated touch-event bits.

Returns Latched SENSE_CAP_EV_* bits since the previous call.

tile_sense_cap_was_tapped

Studio
uint8_t tile_sense_cap_was_tapped(tile_t *tile)

Did a tap (single or double) complete since the last check?

Returns 1 if a tap completed (consumes the tap bits), 0 otherwise.

tile_sense_cap_get_zone

Studio
int8_t tile_sense_cap_get_zone(tile_t *tile)

Which channel (zone) is under the first finger?

Returns Channel number (§5.1.1), or -1 with no finger or no surface.

tile_sense_cap_zone_at

Studio
int8_t tile_sense_cap_zone_at(tile_t *tile, uint16_t x, uint16_t y)

Electrode centres sit 256 points apart in chip units (§7.4), i.e. at k * res / (n - 1) in the configured resolution; the nearest centre on each axis wins, with Flip X/Y undone (§7.7). Use it in tap callbacks, where the finger has already lifted.

x
[0..65535] X position in the configured resolution
y
[0..65535] Y position in the configured resolution

Returns Channel number, or -1 without a surface.

tile_sense_cap_get_x_pct

Studio
int16_t tile_sense_cap_get_x_pct(tile_t *tile)

First finger's X as a percentage of the X range.

Returns 0-100 (truncated), or -1 with no finger.

tile_sense_cap_get_y_pct

Studio
int16_t tile_sense_cap_get_y_pct(tile_t *tile)

First finger's Y as a percentage of the Y range.

Returns 0-100 (truncated), or -1 with no finger or a one-row surface.

tile_sense_cap_wait_for_touch

Studio
uint8_t tile_sense_cap_wait_for_touch(tile_t *tile, uint32_t timeout_ms)

Runs process() every 5 ms. Real time comes from cfg.millis when given (otherwise the driver's own delay count).

timeout_ms
[0..600000] ms Maximum wait

Returns 1 on touch, 0 on timeout.

tile_sense_cap_get_info_flags

Studio
uint16_t tile_sense_cap_get_info_flags(tile_t *tile)

Cached Info Flags word (Table A.2).

Returns Info Flags (IQS7211A_INFO_* masks)

tile_sense_cap_get_gestures

Studio
uint16_t tile_sense_cap_get_gestures(tile_t *tile)

Only non-zero with the chip gesture engine selected; each bit lasts one report cycle.

Returns SENSE_CAP_GESTURE_* bits from the last read

tile_sense_cap_get_num_fingers

Studio
uint8_t tile_sense_cap_get_num_fingers(tile_t *tile)

Number of fingers on the trackpad (0, 1 or 2).

Returns Finger count from the cached Info Flags

tile_sense_cap_get_finger_x

Studio
uint16_t tile_sense_cap_get_finger_x(tile_t *tile, uint8_t finger)

Meaningful only while that slot holds a finger (gate on get_num_fingers); slots are stable while a finger stays down (§7.2.6). An empty slot reads 0xFFFF (observed on hardware); before the first successful process() read, and right after a chip reset, the cache reads 0.

finger
[0..1] Finger slot

Returns X in the configured resolution, 0xFFFF for an empty slot

tile_sense_cap_get_finger_y

Studio
uint16_t tile_sense_cap_get_finger_y(tile_t *tile, uint8_t finger)

An empty slot reads 0xFFFF, as for get_finger_x().

finger
[0..1] Finger slot

Returns Y in the configured resolution, 0xFFFF for an empty slot

tile_sense_cap_get_finger_strength

Studio
uint16_t tile_sense_cap_get_finger_strength(tile_t *tile, uint8_t finger)

Touch strength of a finger: the sum of its deltas (§7.2.4).

finger
[0..1] Finger slot

Returns Strength in counts (relative, scales with tuning)

tile_sense_cap_get_finger_area

Studio
uint16_t tile_sense_cap_get_finger_area(tile_t *tile, uint8_t finger)

Contact area of a finger, in channels (§7.2.5).

finger
[0..1] Finger slot

Returns Number of channels associated with the finger

tile_sense_cap_get_relative_x

Studio
int16_t tile_sense_cap_get_relative_x(tile_t *tile)

Relative X movement since the previous report (§7.2.2).

Returns Signed X delta in the configured resolution

tile_sense_cap_get_relative_y

Studio
int16_t tile_sense_cap_get_relative_y(tile_t *tile)

Relative Y movement since the previous report (§7.2.2).

Returns Signed Y delta in the configured resolution

tile_sense_cap_get_touch_status

Studio
uint32_t tile_sense_cap_get_touch_status(tile_t *tile)

Waits for one communication window (at most about one report period). The outputs of the BUTTONS_2X3 layout.

Returns Bit n set = channel n touched; 0 on failure

tile_sense_cap_is_touched

Studio
uint8_t tile_sense_cap_is_touched(tile_t *tile, uint8_t channel)

Does one channel report touch? (live read)

channel
[0..5] Channel number

Returns 1 if touched, 0 if not

tile_sense_cap_get_num_channels

Studio
uint8_t tile_sense_cap_get_num_channels(tile_t *tile)

Number of channels in the applied surface.

Returns n_rx * n_tx, or 0 without a surface.

tile_sense_cap_get_channel_count

Studio
uint16_t tile_sense_cap_get_channel_count(tile_t *tile, uint8_t channel)

One channel's raw count (extended map 0xE000, live read).

channel
[0..5] Channel number

Returns Count value, or 0 on failure / bad channel.

tile_sense_cap_get_channel_delta

Studio
int16_t tile_sense_cap_get_channel_delta(tile_t *tile, uint8_t channel)

One channel's signed delta, count minus reference (§5.3.4).

channel
[0..5] Channel number

Returns Delta value, or 0 on failure / bad channel.

tile_sense_cap_read_channel_counts

Studio
uint8_t tile_sense_cap_read_channel_counts(tile_t *tile, uint16_t *counts, uint8_t n)

The extended map auto-increments (§11.4.2), so one window serves the whole surface.

counts
Out: n counts
n
Channels to read, 1-32

Returns Channels read (n), or 0 on failure (counts untouched).

tile_sense_cap_read_channel_deltas

Studio
uint8_t tile_sense_cap_read_channel_deltas(tile_t *tile, int16_t *deltas, uint8_t n)

Read the first n signed channel deltas in one transaction.

deltas
Out: n deltas (count - reference, §5.3.4)
n
Channels to read, 1-32

Returns Channels read (n), or 0 on failure (deltas untouched).

tile_sense_cap_is_alp_active

Studio
uint8_t tile_sense_cap_is_alp_active(tile_t *tile)

Does the ALP channel report presence? (cached Info Flags)

Returns 1 if the ALP output bit is set

tile_sense_cap_get_alp_count

Studio
uint16_t tile_sense_cap_get_alp_count(tile_t *tile)

Raw ALP count (register 0x23, live read).

Returns ALP count, or 0 on failure

tile_sense_cap_get_alp_lta

Studio
uint16_t tile_sense_cap_get_alp_lta(tile_t *tile)

ALP long-term average (register 0x24, live read).

Returns ALP LTA, or 0 on failure

tile_sense_cap_get_mode

Studio
uint8_t tile_sense_cap_get_mode(tile_t *tile)

Current charging mode (cached Info Flags).

Returns sense_cap_mode_t value

tile_sense_cap_has_ati_error

Studio
uint8_t tile_sense_cap_has_ati_error(tile_t *tile)

The trackpad ATI error flag, plus the ALP one only while ALP wake is in use: the ALP ATI runs only in LP1/LP2 (§5.6.3), so its flag is stale otherwise.

Returns 1 if a relevant ATI error flag is set

Config

tile_sense_cap_set_sensitivity

Studio
uint8_t tile_sense_cap_set_sensitivity(tile_t *tile, sense_cap_sensitivity_t level)

NORMAL writes the surface's own set/clear multipliers; the other levels scale both by x2, x1.5, x0.75 or x0.5, keeping their ratio. Replaces a set_touch_multipliers() value, and is kept across set_layout().

level
Sensitivity level

Returns 1 if written and verified (or queued behind a running job)

tile_sense_cap_set_touch_multipliers

Studio
uint8_t tile_sense_cap_set_touch_multipliers(tile_t *tile, uint8_t set_mult, uint8_t clear_mult)

A channel reports touch when its count rises above Reference x (1 + set/128) and releases below Reference x (1 + clear/128). Smaller = more sensitive; clear below set gives hysteresis. Replaces the sensitivity level until the next set_sensitivity() or set_layout().

set_mult
[1..255] Touch-set multiplier
clear_mult
[0..255] Touch-clear multiplier (clamped to <= set)

Returns 1 if written and verified

tile_sense_cap_set_power_profile

Studio
uint8_t tile_sense_cap_set_power_profile(tile_t *tile, sense_cap_power_profile_t profile)

Report periods Active / Idle-touch / Idle / LP1 / LP2 (ms), and timeouts Active / Idle-touch / Idle / LP1 (s): - ALWAYS_ACTIVE: 10/10/10/10/10, timeouts never. - RESPONSIVE: 10/20/20/50/100, 10/30/20/60. - BALANCED: 10/50/50/100/200 (the Table 3.4 setup), 5/30/10/30. - LOW_POWER: 20/100/100/160/320, 2/20/3/10. The chip leaves Idle for LP1/LP2 only while ALP wake is on; otherwise the Idle timeout is written as 0 (never, §6.2), because only the ALP can wake it from there.

profile
Profile

Returns 1 if written and verified

tile_sense_cap_set_power_mode

Studio
uint8_t tile_sense_cap_set_power_mode(tile_t *tile, sense_cap_power_mode_t mode)

FORCE_LP1/FORCE_LP2 sense only the ALP and never wake on their own: poll is_alp_active() and switch back. Under manual control the chip does not update trackpad references (§5.4.1): call reseed() when needed.

mode
AUTO (init) or a forced mode

Returns 1 if written and verified

tile_sense_cap_set_active_rate

Studio
uint8_t tile_sense_cap_set_active_rate(tile_t *tile, uint16_t ms)

Overrides one field of the power profile. The coordinate report rate tops out at 100 Hz (§1.1).

ms
[10..1000] ms Report period in Active mode

Returns 1 if written and verified

tile_sense_cap_set_idle_timeout

Studio
uint8_t tile_sense_cap_set_idle_timeout(tile_t *tile, uint16_t seconds)

Overrides one field of the power profile. 0 = never leave Idle.

seconds
[0..3600] s Idle timeout

Returns 1 if written and verified

tile_sense_cap_set_report_rate

Studio
uint8_t tile_sense_cap_set_report_rate(tile_t *tile, sense_cap_mode_t mode, uint16_t ms)

Report period of one charging mode (§6.1).

mode
Which mode's period
ms
[1..65535] ms Report period

Returns 1 if written and verified

tile_sense_cap_set_mode_timeout

Studio
uint8_t tile_sense_cap_set_mode_timeout(tile_t *tile, sense_cap_mode_t mode, uint16_t seconds)

LP2 has no timeout. The Idle timeout is only written while ALP wake is on (see set_power_profile).

mode
Active, Idle-touch, Idle or LP1
seconds
[0..65535] s Timeout, 0 = never

Returns 1 if written and verified, 0 for LP2 or on failure

tile_sense_cap_set_alp_wake

Studio
uint8_t tile_sense_cap_set_alp_wake(tile_t *tile, uint8_t enable)

On: the Idle timeout of the power profile applies, ALP automatic re-ATI is enabled and the ALP counts in has_ati_error(); run ati_start(ALP) once so the ALP is tuned before relying on it. Off (init): the chip never times out of Idle, so it never goes deaf in LP with an untuned ALP. Needs a surface whose alp.enable is set.

enable
1 = allow ALP wake

Returns 1 if applied, 0 if the surface has no ALP or on failure

tile_sense_cap_set_alp_threshold

Studio
uint8_t tile_sense_cap_set_alp_threshold(tile_t *tile, uint16_t threshold)

The ALP output sets when the ALP count deviates from its LTA by more than this. Lower = wakes on lighter proximity.

threshold
[1..1000] Delta counts

Returns 1 if written and verified

tile_sense_cap_set_flip_x

Studio
uint8_t tile_sense_cap_set_flip_x(tile_t *tile, uint8_t enable)

Mirror X relative to the layout (§7.7).

enable
1 = mirror

Returns 1 if written and verified

tile_sense_cap_set_flip_y

Studio
uint8_t tile_sense_cap_set_flip_y(tile_t *tile, uint8_t enable)

Mirror Y relative to the layout (§7.7).

enable
1 = mirror

Returns 1 if written and verified

tile_sense_cap_set_switch_xy

Studio
uint8_t tile_sense_cap_set_switch_xy(tile_t *tile, uint8_t enable)

Channel numbering is unaffected (§7.7). A resolution set with set_resolution() stays with its axis name.

enable
1 = swap

Returns 1 if written and verified

tile_sense_cap_set_resolution

Studio
uint8_t tile_sense_cap_set_resolution(tile_t *tile, uint16_t x_res, uint16_t y_res)

0 = the layout's own (256 per electrode pitch). Gesture distances scale with the resolution.

x_res
[0..65535] X range, 0 = automatic
y_res
[0..65535] Y range, 0 = automatic

Returns 1 if written and verified

tile_sense_cap_set_tap_time

Studio
uint8_t tile_sense_cap_set_tap_time(tile_t *tile, uint16_t ms)

Used by both gesture engines: a touch released sooner, without moving beyond the tap distance, is a tap.

ms
[50..2000] ms Maximum tap duration

Returns 1 if written and verified

tile_sense_cap_set_hold_time

Studio
uint8_t tile_sense_cap_set_hold_time(tile_t *tile, uint16_t ms)

A long press fires at tap time + hold time from touch-down (600 ms with the defaults), in both gesture engines.

ms
[0..5000] ms Hold time after the tap time

Returns 1 if written and verified

tile_sense_cap_set_swipe_time

Studio
uint8_t tile_sense_cap_set_swipe_time(tile_t *tile, uint16_t ms)

Maximum swipe duration for the chip gesture engine (§8.3).

ms
[50..2000] ms Swipe must cover its distance within this

Returns 1 if written and verified

tile_sense_cap_set_swipe_distance

Studio
uint8_t tile_sense_cap_set_swipe_distance(tile_t *tile, uint16_t px)

0 = automatic: 48 px per 256 px of electrode pitch. The driver recognizer also needs a release faster than 400 px/s per 256 px pitch.

px
[0..65535] Pixels in the configured resolution, 0 = automatic

Returns 1 if written and verified

tile_sense_cap_set_swipe_angle

Studio
uint8_t tile_sense_cap_set_swipe_angle(tile_t *tile, uint8_t degrees)

Written as 64 * tan(angle) (register 0x87). 45 accepts every swipe along its dominant axis.

degrees
[1..75] deg Largest angle from the X or Y axis

Returns 1 if written and verified

tile_sense_cap_set_gesture_source

Studio
uint8_t tile_sense_cap_set_gesture_source(tile_t *tile, sense_cap_gesture_source_t source)

DRIVER (init): the driver's own tap / double tap / hold / swipe recognizers, and the chip's gesture engine is switched off so nothing fires twice. CHIP: the chip's engine (§8) with its gesture event enabled, so a gesture holds its window open until the host reads it. Double tap is paired by the driver either way; drag and pinch are always the driver's.

source
Gesture engine

Returns 1 if written and verified

tile_sense_cap_enable_gestures

Studio
uint8_t tile_sense_cap_enable_gestures(tile_t *tile, uint16_t mask)

Which gestures fire (either engine).

mask
[0..63] OR of SENSE_CAP_GESTURE_* bits (init: all)

Returns 1 if written and verified

tile_sense_cap_set_max_touches

Studio
uint8_t tile_sense_cap_set_max_touches(tile_t *tile, uint8_t fingers)

Maximum simultaneous fingers (§7.3).

fingers
[1..2] Fingers tracked

Returns 1 if written and verified

tile_sense_cap_set_reference_update

Studio
uint8_t tile_sense_cap_set_reference_update(tile_t *tile, uint16_t seconds)

Trackpad references refresh from LP1/LP2 under automatic mode control. The datasheet gives a 60 s maximum and does not say what 0 means.

seconds
[0..60] s Update interval

Returns 1 if written and verified

tile_sense_cap_set_i2c_timeout

Studio
uint8_t tile_sense_cap_set_i2c_timeout(tile_t *tile, uint16_t ms)

How long a requested window waits for the host before the chip moves on (the chip pauses while it waits). Init: 50 ms. Poll process() faster than report period + this, or reads alternate with BUSY.

ms
[2..1000] ms Window timeout

Returns 1 if written and verified

tile_sense_cap_set_watchdog

Studio
uint8_t tile_sense_cap_set_watchdog(tile_t *tile, uint8_t enable)

Enable or disable the chip's watchdog (§10.2). Init: enabled.

enable
1 = enable

Returns 1 if written and verified

tile_sense_cap_reseed

Studio
uint8_t tile_sense_cap_reseed(tile_t *tile)

Reseed the trackpad references and the ALP LTA (§5.4.3).

Returns 1 if the command was sent

gapElectrodes beyond the routed fiveHW-gated: RX0-RX2, RX4, RX5, RX7 and TX10 are not routed to pads, so the largest surface is 2 Rx x 3 Tx (6 channels) or 1 Rx x 4 Tx with RX6 as a Tx. surface_begin() rejects any other pin.

Advanced

tile_sense_cap_read_reg

Studio
uint16_t tile_sense_cap_read_reg(tile_t *tile, uint8_t reg)

Read a raw 16-bit register (waits for a window).

reg
[0..255] Register address

Returns Register value, or 0xEEEE if no window opened

tile_sense_cap_write_reg

Studio
sense_cap_result_t tile_sense_cap_write_reg(tile_t *tile, uint8_t reg, uint16_t value)

Refuses the Tx short test (0x50 bit 15), RX0/TX0 or TX10 in the ALP masks (0x72/0x73) or the Rx/Tx map (0x90-0x95), and the value 0xEEEE. A write to 0x51 updates the driver's comms settings. Not re-applied after a chip reset, and a later driver call may overwrite it. 0x50 is sent as a command without read-back.

reg
[0..255] Register address
value
[0..65535] Value

Returns SENSE_CAP_OK, SENSE_CAP_ERR_FORBIDDEN, or a comms/verify error

gap18 MHz main oscillatorDriver policy: the baseline locks the main oscillator to 14 MHz (Other Settings bit 4 = 0). 18 MHz needs VDD >= 2.2 V (Table 3.2) and the tile runs from 1.8-3.3 V, which the driver cannot measure. Main Osc Adj and the calibration capacitor (the rest of 0x52) are left as the chip has them.
gapTx short testForbidden, HW-gated: RX0/TX0 (ball F4) is tied to GND on this layout, so the Tx short-test configuration (System Control bit 15, Table A.6) would drive a transmitter into ground. The driver never sets it, and write_reg refuses it, along with RX0/TX0 or TX10 in the ALP masks or the Rx/Tx map.
gapAnalog front-end settingsDriver-deferred: charge-transfer frequency (0x58/0x59, Table A.9), Max Count, projected opamp bias, pool capacitor, NM-in-static, Cs discharge and init delay (0x5A/0x5B, Table A.10) stay at chip values. They are GUI-derived settings for a particular stack-up (§9: "only adjusted under guidance of Azoteq"). The driver only sets the RF filter bit in 0x5A and 0x5B and, when asked, the ALP auto-prox cycles. write_reg reaches the rest.
gapTouch-status and XY event sourcesDriver policy: with no RDY line, an event window would stall the chip for the whole I2C timeout while nobody services it, so the gesture event is the only source the driver ever enables (and only with the chip gesture engine selected). Touch-status (0x20/0x21) is read live, not cached by process().
gapOTP settings programmingOut of scope: programming a settings image into the part (Azoteq GUI export, §10.1.1). A pre-programmed part is supported: set cfg.skip_baseline and read get_settings_version().

Other

tile_sense_cap_layout_preset

sense_cap_result_t tile_sense_cap_layout_preset(sense_cap_layout_t layout, sense_cap_surface_t *out)

For customising a preset before surface_begin(). SENSE_CAP_LAYOUT_NONE gives the routed 2x3 geometry with every channel disabled.

layout
Preset
out
Filled with the preset

Returns SENSE_CAP_OK, or SENSE_CAP_ERR_ARG for an unknown layout.

tile_sense_cap_surface_begin

sense_cap_result_t tile_sense_cap_surface_begin(tile_t *tile, const sense_cap_surface_t *surf)

Checks the tile rules (routed pins only; never RX0/TX0 or TX10; no pin both Rx and Tx; ALP masks on routed pins; tuning ranges), copies the surface and starts the apply job: register sync (only registers that differ are written, cycles cleared before a geometry change), then trackpad ATI, then ALP ATI if ALP wake is on. Non-blocking: advance it with surface_poll() or process() until is_surface_ready(). Replaces a job still running (the baseline from init included; the new job carries the whole register image). The copy is re-applied after any chip reset.

tile
Initialised tile handle
surf
Surface description

Returns SENSE_CAP_OK when accepted, or the validation error.

tile_sense_cap_configure_surface

sense_cap_result_t tile_sense_cap_configure_surface(tile_t *tile, const sense_cap_surface_t *surf)

surface_begin() plus surface_poll() until done, bounded by 20 s of real time. Also finishes a baseline still pending from init().

tile
Initialised tile handle
surf
Surface description

Returns SENSE_CAP_OK when applied and ATI converged; otherwise the error.

tile_sense_cap_on_touch

void tile_sense_cap_on_touch(tile_t *tile, sense_cap_touch_cb_t cb, void *ctx)

Register the raw touch-event stream callback (DOWN/MOVED/UP).

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_next_touch_event

uint8_t tile_sense_cap_next_touch_event(tile_t *tile, sense_cap_touch_t *ev)

Pop the oldest queued touch event (8-deep ring, oldest dropped).

tile
Tile handle
ev
Filled with the event when one was available

Returns 1 if an event was returned, 0 if the queue is empty.

tile_sense_cap_on_tap

void tile_sense_cap_on_tap(tile_t *tile, sense_cap_tap_cb_t cb, void *ctx)

Register the tap callback (single and double).

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_on_long_press

void tile_sense_cap_on_long_press(tile_t *tile, sense_cap_hold_cb_t cb, void *ctx)

Register the long-press callback.

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_on_swipe

void tile_sense_cap_on_swipe(tile_t *tile, sense_cap_swipe_cb_t cb, void *ctx)

Register the swipe callback.

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_on_drag

void tile_sense_cap_on_drag(tile_t *tile, sense_cap_drag_cb_t cb, void *ctx)

Register the drag (pan) callback.

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_on_pinch

void tile_sense_cap_on_pinch(tile_t *tile, sense_cap_pinch_cb_t cb, void *ctx)

Register the two-finger pinch callback.

tile
Tile handle
cb
Callback (NULL to disable)
ctx
User context

tile_sense_cap_read_channels

uint8_t tile_sense_cap_read_channels(tile_t *tile, uint16_t *counts, int16_t *deltas, uint8_t n)

Counts and deltas together (two windows). C only.

tile
Tile handle
counts
Out: n counts, or NULL to skip
deltas
Out: n signed deltas, or NULL to skip
n
Channels to read, 1-32

Returns 1 if every requested block came back valid, 0 otherwise.

Events

touch_down
touch_up
tap
double_tap
long_press
swipe
drag
reset

Enums

sense_cap_result_t

Result of a lifecycle call, a surface/ATI step or a guarded write.

SENSE_CAP_OK
Done
SENSE_CAP_BUSY
In progress; call the poll function again
SENSE_CAP_ERR_STATE
Tile not initialised, or another job is running
SENSE_CAP_ERR_ARG
Argument out of range
SENSE_CAP_ERR_PIN
Electrode not routed on this tile
SENSE_CAP_ERR_FORBIDDEN
RX0/TX0, TX10 or the Tx short test
SENSE_CAP_ERR_GEOMETRY
Duplicate electrode or impossible surface
SENSE_CAP_ERR_COMMS
No communication window within the budget
SENSE_CAP_ERR_VERIFY
A register read back differently
SENSE_CAP_ERR_ATI
ATI did not converge
SENSE_CAP_ERR_TIMEOUT
Real-time budget exceeded
SENSE_CAP_ERR_RESET
The chip reset mid-operation (it is being re-applied)
SENSE_CAP_ERR_NO_CALLBACK
hw_reset() without a cfg.mclr callback
SENSE_CAP_ERR_NOT_FOUND
No IQS7211A answered

sense_cap_layout_t

Electrode layout presets, all physically valid on the routed pins.

SENSE_CAP_LAYOUT_NONE
No surface: nothing sensed
SENSE_CAP_LAYOUT_GRID_2X3
2x3 trackpad (bench-tuned)
SENSE_CAP_LAYOUT_BUTTONS_2X3
2x3 as six buttons
SENSE_CAP_LAYOUT_SLIDER_1X3
3-segment slider on RX3
SENSE_CAP_LAYOUT_SLIDER_1X4
4-segment slider, RX6 as Tx

sense_cap_sensitivity_t

Touch sensitivity, relative to the surface's tuned multipliers.

SENSE_CAP_SENS_LOWEST
Firm touches only (multipliers x2)
SENSE_CAP_SENS_LOW
Less sensitive (x1.5)
SENSE_CAP_SENS_NORMAL
As tuned for the surface
SENSE_CAP_SENS_HIGH
More sensitive (x0.75)
SENSE_CAP_SENS_HIGHEST
Light touches (x0.5)

sense_cap_mode_t

Charging (power) mode, as reported in Info Flags (Table A.2).

SENSE_CAP_MODE_ACTIVE
Active
SENSE_CAP_MODE_IDLE_TOUCH
Idle-touch
SENSE_CAP_MODE_IDLE
Idle
SENSE_CAP_MODE_LP1
Low power 1
SENSE_CAP_MODE_LP2
Low power 2

sense_cap_power_mode_t

Who switches the chip's power modes (§6.3).

SENSE_CAP_POWER_AUTO
Chip switches modes itself
SENSE_CAP_POWER_FORCE_ACTIVE
Held in Active (manual control)
SENSE_CAP_POWER_FORCE_LP1
Held in LP1: ALP only
SENSE_CAP_POWER_FORCE_LP2
Held in LP2: ALP only

sense_cap_power_profile_t

Report-rate and timeout bundles for the automatic power modes.

SENSE_CAP_POWER_ALWAYS_ACTIVE
Always active (10 ms in every mode)
SENSE_CAP_POWER_RESPONSIVE
Responsive
SENSE_CAP_POWER_BALANCED
Balanced
SENSE_CAP_POWER_LOW_POWER
Low power

sense_cap_gesture_source_t

Which engine recognizes tap / hold / swipe.

SENSE_CAP_GESTURES_DRIVER
Driver recognizers
SENSE_CAP_GESTURES_CHIP
Chip gesture engine

sense_cap_ati_target_t

What ati_start() tunes.

SENSE_CAP_ATI_TRACKPAD
Trackpad channels
SENSE_CAP_ATI_ALP
ALP wake channel (runs in LP1)
SENSE_CAP_ATI_BOTH
Trackpad, then ALP

sense_cap_auto_prox_t

ALP auto-prox cycles per low-power report (0x5B, Table A.10).

SENSE_CAP_AUTOPROX_KEEP
Leave the chip's setting
SENSE_CAP_AUTOPROX_4
4 cycles
SENSE_CAP_AUTOPROX_8
8 cycles
SENSE_CAP_AUTOPROX_16
16 cycles
SENSE_CAP_AUTOPROX_32
32 cycles
SENSE_CAP_AUTOPROX_OFF
Auto-prox disabled

sense_cap_finger_t

Finger slot for the absolute-XY getters.

SENSE_CAP_FINGER_1
First tracked finger
SENSE_CAP_FINGER_2
Second tracked finger

sense_cap_phase_t

Phase of a touch event, iOS/Android style.

SENSE_CAP_TOUCH_DOWN
Finger arrived
SENSE_CAP_TOUCH_MOVED
Position changed while down
SENSE_CAP_TOUCH_UP
Finger left

Constants

TILE_SENSE_CAP_VERSION_MAJOR1
TILE_SENSE_CAP_VERSION_MINOR0
TILE_SENSE_CAP_VERSION_PATCH0
IQS7211A_I2C_ADDR0x56
IQS7211A_PRODUCT_NUMBER763
IQS7211A_INVALID_RESPONSE0xEEEE
IQS7211A_CYCLE_PROX_BYTE0x05Fixed first byte of every cycle record
IQS7211A_CHANNEL_NONE0xFF"No channel allocated" (§7.1.2)
IQS7211A_INFO_MODE_SHIFT0
IQS7211A_INFO_NUM_FINGERS_SHIFT8
SENSE_CAP_GESTURE_ALL0x3F
IQS7211A_CTRL_MODE_SHIFT0
IQS7211A_HW_LP2_AUTOPROX_SHIFT50x5B bits 7-5
IQS7211A_HW_LP1_AUTOPROX_SHIFT20x5B bits 4-2
SENSE_CAP_PIN_RX33Tile pad 2, prox block A; RX3/TX3 pin, usable as Tx
SENSE_CAP_PIN_RX66Tile pad 9, prox block B; RX6/TX6 pin, usable as Tx
SENSE_CAP_PIN_TX88Tile pad 8
SENSE_CAP_PIN_TX99Tile pad 7 (ball A1, bonded to TX10: only TX9 is used)
SENSE_CAP_PIN_TX1111Tile pad 6
SENSE_CAP_MAX_RX2Routed Rx pins
SENSE_CAP_MAX_TX4Routed Tx pins when one Rx pin acts as a Tx
SENSE_CAP_MAX_CHANNELS6Largest surface: 2 Rx x 3 Tx
SENSE_CAP_NUM_FINGERS2Finger slots (§7.3)
SENSE_CAP_DIR_LEFT0Toward -X
SENSE_CAP_DIR_RIGHT1Toward +X
SENSE_CAP_DIR_UP2Toward -Y
SENSE_CAP_DIR_DOWN3Toward +Y