From 9327fb3708be9ceb9479ee2f41f1f21b4a969988 Mon Sep 17 00:00:00 2001 From: Sanyog Date: Fri, 29 Nov 2024 15:01:00 +0530 Subject: [PATCH] Add UART1 Handler for as per NMEA sentence --- main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index ec92c51..ec559e2 100644 --- a/main.c +++ b/main.c @@ -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; + } +}