1device_driver::create_device!(
2 device_name: Registers,
3 dsl: {
4 config {
5 type RegisterAddressType = u8;
6 type DefaultByteOrder = LE;
7 }
8
9 #[cfg(feature = "movement-ui")]
10 register Version {
11 type Access = ReadOnly;
12 const ADDRESS = 0;
13 const SIZE_BITS = 48;
14 const RESET_VALUE = [0xb6, 0x05, 0x01, 0x00, 0x04, 0x00];
15 const ALLOW_ADDRESS_OVERLAP = true;
16
17 product_number: uint = 0..16,
18 major_version: uint = 16..32,
19 minor_version: uint = 32..48,
20 },
21 #[cfg(not(feature = "movement-ui"))]
22 register Version {
23 type Access = ReadOnly;
24 const ADDRESS = 0;
25 const SIZE_BITS = 48;
26 const RESET_VALUE = [0x52, 0x04, 0x01, 0x00, 0x03, 0x00];
27 const ALLOW_ADDRESS_OVERLAP = true;
28
29 product_number: uint = 0..16,
30 major_version: uint = 16..32,
31 minor_version: uint = 32..48,
32 },
33 block SysInfo {
34 register SystemStatus {
35 type Access = ReadOnly;
36 const ADDRESS = 0x10;
37 const SIZE_BITS = 16;
38
39 prox_event: bool = 0,
40 touch_event: bool = 1,
41 slider_event: bool = 2,
42 power_event: bool = 3,
43 ati_event: bool = 4,
44 ati_active: bool = 5,
45 ati_error: bool = 6,
46 reset_event: bool = 7,
47 ch0_prox_event: bool = 8,
48 ch0_touch_event: bool = 9,
49 ch1_prox_event: bool = 10,
50 ch1_touch_event: bool = 11,
51 ch2_prox_event: bool = 12,
52 ch2_touch_event: bool = 13,
53 current_power_mode: uint as enum PowerModeStatus {
54 Normal = default,
55 Low = 1,
56 UltraLow = 2,
57 Halt = 3,
58 } = 14..16,
59 },
60 register Gestures {
61 type Access = ReadOnly;
62 const ADDRESS = 0x11;
63 const SIZE_BITS = 16;
64
65 tap: bool = 0,
66 swipe_positive: bool = 1,
67 swipe_negative: bool = 2,
68 flick_positive: bool = 3,
69 flick_negative: bool = 4,
70 hold: bool = 5,
71 event: bool = 6,
72 busy: bool = 7,
73 },
74 register SliderPosition {
75 type Access = ReadOnly;
76 const ADDRESS = 0x12;
77 const SIZE_BITS = 16;
78
79 value: uint = 0..16,
80 },
81 register Ch0FilteredCounts {
82 type Access = ReadOnly;
83 const ADDRESS = 0x13;
84 const SIZE_BITS = 16;
85
86 value: uint = 0..16,
87 },
88 register Ch0Lta {
89 type Access = ReadOnly;
90 const ADDRESS = 0x14;
91 const SIZE_BITS = 16;
92
93 value: uint = 0..16,
94 },
95 register Ch1FilteredCounts {
96 type Access = ReadOnly;
97 const ADDRESS = 0x15;
98 const SIZE_BITS = 16;
99
100 value: uint = 0..16,
101 },
102 register Ch1Lta {
103 type Access = ReadOnly;
104 const ADDRESS = 0x16;
105 const SIZE_BITS = 16;
106
107 value: uint = 0..16,
108 },
109 register Ch2FilteredCounts {
110 type Access = ReadOnly;
111 const ADDRESS = 0x17;
112 const SIZE_BITS = 16;
113
114 value: uint = 0..16,
115 },
116 register Ch2Lta {
117 type Access = ReadOnly;
118 const ADDRESS = 0x18;
119 const SIZE_BITS = 16;
120
121 value: uint = 0..16,
122 },
123 },
124 #[cfg(not(feature = "movement-ui"))]
125 block ReleaseUi {
126 register Ch0ActivationLta {
127 type Access = ReadOnly;
128 const ADDRESS = 0x20;
129 const SIZE_BITS = 16;
130 const ALLOW_ADDRESS_OVERLAP = true;
131
132 value: uint = 0..16,
133 },
134 register Ch1ActivationLta {
135 type Access = ReadOnly;
136 const ADDRESS = 0x21;
137 const SIZE_BITS = 16;
138 const ALLOW_ADDRESS_OVERLAP = true;
139
140 value: uint = 0..16,
141 },
142 register Ch2ActivationLta {
143 type Access = ReadOnly;
144 const ADDRESS = 0x22;
145 const SIZE_BITS = 16;
146 const ALLOW_ADDRESS_OVERLAP = true;
147
148 value: uint = 0..16,
149 },
150 register Ch0DeltaSnapshot {
151 type Access = ReadOnly;
152 const ADDRESS = 0x23;
153 const SIZE_BITS = 16;
154 const ALLOW_ADDRESS_OVERLAP = true;
155
156 value: uint = 0..16,
157 },
158 register Ch1DeltaSnapshot {
159 type Access = ReadOnly;
160 const ADDRESS = 0x24;
161 const SIZE_BITS = 16;
162 const ALLOW_ADDRESS_OVERLAP = true;
163
164 value: uint = 0..16,
165 },
166 register Ch2DeltaSnapshot {
167 type Access = ReadOnly;
168 const ADDRESS = 0x25;
169 const SIZE_BITS = 16;
170 const ALLOW_ADDRESS_OVERLAP = true;
171
172 value: uint = 0..16,
173 },
174 },
175 #[cfg(feature = "movement-ui")]
176 block MovementUi {
177 register Ch0MovementLta {
178 type Access = ReadOnly;
179 const ADDRESS = 0x20;
180 const SIZE_BITS = 16;
181 const ALLOW_ADDRESS_OVERLAP = true;
182
183 value: uint = 0..16,
184 },
185 register Ch1MovementLta {
186 type Access = ReadOnly;
187 const ADDRESS = 0x21;
188 const SIZE_BITS = 16;
189 const ALLOW_ADDRESS_OVERLAP = true;
190
191 value: uint = 0..16,
192 },
193 register Ch2MovementLta {
194 type Access = ReadOnly;
195 const ADDRESS = 0x22;
196 const SIZE_BITS = 16;
197 const ALLOW_ADDRESS_OVERLAP = true;
198
199 value: uint = 0..16,
200 },
201 register MovementStatus {
202 type Access = ReadOnly;
203 const ADDRESS = 0x23;
204 const SIZE_BITS = 16;
205 const ALLOW_ADDRESS_OVERLAP = true;
206
207 ch0_movement: bool = 0,
208 ch1_movement: bool = 1,
209 ch2_movement: bool = 2,
210 },
211 },
212 block Sensor {
213 const ADDRESS_OFFSET = 0x30;
214 const REPEAT = { count: 3, stride: 0x10 };
215
216 register SensorSetup {
217 type Access = ReadWrite;
218 const ADDRESS = 0x00;
219 const SIZE_BITS = 16;
220
221 cal_cap_rx_selected: bool = 14,
222 cal_cap_tx_selected: bool = 13,
223 txa_enabled: bool = 11,
224 ctx2_enabled: bool = 10,
225 ctx1_enabled: bool = 9,
226 ctx0_enabled: bool = 8,
227 ui_enabled: bool = 6,
228 fosc_tx_freq_14mhz: bool = 5,
229 vbias_on_cx2: bool = 4,
230 invert_channel_logic: bool = 3,
231 dual_direction_thresholds: bool = 2,
232 linearise_counts: bool = 1,
233 channel_enabled: bool = 0,
234 },
235 register ConversionFrequency {
236 type Access = ReadWrite;
237 const ADDRESS = 0x01;
238 const SIZE_BITS = 16;
239 const RESET_VALUE = 0x007f;
240
241 period: uint = 8..16,
242 frac: uint = 0..8,
243 },
244 register ProxControl {
245 type Access = ReadWrite;
246 const ADDRESS = 0x02;
247 const SIZE_BITS = 16;
248
249 discharge_0v5_enabled: bool = 14,
250 cs_size: uint as enum CsCapacitorSize {
252 Cs40pF,
253 Cs80pF = default,
254 } = 12..13,
255 sh_bias_Select: uint as enum SampleHoldBiasSelect {
256 Bias2uA,
257 Bias5uA,
258 Bias7uA,
259 Bias10uA = default,
260 } = 8..10,
261 max_counts: uint as enum MaxCounts {
262 Max1023,
263 Max2047,
264 Max4095,
265 Max16383 = default,
266 } = 6..8,
267 pxs_mode: uint as try enum PxsMode {
268 SelfCapacitance = 0x10,
269 MutualCapacitance = 0x13,
270 CurrentMeasurement = 0x1d,
271 Inductive = 0x3d,
272 } = 0..6,
273 },
274 register ProxInput {
275 type Access = ReadWrite;
276 const ADDRESS = 0x03;
277 const SIZE_BITS = 16;
278 const RESET_VALUE = 0x0083;
279
280 internal_reference_enabled: bool = 13,
281 prox_engine_bias_current_enabled: bool = 12,
282 calibration_capacitor_enabled: bool = 11,
283 crx2_enabled: bool = 10,
284 crx1_enabled: bool = 9,
285 crx0_enabled: bool = 8,
286 dead_time_enabled: bool = 6,
287 auto_prox_cycle: uint as enum AutoProxCycleCount {
288 Cycles4 = default,
289 Cycles8,
290 Cycles16,
291 Cycles32,
292 } = 2..4,
293 },
294 register PatternDefinitions {
295 type Access = ReadWrite;
296 const ADDRESS = 0x04;
297 const SIZE_BITS = 16;
298
299 wav_pattern_1: uint = 12..16,
300 wav_pattern_0: uint = 8..12,
301 calibration_cap: uint = 4..8,
302 inactive_rxs: uint as try enum InactiveCxState {
303 Floating = 0x00,
304 BiasVolatage = 0x05,
305 Vss = 0x0a,
306 Vreg = 0x0f,
307 } = 0..4,
308 },
309 register PatternSelectionAndEngineBiasCurrent {
310 type Access = ReadWrite;
311 const ADDRESS = 0x05;
312 const SIZE_BITS = 16;
313
314 engine_bias_current: int = 12..16,
315 engine_bias_current_trim: int = 8..12,
316 wav_pattern_select: uint = 0..8,
317 },
318 register AtiSetup {
319 type Access = ReadWrite;
320 const ADDRESS = 0x06;
321 const SIZE_BITS = 16;
322
323 resolution_factor: uint = 4..16,
324 band: uint as enum AtiBand {
325 Small = default,
326 Large,
327 } = 3..4,
328 mode: uint as try enum AtiMode {
329 Disabled = default,
330 CompensationOnly,
331 FromCompensationDivider,
332 FromFineFractionalDivider,
333 Full = 4,
334 } = 0..3,
335 },
336 register AtiBase {
337 type Access = ReadWrite;
338 const ADDRESS = 0x07;
339 const SIZE_BITS = 16;
340
341 value: uint = 0..16,
342 },
343 register AtiMultipliers {
344 type Access = ReadWrite;
345 const ADDRESS = 0x08;
346 const SIZE_BITS = 16;
347
348 fine_fractional_multiplier: uint = 14..16,
349 fine_fractional_divider: uint = 9..14,
350 coarse_fractional_multiplier: uint = 5..9,
351 coarse_fractional_divider: uint = 0..5,
352 },
353 register Compensation {
354 type Access = ReadWrite;
355 const ADDRESS = 0x09;
356 const SIZE_BITS = 16;
357
358 divider: uint = 11..16,
359 value: uint = 0..10,
360 },
361 },
362 block Channel {
363 const ADDRESS_OFFSET = 0x60;
364 const REPEAT = { count: 3, stride: 0x10 };
365
366 register ChannelSetup {
367 type Access = ReadWrite;
368 const ADDRESS = 0x00;
369 const SIZE_BITS = 16;
370
371 follower_event_mask: uint = 8..16,
372 reference_sensor_id: uint = 4..8,
373 channel_mode: uint as try enum ChannelMode {
374 Independent,
375 Follower,
376 Reference,
377 } = 0..4,
378 },
379 register ProxSettings {
380 type Access = ReadWrite;
381 const ADDRESS = 0x01;
382 const SIZE_BITS = 16;
383
384 debounce_exit: uint = 12..16,
385 debounce_enter: uint = 8..12,
386 threshold: uint = 0..8,
387 },
388 register TouchSettings {
389 type Access = ReadWrite;
390 const ADDRESS = 0x02;
391 const SIZE_BITS = 16;
392
393 hysteresis: uint = 12..16,
394 threshold: uint = 0..8,
395 },
396 register FollowerWeight {
397 type Access = ReadWrite;
398 const ADDRESS = 0x03;
399 const SIZE_BITS = 16;
400
401 value: uint = 0..16,
402 },
403 #[cfg(feature = "movement-ui")]
404 register MovementUiSettings {
405 type Access = ReadWrite;
406 const ADDRESS = 0x04;
407 const SIZE_BITS = 16;
408
409 debounce_exit: uint = 12..16,
410 debounce_enter: uint = 8..12,
411 threshold: uint = 0..8,
412 },
413 },
414 block SliderConfig {
415 register SliderSetup {
416 type Access = ReadWrite;
417 const ADDRESS = 0x90;
418 const SIZE_BITS = 16;
419
420 lower_calibration_value: uint = 8..16,
421 static_filter: uint as enum SliderStaticFilter {
422 Dynamic = default,
423 SlowStaticBeta,
424 } = 6..7,
425 slow_static_beta: uint = 3..6,
426 total_channels: uint = 0..3,
427 },
428 register SliderBottomSpeed {
429 type Access = ReadWrite;
430 const ADDRESS = 0x91;
431 const SIZE_BITS = 16;
432
433 bottom_speed: uint = 8..16,
434 upper_calibration_value: uint = 0..8,
435 },
436 register SliderTopSpeed {
437 type Access = ReadWrite;
438 const ADDRESS = 0x92;
439 const SIZE_BITS = 16;
440
441 value: uint = 0..16,
442 },
443 register SliderResolution {
444 type Access = ReadWrite;
445 const ADDRESS = 0x93;
446 const SIZE_BITS = 16;
447
448 value: uint = 0..16,
449 },
450 register SliderEnableMask {
451 type Access = ReadWrite;
452 const ADDRESS = 0x94;
453 const SIZE_BITS = 16;
454
455 ch2_enabled: bool = 2,
456 ch1_enabled: bool = 1,
457 ch0_enabled: bool = 0,
458 },
459 register DeltaLink0 {
460 type Access = ReadWrite;
461 const ADDRESS = 0x96;
462 const SIZE_BITS = 16;
463
464 value: uint as try DeltaLinkChannel = 0..16,
465 },
466 register DeltaLink1 {
467 type Access = ReadWrite;
468 const ADDRESS = 0x97;
469 const SIZE_BITS = 16;
470
471 value: uint as try DeltaLinkChannel = 0..16,
472 },
473 register DeltaLink2 {
474 type Access = ReadWrite;
475 const ADDRESS = 0x98;
476 const SIZE_BITS = 16;
477
478 value: uint as try DeltaLinkChannel = 0..16,
479 },
480 #[cfg(not(feature = "movement-ui"))]
481 register SliderEnableStatusPointer {
482 type Access = ReadWrite;
483 const ADDRESS = 0x95;
484 const SIZE_BITS = 16;
485 const RESET_VALUE = 0x0558;
486 const ALLOW_ADDRESS_OVERLAP = true;
487
488 value: uint = 0..16,
489 },
490 #[cfg(feature = "movement-ui")]
491 register SliderEnableStatusPointer {
492 type Access = ReadWrite;
493 const ADDRESS = 0x95;
494 const SIZE_BITS = 16;
495 const RESET_VALUE = 0x0552;
496 const ALLOW_ADDRESS_OVERLAP = true;
497
498 value: uint = 0..16,
499 },
500 },
501 block GestureConfig {
502 register GestureEnable {
503 type Access = ReadWrite;
504 const ADDRESS = 0xa0;
505 const SIZE_BITS = 16;
506
507 hold_enabled: bool = 3,
508 flick_enabled: bool = 2,
509 swipe_enabled: bool = 1,
510 tap_enabled: bool = 0,
511 },
512 register MinimumGestureTime {
513 type Access = ReadWrite;
514 const ADDRESS = 0xa1;
515 const SIZE_BITS = 16;
516
517 ms: uint = 0..16,
518 },
519 register MaximumTapTime {
520 type Access = ReadWrite;
521 const ADDRESS = 0xa2;
522 const SIZE_BITS = 16;
523
524 ms: uint = 0..16,
525 },
526 register MaximumSwipeTime {
527 type Access = ReadWrite;
528 const ADDRESS = 0xa3;
529 const SIZE_BITS = 16;
530
531 ms: uint = 0..16,
532 },
533 register MinimumHoldTime {
534 type Access = ReadWrite;
535 const ADDRESS = 0xa4;
536 const SIZE_BITS = 16;
537
538 ms: uint = 0..16,
539 },
540 register MaximumTapDistance {
541 type Access = ReadWrite;
542 const ADDRESS = 0xa5;
543 const SIZE_BITS = 16;
544
545 value: uint = 0..16,
546 },
547 register MinimumSwipeDistance {
548 type Access = ReadWrite;
549 const ADDRESS = 0xa6;
550 const SIZE_BITS = 16;
551
552 value: uint = 0..16,
553 },
554 },
555 block FilterBetas {
556 register Counts {
557 type Access = ReadWrite;
558 const ADDRESS = 0xb0;
559 const SIZE_BITS = 16;
560
561 low_power: uint = 8..16,
562 normal_power: uint = 0..8,
563 },
564 register Lta {
565 type Access = ReadWrite;
566 const ADDRESS = 0xb1;
567 const SIZE_BITS = 16;
568
569 low_power: uint = 8..16,
570 normal_power: uint = 0..8,
571 },
572 register LtaFast {
573 type Access = ReadWrite;
574 const ADDRESS = 0xb2;
575 const SIZE_BITS = 16;
576
577 low_power: uint = 8..16,
578 normal_power: uint = 0..8,
579 },
580 register FastFilterBand {
581 type Access = ReadWrite;
582 const ADDRESS = 0xb4;
583 const SIZE_BITS = 16;
584
585 value: uint = 0..16,
586 },
587 #[cfg(not(feature = "movement-ui"))]
588 register ActivationLta {
589 type Access = ReadWrite;
590 const ADDRESS = 0xb3;
591 const SIZE_BITS = 16;
592 const ALLOW_ADDRESS_OVERLAP = true;
593
594 low_power: uint = 8..16,
595 normal_power: uint = 0..8,
596 },
597 #[cfg(feature = "movement-ui")]
598 register MovementLta {
599 type Access = ReadWrite;
600 const ADDRESS = 0xb3;
601 const SIZE_BITS = 16;
602 const ALLOW_ADDRESS_OVERLAP = true;
603
604 low_power: uint = 8..16,
605 normal_power: uint = 0..8,
606 },
607 },
608 block SysControl {
609 register Control {
610 type Access = ReadWrite;
611 const ADDRESS = 0xc0;
612 const SIZE_BITS = 16;
613
614 ch2_timeout_disabled: bool = 10,
615 ch1_timeout_disabled: bool = 9,
616 ch0_timeout_disabled: bool = 8,
617 interface: uint as enum InterfaceSelection {
618 I2cStreaming = default,
619 I2cEvents,
620 } = 7..8,
621 power_mode: uint as try enum PowerMode {
622 Normal,
623 Low,
624 UltraLow,
625 Halt,
626 Automatic,
627 AutomaticNoUlp,
628 } = 4..7,
629 trigger_reseed: bool = 3,
630 trigger_ati: bool = 2,
631 trigger_soft_reset: bool = 1,
632 ack_reset: bool = 0,
633 },
634 register NormalPowerReportRate {
635 type Access = ReadWrite;
636 const ADDRESS = 0xc1;
637 const SIZE_BITS = 16;
638
639 ms: uint = 0..16,
640 },
641 register LowPowerReportRate {
642 type Access = ReadWrite;
643 const ADDRESS = 0xc2;
644 const SIZE_BITS = 16;
645
646 ms: uint = 0..16,
647 },
648 register UltraLowPowerReportRate {
649 type Access = ReadWrite;
650 const ADDRESS = 0xc3;
651 const SIZE_BITS = 16;
652
653 ms: uint = 0..16,
654 },
655 register HaltReportRate {
656 type Access = ReadWrite;
657 const ADDRESS = 0xc4;
658 const SIZE_BITS = 16;
659
660 ms: uint = 0..16,
661 },
662 register PowerModeTimeout {
663 type Access = ReadWrite;
664 const ADDRESS = 0xc5;
665 const SIZE_BITS = 16;
666
667 ms: uint = 0..16,
668 },
669 },
670 block General {
671 register OutAMask {
672 type Access = ReadWrite;
673 const ADDRESS = 0xd0;
674 const SIZE_BITS = 16;
675
676 value: uint = 0..16,
677 },
678 register TransactionTimeout {
679 type Access = ReadWrite;
680 const ADDRESS = 0xd1;
681 const SIZE_BITS = 16;
682
683 ms: uint = 0..16,
684 },
685 register EventTimeouts {
686 type Access = ReadWrite;
687 const ADDRESS = 0xd2;
688 const SIZE_BITS = 16;
689
690 touch: uint = 8..16,
691 prox: uint = 0..8,
692 },
693 #[cfg(not(feature = "movement-ui"))]
694 register EventsEnable {
695 type Access = ReadWrite;
696 const ADDRESS = 0xd3;
697 const SIZE_BITS = 16;
698 const ALLOW_ADDRESS_OVERLAP = true;
699
700 activation_setting_threshold: uint = 8..16,
701 ati_error: bool = 6,
702 ati_event: bool = 4,
703 power_event: bool = 3,
704 slider_event: bool = 2,
705 touch_event: bool = 1,
706 prox_event: bool = 0,
707 },
708 #[cfg(feature = "movement-ui")]
709 register EventsEnable {
710 type Access = ReadWrite;
711 const ADDRESS = 0xd3;
712 const SIZE_BITS = 16;
713 const ALLOW_ADDRESS_OVERLAP = true;
714
715 ati_error: bool = 6,
716 ati_event: bool = 4,
717 power_event: bool = 3,
718 slider_event: bool = 2,
719 touch_event: bool = 1,
720 prox_event: bool = 0,
721 },
722 #[cfg(not(feature = "movement-ui"))]
723 register ReleaseUiSettings {
724 type Access = ReadWrite;
725 const ADDRESS = 0xd4;
726 const SIZE_BITS = 16;
727 const ALLOW_ADDRESS_OVERLAP = true;
728
729 delta_snapshot_sample_delay: uint = 8..16,
730 release_delta_percentage: uint = 0..8,
731 },
732 #[cfg(feature = "movement-ui")]
733 register MovementTimeout {
734 type Access = ReadWrite;
735 const ADDRESS = 0xd4;
736 const SIZE_BITS = 16;
737 const ALLOW_ADDRESS_OVERLAP = true;
738
739 value: uint = 0..16,
740 },
741 },
742 block InterfaceSettings {
743 register I2c {
744 type Access = ReadWrite;
745 const ADDRESS = 0xe0;
746 const SIZE_BITS = 16;
747
748 rw_check_disabled: bool = 1,
749 stop_bit_disabled: bool = 0,
750 },
751 register HardwareId {
752 type Access = ReadOnly;
753 const ADDRESS = 0xe1;
754 const SIZE_BITS = 16;
755
756 value: uint = 0..16,
757 },
758 }
759 }
760);
761
762cfg_if::cfg_if! {
763 if #[cfg(feature = "movement-ui")] {
764 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, num_enum::IntoPrimitive, num_enum::TryFromPrimitive)]
765 #[repr(u16)]
766 pub enum DeltaLinkChannel {
767 Disabled,
768 Channel0 = 0x430,
769 Channel1 = 0x474,
770 Channel2 = 0x4b8,
771 }
772 } else {
773 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, num_enum::IntoPrimitive, num_enum::TryFromPrimitive)]
774 #[repr(u16)]
775 pub enum DeltaLinkChannel {
776 Disabled,
777 Channel0 = 0x430,
778 Channel1 = 0x472,
779 Channel2 = 0x4b4,
780 }
781 }
782}