gps_uart.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #include <furi_hal.h>
  3. #include <notification/notification_messages.h>
  4. #include <xtreme.h>
  5. #define UART_CH \
  6. (xtreme_settings.uart_nmea_channel == UARTDefault ? FuriHalUartIdUSART1 : FuriHalUartIdLPUART1)
  7. #define RX_BUF_SIZE 1024
  8. static const int gps_baudrates[6] = {4800, 9600, 19200, 38400, 57600, 115200};
  9. static int current_gps_baudrate = 1;
  10. typedef struct {
  11. bool valid;
  12. float latitude;
  13. float longitude;
  14. float speed;
  15. float course;
  16. float altitude;
  17. char altitude_units;
  18. int fix_quality;
  19. int satellites_tracked;
  20. int time_hours;
  21. int time_minutes;
  22. int time_seconds;
  23. } GpsStatus;
  24. typedef enum { KNOTS, KPH, MPH, INVALID } SpeedUnit;
  25. typedef struct {
  26. FuriMutex* mutex;
  27. FuriThread* thread;
  28. FuriStreamBuffer* rx_stream;
  29. uint8_t rx_buf[RX_BUF_SIZE];
  30. NotificationApp* notifications;
  31. uint32_t baudrate;
  32. bool changing_baudrate;
  33. bool backlight_on;
  34. SpeedUnit speed_units;
  35. GpsStatus status;
  36. } GpsUart;
  37. void gps_uart_init_thread(GpsUart* gps_uart);
  38. void gps_uart_deinit_thread(GpsUart* gps_uart);
  39. GpsUart* gps_uart_enable();
  40. void gps_uart_disable(GpsUart* gps_uart);