@@ -159,7 +159,6 @@ static void spi_delay(void);
159
159
static void spi_AS5047_cs_delay (void );
160
160
static void TS5700N8501_send_byte (uint8_t b );
161
161
162
- static void encoder_AS504x_update_connected_diag (uint8_t is_connected );
163
162
static void encoder_AS504x_determinate_if_connected (bool was_last_valid );
164
163
165
164
#if AS504x_USE_SW_MOSI_PIN || AS5047_USE_HW_SPI_PINS
@@ -629,10 +628,6 @@ bool spi_check_parity(uint16_t x) {
629
628
return (~x ) & 1 ;
630
629
}
631
630
632
- void encoder_AS504x_update_connected_diag (uint8_t is_connected ) {
633
- AS504x_sensor_diag .is_connected = is_connected ;
634
- }
635
-
636
631
#if AS504x_USE_SW_MOSI_PIN || AS5047_USE_HW_SPI_PINS
637
632
static uint8_t encoder_AS504x_fetch_diag (void ) {
638
633
uint16_t recf [2 ], senf [2 ] = {AS504x_SPI_READ_DIAG_MSG , AS504x_SPI_READ_MAGN_MSG };
@@ -735,24 +730,20 @@ static uint8_t spi_transfer_err_check(uint16_t *in_buf, const uint16_t *out_buf,
735
730
/*
736
731
* Determinate if is connected depending on last retieved data.
737
732
*/
738
- void encoder_AS504x_determinate_if_connected (bool was_last_valid ) {
733
+ static void encoder_AS504x_determinate_if_connected (bool was_last_valid ) {
739
734
if (!was_last_valid ) {
740
- AS504x_spi_communication_error_count += AS504x_CONNECTION_DETERMINATOR_ERROR_WEIGHT ;
735
+ AS504x_spi_communication_error_count ++ ;
741
736
742
737
if (AS504x_spi_communication_error_count >= AS504x_CONNECTION_DETERMINATOR_ERROR_THRESHOLD ) {
743
738
AS504x_spi_communication_error_count = AS504x_CONNECTION_DETERMINATOR_ERROR_THRESHOLD ;
744
- encoder_AS504x_update_connected_diag ( 0 ) ;
739
+ AS504x_sensor_diag . is_connected = 0 ;
745
740
mc_interface_fault_stop (FAULT_CODE_ENCODER_SPI , 0 , 1 );
746
741
}
747
742
} else {
748
743
if (AS504x_spi_communication_error_count ) {
749
744
AS504x_spi_communication_error_count -- ;
750
745
} else {
751
- encoder_AS504x_update_connected_diag (1 );
752
- if (FAULT_CODE_ENCODER_SPI == mc_interface_get_fault ()) {
753
- mc_interface_fault_stop (FAULT_CODE_NONE , 0 , 1 );
754
-
755
- }
746
+ AS504x_sensor_diag .is_connected = 1 ;
756
747
}
757
748
}
758
749
}
0 commit comments