gps_uart.h 1.1 KB

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