mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGHz: Improve some GPS handling
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include "subghz_gps.h"
|
||||
#include "minmea.h"
|
||||
|
||||
#include <expansion/expansion.h>
|
||||
#include <momentum/momentum.h>
|
||||
|
||||
#define UART_CH (momentum_settings.uart_nmea_channel)
|
||||
@@ -128,15 +127,13 @@ static int32_t subghz_gps_uart_worker(void* context) {
|
||||
static void subghz_gps_deinit(SubGhzGPS* subghz_gps) {
|
||||
furi_assert(subghz_gps);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(subghz_gps->thread), WorkerEvtStop);
|
||||
furi_thread_join(subghz_gps->thread);
|
||||
|
||||
furi_hal_serial_async_rx_stop(subghz_gps->serial_handle);
|
||||
furi_hal_serial_deinit(subghz_gps->serial_handle);
|
||||
furi_hal_serial_control_release(subghz_gps->serial_handle);
|
||||
|
||||
expansion_enable(furi_record_open(RECORD_EXPANSION));
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
|
||||
furi_thread_flags_set(furi_thread_get_id(subghz_gps->thread), WorkerEvtStop);
|
||||
furi_thread_join(subghz_gps->thread);
|
||||
furi_thread_free(subghz_gps->thread);
|
||||
|
||||
furi_stream_buffer_free(subghz_gps->rx_stream);
|
||||
@@ -220,9 +217,6 @@ static void subghz_gps_init(SubGhzGPS* subghz_gps, uint32_t baudrate) {
|
||||
furi_thread_alloc_ex("SubGhzGPSWorker", 1024, subghz_gps_uart_worker, subghz_gps);
|
||||
furi_thread_start(subghz_gps->thread);
|
||||
|
||||
expansion_disable(furi_record_open(RECORD_EXPANSION));
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
|
||||
subghz_gps->serial_handle = furi_hal_serial_control_acquire(UART_CH);
|
||||
furi_check(subghz_gps->serial_handle);
|
||||
furi_hal_serial_init(subghz_gps->serial_handle, baudrate);
|
||||
|
||||
@@ -11,6 +11,9 @@ SubGhzGPS* subghz_gps_plugin_init(uint32_t baudrate) {
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
if(connected) return NULL;
|
||||
|
||||
expansion_disable(furi_record_open(RECORD_EXPANSION));
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
FlipperApplication* plugin_app = flipper_application_alloc(storage, firmware_api_interface);
|
||||
do {
|
||||
@@ -60,6 +63,9 @@ SubGhzGPS* subghz_gps_plugin_init(uint32_t baudrate) {
|
||||
} while(false);
|
||||
flipper_application_free(plugin_app);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
expansion_enable(furi_record_open(RECORD_EXPANSION));
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -68,4 +74,7 @@ void subghz_gps_plugin_deinit(SubGhzGPS* subghz_gps) {
|
||||
flipper_application_free(subghz_gps->plugin_app);
|
||||
free(subghz_gps);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
expansion_enable(furi_record_open(RECORD_EXPANSION));
|
||||
furi_record_close(RECORD_EXPANSION);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user