Реализована функция lidar_update(), обновляющая данные
This commit is contained in:
@@ -75,17 +75,25 @@ void USART3_IRQHandler()
|
||||
|
||||
if (usart3_index == USART3_FRAME_SIZE)
|
||||
{
|
||||
for (uint8_t i = 0; i < USART3_FRAME_SIZE; ++i) usart3_checksum += buff_data[i];
|
||||
if (buffer.checksum == usart3_checksum)
|
||||
{
|
||||
usart3_index = 0;
|
||||
usart3_frame_ready = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
usart3_index = 0;
|
||||
usart3_frame_ready = 0;
|
||||
}
|
||||
usart3_index = 0;
|
||||
usart3_frame_ready = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lidar_update(lidar_data* lidar)
|
||||
{
|
||||
if (!usart3_frame_ready)
|
||||
return;
|
||||
|
||||
usart3_frame_ready = 0;
|
||||
|
||||
for (uint8_t i = 0; i < USART3_FRAME_SIZE; ++i) usart3_checksum += buff_data[i];
|
||||
|
||||
if (buffer.checksum != usart3_checksum)
|
||||
return;
|
||||
|
||||
lidar->distance = buffer.distance_l | (buffer.distance_h << 8);
|
||||
lidar->strength = buffer.strength_l | (buffer.strength_h << 8);
|
||||
lidar->temperature = buffer.temp_l | (buffer.temp_h << 8);
|
||||
}
|
||||
Reference in New Issue
Block a user