Add UART1 Handler for as per NMEA sentence

This commit is contained in:
Sanyog Nevase Nevase 2024-11-29 15:01:00 +05:30
parent 13be37ba82
commit 9327fb3708
1 changed files with 17 additions and 1 deletions

18
main.c
View File

@ -61,5 +61,21 @@ void control_leds_based_on_speed(float speed_kmh) {
}
}
void UART1_Handler(void)
{
char data = UART1_DR_R & 0xFF;
if (data == '\n' || data == '\r')
{
nmea_sentence[nmea_index] = '\0';
if (strncmp((const char *)nmea_sentence, "$GPRMC", 6) == 0)
{
nmea_ready = true;
}
nmea_index = 0;
}
else if (nmea_index < MAX_FIELD_SIZE - 1)
{
nmea_sentence[nmea_index++] = data;
}
}