@@ -105,6 +105,11 @@ ADIS16448::ADIS16448(I2CSPIBusOption bus_option, int bus, uint32_t device, enum
105
105
_px4_gyro(get_device_id(), rotation),
106
106
_px4_mag(get_device_id(), rotation)
107
107
{
108
+ _debug_enabled = true ;
109
+
110
+ if (_drdy_gpio != 0 ) {
111
+ _drdy_missed_perf = perf_alloc (PC_COUNT, MODULE_NAME" : DRDY missed" );
112
+ }
108
113
}
109
114
110
115
ADIS16448::~ADIS16448 ()
@@ -160,12 +165,12 @@ int ADIS16448::probe()
160
165
}
161
166
162
167
for (int attempt = 0 ; attempt < 3 ; attempt++) {
163
- const uint16_t PROD_ID = RegisterRead (Register::PROD_ID);
168
+ const uint16_t PROD_ID = RegisterReadVerified (Register::PROD_ID);
164
169
165
170
if (PROD_ID == Product_identification) {
166
- const uint16_t SERIAL_NUM = RegisterRead (Register::SERIAL_NUM);
167
- const uint16_t LOT_ID1 = RegisterRead (Register::LOT_ID1);
168
- const uint16_t LOT_ID2 = RegisterRead (Register::LOT_ID2);
171
+ const uint16_t SERIAL_NUM = RegisterReadVerified (Register::SERIAL_NUM);
172
+ const uint16_t LOT_ID1 = RegisterReadVerified (Register::LOT_ID1);
173
+ const uint16_t LOT_ID2 = RegisterReadVerified (Register::LOT_ID2);
169
174
170
175
PX4_INFO (" Serial Number: 0x%02x, Lot ID1: 0x%02x ID2: 0x%02x" , SERIAL_NUM, LOT_ID1, LOT_ID2);
171
176
@@ -197,7 +202,7 @@ void ADIS16448::RunImpl()
197
202
case STATE::WAIT_FOR_RESET:
198
203
199
204
if (_self_test_passed) {
200
- if ((RegisterRead (Register::PROD_ID) == Product_identification)) {
205
+ if ((RegisterReadVerified (Register::PROD_ID) == Product_identification)) {
201
206
// if reset succeeded then configure
202
207
_state = STATE::CONFIGURE;
203
208
ScheduleNow ();
@@ -224,7 +229,7 @@ void ADIS16448::RunImpl()
224
229
break ;
225
230
226
231
case STATE::SELF_TEST_CHECK: {
227
- const uint16_t MSC_CTRL = RegisterRead (Register::MSC_CTRL);
232
+ const uint16_t MSC_CTRL = RegisterReadVerified (Register::MSC_CTRL);
228
233
229
234
if (MSC_CTRL & MSC_CTRL_BIT::Internal_self_test) {
230
235
// self test not finished, check again
@@ -244,7 +249,7 @@ void ADIS16448::RunImpl()
244
249
245
250
bool test_passed = true ;
246
251
247
- const uint16_t DIAG_STAT = RegisterRead (Register::DIAG_STAT);
252
+ const uint16_t DIAG_STAT = RegisterReadVerified (Register::DIAG_STAT);
248
253
249
254
if (DIAG_STAT & DIAG_STAT_BIT::Self_test_diagnostic_error_flag) {
250
255
PX4_ERR (" self test failed" );
@@ -477,7 +482,7 @@ void ADIS16448::RunImpl()
477
482
478
483
bool ADIS16448::Configure ()
479
484
{
480
- const uint16_t LOT_ID1 = RegisterRead (Register::LOT_ID1);
485
+ const uint16_t LOT_ID1 = RegisterReadVerified (Register::LOT_ID1);
481
486
482
487
// Only enable CRC-16 for verified lots (HACK to support older ADIS16448AMLZ with no explicit detection)
483
488
if (LOT_ID1 == 0x1824 ) {
@@ -603,7 +608,7 @@ bool ADIS16448::RegisterCheck(const register_config_t ®_cfg)
603
608
{
604
609
bool success = true ;
605
610
606
- const uint16_t reg_value = RegisterRead (reg_cfg.reg );
611
+ const uint16_t reg_value = RegisterReadVerified (reg_cfg.reg );
607
612
608
613
if (reg_cfg.set_bits && ((reg_value & reg_cfg.set_bits ) != reg_cfg.set_bits )) {
609
614
PX4_DEBUG (" 0x%02hhX: 0x%02hhX (0x%02hhX not set)" , (uint8_t )reg_cfg.reg , reg_value, reg_cfg.set_bits );
@@ -628,10 +633,27 @@ uint16_t ADIS16448::RegisterRead(Register reg)
628
633
transferhword (cmd, nullptr , 1 );
629
634
px4_udelay (SPI_STALL_PERIOD);
630
635
transferhword (nullptr , cmd, 1 );
636
+ px4_udelay (SPI_STALL_PERIOD);
631
637
632
638
return cmd[0 ];
633
639
}
634
640
641
+ uint16_t ADIS16448::RegisterReadVerified (Register reg)
642
+ {
643
+ // 3 attempts
644
+ for (int i = 0 ; i < 3 ; i++) {
645
+ uint16_t read1 = RegisterRead (reg);
646
+ uint16_t read2 = RegisterRead (reg);
647
+
648
+ if (read1 == read2) {
649
+ return read1;
650
+ }
651
+ }
652
+
653
+ // failed
654
+ return 0 ;
655
+ }
656
+
635
657
void ADIS16448::RegisterWrite (Register reg, uint16_t value)
636
658
{
637
659
set_frequency (SPI_SPEED);
@@ -643,11 +665,12 @@ void ADIS16448::RegisterWrite(Register reg, uint16_t value)
643
665
transferhword (cmd, nullptr , 1 );
644
666
px4_udelay (SPI_STALL_PERIOD);
645
667
transferhword (cmd + 1 , nullptr , 1 );
668
+ px4_udelay (SPI_STALL_PERIOD);
646
669
}
647
670
648
671
void ADIS16448::RegisterSetAndClearBits (Register reg, uint16_t setbits, uint16_t clearbits)
649
672
{
650
- const uint16_t orig_val = RegisterRead (reg);
673
+ const uint16_t orig_val = RegisterReadVerified (reg);
651
674
652
675
uint16_t val = (orig_val & ~clearbits) | setbits;
653
676
0 commit comments