mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-11 06:09:08 -07:00
Fix problems from FreeRTOS refactor
This commit is contained in:
2
applications/external/ble_spam/ble_spam.c
vendored
2
applications/external/ble_spam/ble_spam.c
vendored
@@ -446,7 +446,7 @@ static bool input_callback(InputEvent* input, void* _ctx) {
|
||||
with_view_model(
|
||||
state->main_view, State * *model, { (*model)->lock_warning = true; }, true);
|
||||
if(state->lock_count == 0) {
|
||||
furi_timer_start(state->lock_timer, pdMS_TO_TICKS(1000));
|
||||
furi_timer_start(state->lock_timer, 1000);
|
||||
}
|
||||
if(input->type == InputTypeShort && input->key == InputKeyBack) {
|
||||
state->lock_count++;
|
||||
|
||||
@@ -351,7 +351,7 @@ void esp_flasher_worker_stop_thread(EspFlasherApp* app) {
|
||||
}
|
||||
|
||||
esp_loader_error_t loader_port_read(uint8_t* data, uint16_t size, uint32_t timeout) {
|
||||
size_t read = furi_stream_buffer_receive(flash_rx_stream, data, size, pdMS_TO_TICKS(timeout));
|
||||
size_t read = furi_stream_buffer_receive(flash_rx_stream, data, size, timeout);
|
||||
if(read < size) {
|
||||
return ESP_LOADER_ERROR_TIMEOUT;
|
||||
} else {
|
||||
@@ -396,7 +396,7 @@ void loader_port_delay_ms(uint32_t ms) {
|
||||
|
||||
void loader_port_start_timer(uint32_t ms) {
|
||||
_remaining_time = ms;
|
||||
furi_timer_start(timer, pdMS_TO_TICKS(1));
|
||||
furi_timer_start(timer, 1);
|
||||
}
|
||||
|
||||
uint32_t loader_port_remaining_time(void) {
|
||||
|
||||
@@ -22,16 +22,15 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef SERIAL_FLASHER_DEBUG_TRACE
|
||||
static void transfer_debug_print(const uint8_t *data, uint16_t size, bool write)
|
||||
{
|
||||
static void transfer_debug_print(const uint8_t* data, uint16_t size, bool write) {
|
||||
static bool write_prev = false;
|
||||
|
||||
if (write_prev != write) {
|
||||
if(write_prev != write) {
|
||||
write_prev = write;
|
||||
printf("\n--- %s ---\n", write ? "WRITE" : "READ");
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
for(uint32_t i = 0; i < size; i++) {
|
||||
printf("%02x ", data[i]);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +41,7 @@ static int32_t s_uart_port;
|
||||
static int32_t s_reset_trigger_pin;
|
||||
static int32_t s_gpio0_trigger_pin;
|
||||
|
||||
esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config)
|
||||
{
|
||||
esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t* config) {
|
||||
s_uart_port = config->uart_port;
|
||||
s_reset_trigger_pin = config->reset_trigger_pin;
|
||||
s_gpio0_trigger_pin = config->gpio0_trigger_pin;
|
||||
@@ -52,7 +50,7 @@ esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config)
|
||||
uart_config_t uart_config = {
|
||||
.baud_rate = config->baud_rate,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
@@ -62,16 +60,22 @@ esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config)
|
||||
|
||||
int rx_buffer_size = config->rx_buffer_size ? config->rx_buffer_size : 400;
|
||||
int tx_buffer_size = config->tx_buffer_size ? config->tx_buffer_size : 400;
|
||||
QueueHandle_t *uart_queue = config->uart_queue ? config->uart_queue : NULL;
|
||||
QueueHandle_t* uart_queue = config->uart_queue ? config->uart_queue : NULL;
|
||||
int queue_size = config->queue_size ? config->queue_size : 0;
|
||||
|
||||
if ( uart_param_config(s_uart_port, &uart_config) != ESP_OK ) {
|
||||
if(uart_param_config(s_uart_port, &uart_config) != ESP_OK) {
|
||||
return ESP_LOADER_ERROR_FAIL;
|
||||
}
|
||||
if ( uart_set_pin(s_uart_port, config->uart_tx_pin, config->uart_rx_pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE) != ESP_OK ) {
|
||||
if(uart_set_pin(
|
||||
s_uart_port,
|
||||
config->uart_tx_pin,
|
||||
config->uart_rx_pin,
|
||||
UART_PIN_NO_CHANGE,
|
||||
UART_PIN_NO_CHANGE) != ESP_OK) {
|
||||
return ESP_LOADER_ERROR_FAIL;
|
||||
}
|
||||
if ( uart_driver_install(s_uart_port, rx_buffer_size, tx_buffer_size, queue_size, uart_queue, 0) != ESP_OK ) {
|
||||
if(uart_driver_install(
|
||||
s_uart_port, rx_buffer_size, tx_buffer_size, queue_size, uart_queue, 0) != ESP_OK) {
|
||||
return ESP_LOADER_ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -87,37 +91,32 @@ esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config)
|
||||
return ESP_LOADER_SUCCESS;
|
||||
}
|
||||
|
||||
void loader_port_esp32_deinit(void)
|
||||
{
|
||||
void loader_port_esp32_deinit(void) {
|
||||
uart_driver_delete(s_uart_port);
|
||||
}
|
||||
|
||||
esp_loader_error_t loader_port_write(const uint8_t* data, uint16_t size, uint32_t timeout) {
|
||||
uart_write_bytes(s_uart_port, (const char*)data, size);
|
||||
esp_err_t err = uart_wait_tx_done(s_uart_port, timeout);
|
||||
|
||||
esp_loader_error_t loader_port_write(const uint8_t *data, uint16_t size, uint32_t timeout)
|
||||
{
|
||||
uart_write_bytes(s_uart_port, (const char *)data, size);
|
||||
esp_err_t err = uart_wait_tx_done(s_uart_port, pdMS_TO_TICKS(timeout));
|
||||
|
||||
if (err == ESP_OK) {
|
||||
if(err == ESP_OK) {
|
||||
#ifdef SERIAL_FLASHER_DEBUG_TRACE
|
||||
transfer_debug_print(data, size, true);
|
||||
#endif
|
||||
return ESP_LOADER_SUCCESS;
|
||||
} else if (err == ESP_ERR_TIMEOUT) {
|
||||
} else if(err == ESP_ERR_TIMEOUT) {
|
||||
return ESP_LOADER_ERROR_TIMEOUT;
|
||||
} else {
|
||||
return ESP_LOADER_ERROR_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
esp_loader_error_t loader_port_read(uint8_t* data, uint16_t size, uint32_t timeout) {
|
||||
int read = uart_read_bytes(s_uart_port, data, size, timeout);
|
||||
|
||||
esp_loader_error_t loader_port_read(uint8_t *data, uint16_t size, uint32_t timeout)
|
||||
{
|
||||
int read = uart_read_bytes(s_uart_port, data, size, pdMS_TO_TICKS(timeout));
|
||||
|
||||
if (read < 0) {
|
||||
if(read < 0) {
|
||||
return ESP_LOADER_ERROR_FAIL;
|
||||
} else if (read < size) {
|
||||
} else if(read < size) {
|
||||
#ifdef SERIAL_FLASHER_DEBUG_TRACE
|
||||
transfer_debug_print(data, read, false);
|
||||
#endif
|
||||
@@ -130,52 +129,39 @@ esp_loader_error_t loader_port_read(uint8_t *data, uint16_t size, uint32_t timeo
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set GPIO0 LOW, then
|
||||
// assert reset pin for 50 milliseconds.
|
||||
void loader_port_enter_bootloader(void)
|
||||
{
|
||||
void loader_port_enter_bootloader(void) {
|
||||
gpio_set_level(s_gpio0_trigger_pin, 0);
|
||||
loader_port_reset_target();
|
||||
loader_port_delay_ms(SERIAL_FLASHER_BOOT_HOLD_TIME_MS);
|
||||
gpio_set_level(s_gpio0_trigger_pin, 1);
|
||||
}
|
||||
|
||||
|
||||
void loader_port_reset_target(void)
|
||||
{
|
||||
void loader_port_reset_target(void) {
|
||||
gpio_set_level(s_reset_trigger_pin, 0);
|
||||
loader_port_delay_ms(SERIAL_FLASHER_RESET_HOLD_TIME_MS);
|
||||
gpio_set_level(s_reset_trigger_pin, 1);
|
||||
}
|
||||
|
||||
|
||||
void loader_port_delay_ms(uint32_t ms)
|
||||
{
|
||||
void loader_port_delay_ms(uint32_t ms) {
|
||||
usleep(ms * 1000);
|
||||
}
|
||||
|
||||
|
||||
void loader_port_start_timer(uint32_t ms)
|
||||
{
|
||||
void loader_port_start_timer(uint32_t ms) {
|
||||
s_time_end = esp_timer_get_time() + ms * 1000;
|
||||
}
|
||||
|
||||
|
||||
uint32_t loader_port_remaining_time(void)
|
||||
{
|
||||
uint32_t loader_port_remaining_time(void) {
|
||||
int64_t remaining = (s_time_end - esp_timer_get_time()) / 1000;
|
||||
return (remaining > 0) ? (uint32_t)remaining : 0;
|
||||
}
|
||||
|
||||
|
||||
void loader_port_debug_print(const char *str)
|
||||
{
|
||||
void loader_port_debug_print(const char* str) {
|
||||
printf("DEBUG: %s\n", str);
|
||||
}
|
||||
|
||||
esp_loader_error_t loader_port_change_transmission_rate(uint32_t baudrate)
|
||||
{
|
||||
esp_loader_error_t loader_port_change_transmission_rate(uint32_t baudrate) {
|
||||
esp_err_t err = uart_set_baudrate(s_uart_port, baudrate);
|
||||
return (err == ESP_OK) ? ESP_LOADER_SUCCESS : ESP_LOADER_ERROR_FAIL;
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
#include "helpers/hardware_worker.h"
|
||||
#include "protocol_i.h"
|
||||
|
||||
#include <timer.h>
|
||||
|
||||
#include <lib/toolbox/hex.h>
|
||||
#include <toolbox/stream/stream.h>
|
||||
#include <toolbox/stream/buffered_file_stream.h>
|
||||
|
||||
@@ -502,7 +502,7 @@ int32_t zero_tracker_app(void* p) {
|
||||
|
||||
while(1) {
|
||||
TrackerMessage message;
|
||||
FuriStatus status = furi_message_queue_get(queue, &message, portMAX_DELAY);
|
||||
FuriStatus status = furi_message_queue_get(queue, &message, FuriWaitForever);
|
||||
if(status == FuriStatusOk) {
|
||||
if(message.type == TrackerPositionChanged) {
|
||||
uint8_t order_list_index = message.data.position.order_list_index;
|
||||
|
||||
Reference in New Issue
Block a user