mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Merge branch 'dev' of https://github.com/Flipper-XFW/Xtreme-Firmware into xfw-dev
This commit is contained in:
@@ -193,11 +193,25 @@ bool subghz_device_cc1101_ext_alloc() {
|
||||
subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateInit;
|
||||
subghz_device_cc1101_ext->regulation = SubGhzDeviceCC1101ExtRegulationTxRx;
|
||||
subghz_device_cc1101_ext->async_mirror_pin = NULL;
|
||||
subghz_device_cc1101_ext->spi_bus_handle = &furi_hal_spi_bus_handle_external;
|
||||
|
||||
subghz_device_cc1101_ext->g0_pin = SUBGHZ_DEVICE_CC1101_EXT_TX_GPIO;
|
||||
|
||||
subghz_device_cc1101_ext->async_rx.capture_delta_duration = 0;
|
||||
|
||||
subghz_device_cc1101_ext->spi_bus_handle =
|
||||
(XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault ?
|
||||
&furi_hal_spi_bus_handle_external :
|
||||
&furi_hal_spi_bus_handle_external_extra);
|
||||
|
||||
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
|
||||
if(XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, true);
|
||||
} else if(XTREME_SETTINGS()->spi_cc1101_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, true);
|
||||
}
|
||||
|
||||
furi_hal_spi_bus_handle_init(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
return subghz_device_cc1101_ext_check_init();
|
||||
}
|
||||
@@ -207,6 +221,13 @@ void subghz_device_cc1101_ext_free() {
|
||||
furi_hal_spi_bus_handle_deinit(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
free(subghz_device_cc1101_ext);
|
||||
subghz_device_cc1101_ext = NULL;
|
||||
|
||||
// resetting the CS pins to floating
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_device_cc1101_ext_set_async_mirror_pin(const GpioPin* pin) {
|
||||
@@ -529,7 +550,7 @@ void subghz_device_cc1101_ext_start_async_rx(
|
||||
furi_hal_bus_enable(FuriHalBusTIM17);
|
||||
|
||||
// Configure TIM
|
||||
//Set the timer resolution to 2 µs
|
||||
//Set the timer resolution to 2 <EFBFBD>s
|
||||
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
|
||||
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
|
||||
LL_TIM_SetAutoReload(TIM17, 0xFFFF);
|
||||
@@ -710,7 +731,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
furi_hal_bus_enable(FuriHalBusTIM17);
|
||||
|
||||
// Configure TIM
|
||||
// Set the timer resolution to 2 µs
|
||||
// Set the timer resolution to 2 <EFBFBD>s
|
||||
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
|
||||
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
|
||||
LL_TIM_SetAutoReload(TIM17, 0xFFFF);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <stddef.h>
|
||||
#include <toolbox/level_duration.h>
|
||||
#include <furi_hal_gpio.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -232,7 +232,7 @@ static bool camera_suite_view_style_1_input(InputEvent* event, void* context) {
|
||||
break;
|
||||
}
|
||||
// Send `data` to the ESP32-CAM
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
|
||||
furi_hal_uart_tx(UART_CH, data, 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ static void camera_suite_view_style_1_enter(void* context) {
|
||||
uint8_t data[1];
|
||||
data[0] = 'S'; // Uppercase `S` to start the camera
|
||||
// Send `data` to the ESP32-CAM
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
|
||||
furi_hal_uart_tx(UART_CH, data, 1);
|
||||
|
||||
with_view_model(
|
||||
instance->view,
|
||||
@@ -379,9 +379,13 @@ CameraSuiteViewStyle1* camera_suite_view_style_1_alloc() {
|
||||
furi_thread_start(instance->worker_thread);
|
||||
|
||||
// Enable uart listener
|
||||
furi_hal_console_disable();
|
||||
furi_hal_uart_set_br(FuriHalUartIdUSART1, 230400);
|
||||
furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, camera_on_irq_cb, instance);
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, 230400);
|
||||
}
|
||||
furi_hal_uart_set_br(UART_CH, 230400);
|
||||
furi_hal_uart_set_irq_cb(UART_CH, camera_on_irq_cb, instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
@@ -393,6 +397,14 @@ void camera_suite_view_style_1_free(CameraSuiteViewStyle1* instance) {
|
||||
instance->view, UartDumpModel * model, { UNUSED(model); }, true);
|
||||
view_free(instance->view);
|
||||
free(instance);
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
||||
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
}
|
||||
|
||||
View* camera_suite_view_style_1_get_view(CameraSuiteViewStyle1* instance) {
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
#include <storage/filesystem_api_defines.h>
|
||||
#include <storage/storage.h>
|
||||
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#pragma once
|
||||
|
||||
#define FRAME_WIDTH 128
|
||||
|
||||
@@ -11,9 +11,14 @@
|
||||
//#include <notification/notification.h>
|
||||
//#include <notification/notification_messages.h>
|
||||
//#include <stdlib.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#include "FlipperZeroWiFiDeauthModuleDefines.h"
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#define DEAUTH_APP_DEBUG 0
|
||||
|
||||
#if DEAUTH_APP_DEBUG
|
||||
@@ -392,6 +397,13 @@ int32_t esp8266_deauth_app(void* p) {
|
||||
#if DISABLE_CONSOLE
|
||||
furi_hal_console_disable();
|
||||
#endif
|
||||
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, FLIPPERZERO_SERIAL_BAUD);
|
||||
}
|
||||
|
||||
furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD);
|
||||
furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_on_irq_cb, app);
|
||||
DEAUTH_APP_LOG_I("UART Listener created");
|
||||
@@ -511,6 +523,12 @@ int32_t esp8266_deauth_app(void* p) {
|
||||
furi_hal_console_enable();
|
||||
#endif
|
||||
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
|
||||
//*app->m_originalBufferLocation = app->m_originalBuffer;
|
||||
|
||||
view_port_enabled_set(view_port, false);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#include "esp_flasher_app_i.h"
|
||||
#include "esp_flasher_uart.h"
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
#define BAUDRATE (115200)
|
||||
|
||||
struct EspFlasherUart {
|
||||
|
||||
@@ -14,10 +14,14 @@
|
||||
#include <assets_icons.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
|
||||
#include <xtreme.h>
|
||||
|
||||
#define NUM_MENU_ITEMS (4)
|
||||
|
||||
#define EVIL_PORTAL_TEXT_BOX_STORE_SIZE (4096)
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#define SET_HTML_CMD "sethtml"
|
||||
#define SET_AP_CMD "setap"
|
||||
|
||||
@@ -121,10 +121,16 @@ Evil_PortalUart* evil_portal_uart_init(Evil_PortalApp* app) {
|
||||
|
||||
furi_thread_start(uart->rx_thread);
|
||||
|
||||
furi_hal_console_disable();
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, app->BAUDRATE);
|
||||
}
|
||||
|
||||
if(app->BAUDRATE == 0) {
|
||||
app->BAUDRATE = 115200;
|
||||
}
|
||||
|
||||
furi_hal_uart_set_br(UART_CH, app->BAUDRATE);
|
||||
furi_hal_uart_set_irq_cb(UART_CH, evil_portal_uart_on_irq_cb, uart);
|
||||
|
||||
@@ -139,7 +145,12 @@ void evil_portal_uart_free(Evil_PortalUart* uart) {
|
||||
furi_thread_free(uart->rx_thread);
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
||||
furi_hal_console_enable();
|
||||
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
|
||||
free(uart);
|
||||
}
|
||||
|
||||
19
applications/external/gps_nmea_uart/gps_uart.c
vendored
19
applications/external/gps_nmea_uart/gps_uart.c
vendored
@@ -20,15 +20,24 @@ static void gps_uart_on_irq_cb(UartIrqEvent ev, uint8_t data, void* context) {
|
||||
}
|
||||
|
||||
static void gps_uart_serial_init(GpsUart* gps_uart) {
|
||||
furi_hal_console_disable();
|
||||
furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, gps_uart_on_irq_cb, gps_uart);
|
||||
furi_hal_uart_set_br(FuriHalUartIdUSART1, gps_uart->baudrate);
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, gps_uart->baudrate);
|
||||
}
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, gps_uart_on_irq_cb, gps_uart);
|
||||
furi_hal_uart_set_br(UART_CH, gps_uart->baudrate);
|
||||
}
|
||||
|
||||
static void gps_uart_serial_deinit(GpsUart* gps_uart) {
|
||||
UNUSED(gps_uart);
|
||||
furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, NULL, NULL);
|
||||
furi_hal_console_enable();
|
||||
furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
}
|
||||
|
||||
static void gps_uart_parse_nmea(GpsUart* gps_uart, char* line) {
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
#include <furi_hal.h>
|
||||
#include <notification/notification_messages.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_nmea_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#define RX_BUF_SIZE 1024
|
||||
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
#include <string.h>
|
||||
|
||||
void nrf24_init() {
|
||||
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, true);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, true);
|
||||
}
|
||||
|
||||
furi_hal_spi_bus_handle_init(nrf24_HANDLE);
|
||||
furi_hal_spi_acquire(nrf24_HANDLE);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
|
||||
@@ -19,13 +28,16 @@ void nrf24_deinit() {
|
||||
furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
|
||||
furi_hal_gpio_write(nrf24_CE_PIN, false);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// resetting the CS pins to floating
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf24_spi_trx(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint8_t* tx,
|
||||
uint8_t* rx,
|
||||
uint8_t size) {
|
||||
void nrf24_spi_trx(FuriHalSpiBusHandle* handle, uint8_t* tx, uint8_t* rx, uint8_t size) {
|
||||
furi_hal_gpio_write(handle->cs, false);
|
||||
furi_hal_spi_bus_trx(handle, tx, rx, size, nrf24_TIMEOUT);
|
||||
furi_hal_gpio_write(handle->cs, true);
|
||||
@@ -38,7 +50,8 @@ uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data)
|
||||
return buf[0];
|
||||
}
|
||||
|
||||
uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
|
||||
uint8_t
|
||||
nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
|
||||
uint8_t buf[size + 1];
|
||||
buf[0] = W_REGISTER | (REGISTER_MASK & reg);
|
||||
memcpy(&buf[1], data, size);
|
||||
@@ -57,7 +70,7 @@ uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data,
|
||||
}
|
||||
|
||||
uint8_t nrf24_read_register(FuriHalSpiBusHandle* handle, uint8_t reg) {
|
||||
uint8_t buf[] = { R_REGISTER | (REGISTER_MASK & reg), 0 };
|
||||
uint8_t buf[] = {R_REGISTER | (REGISTER_MASK & reg), 0};
|
||||
nrf24_spi_trx(handle, buf, buf, 2);
|
||||
return buf[1];
|
||||
}
|
||||
@@ -190,7 +203,11 @@ uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
|
||||
|
||||
// packet_size: 0 - dyn payload (read from PL_WID), 1 - read from pipe size, >1 - override
|
||||
// Return STATUS reg + additional: RX_DR - new data available, 0x80 - NRF24 hardware error
|
||||
uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size) {
|
||||
uint8_t nrf24_rxpacket(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint8_t* packet,
|
||||
uint8_t* ret_packetsize,
|
||||
uint8_t packet_size) {
|
||||
uint8_t status = 0;
|
||||
uint8_t buf[33]; // 32 max payload size + 1 for command
|
||||
|
||||
@@ -207,8 +224,9 @@ uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* re
|
||||
if(status & 0x80) return 0x80; // hardware error
|
||||
if(packet_size == 1)
|
||||
packet_size = nrf24_get_packetlen(handle, (status >> 1) & 7);
|
||||
else if(packet_size == 0){
|
||||
buf[0] = R_RX_PL_WID; buf[1] = 0xFF;
|
||||
else if(packet_size == 0) {
|
||||
buf[0] = R_RX_PL_WID;
|
||||
buf[1] = 0xFF;
|
||||
nrf24_spi_trx(handle, buf, buf, 2);
|
||||
packet_size = buf[1];
|
||||
}
|
||||
@@ -241,7 +259,9 @@ uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t si
|
||||
status = nrf24_status(handle);
|
||||
} while(!(status & (TX_DS | MAX_RT)) && furi_get_tick() - start_time < 100UL);
|
||||
if(status & MAX_RT) {
|
||||
if(furi_log_get_level() == FuriLogLevelDebug) FURI_LOG_D("NRF", "MAX RT: %X (%X)", nrf24_read_register(handle, REG_OBSERVE_TX), status);
|
||||
if(furi_log_get_level() == FuriLogLevelDebug)
|
||||
FURI_LOG_D(
|
||||
"NRF", "MAX RT: %X (%X)", nrf24_read_register(handle, REG_OBSERVE_TX), status);
|
||||
nrf24_flush_tx(handle);
|
||||
}
|
||||
furi_hal_gpio_write(nrf24_CE_PIN, false);
|
||||
@@ -357,9 +377,8 @@ void int16_to_bytes(uint16_t val, uint8_t* out, bool bigendian) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen)
|
||||
{
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t* mac, uint8_t mlen) {
|
||||
uint8_t addr[5];
|
||||
for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1];
|
||||
return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen);
|
||||
for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1];
|
||||
return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -47,14 +48,16 @@ extern "C" {
|
||||
#define RX_PW_P3 0x14
|
||||
#define RX_PW_P4 0x15
|
||||
#define RX_PW_P5 0x16
|
||||
#define RX_DR 0x40
|
||||
#define TX_DS 0x20
|
||||
#define MAX_RT 0x10
|
||||
#define RX_DR 0x40
|
||||
#define TX_DS 0x20
|
||||
#define MAX_RT 0x10
|
||||
#define NRF24_EN_DYN_ACK 0x01
|
||||
|
||||
#define nrf24_TIMEOUT 500
|
||||
#define nrf24_CE_PIN &gpio_ext_pb2
|
||||
#define nrf24_HANDLE &furi_hal_spi_bus_handle_external
|
||||
#define nrf24_HANDLE \
|
||||
(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : \
|
||||
&furi_hal_spi_bus_handle_external_extra)
|
||||
|
||||
/* Low level API */
|
||||
|
||||
@@ -278,8 +281,11 @@ uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
|
||||
*
|
||||
* @return device status
|
||||
*/
|
||||
uint8_t
|
||||
nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size_flag);
|
||||
uint8_t nrf24_rxpacket(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint8_t* packet,
|
||||
uint8_t* ret_packetsize,
|
||||
uint8_t packet_size_flag);
|
||||
|
||||
/** Sends TX packet
|
||||
*
|
||||
@@ -315,7 +321,7 @@ void nrf24_configure(
|
||||
bool disable_aa);
|
||||
|
||||
// Set mac address (MSB first), Return: Status
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen);
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t* mac, uint8_t mlen);
|
||||
|
||||
/** Configures the radio for "promiscuous mode" and primes it for rx
|
||||
* This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were.
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
#include <string.h>
|
||||
|
||||
void nrf24_init() {
|
||||
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, true);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, true);
|
||||
}
|
||||
|
||||
furi_hal_spi_bus_handle_init(nrf24_HANDLE);
|
||||
furi_hal_spi_acquire(nrf24_HANDLE);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
|
||||
@@ -17,6 +26,13 @@ void nrf24_deinit() {
|
||||
furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
|
||||
furi_hal_gpio_write(nrf24_CE_PIN, false);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// resetting the CS pins to floating
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf24_spi_trx(
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -40,7 +41,9 @@ extern "C" {
|
||||
|
||||
#define nrf24_TIMEOUT 500
|
||||
#define nrf24_CE_PIN &gpio_ext_pb2
|
||||
#define nrf24_HANDLE &furi_hal_spi_bus_handle_external
|
||||
#define nrf24_HANDLE \
|
||||
(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : \
|
||||
&furi_hal_spi_bus_handle_external_extra)
|
||||
|
||||
/* Low level API */
|
||||
|
||||
|
||||
@@ -8,6 +8,15 @@
|
||||
#include <string.h>
|
||||
|
||||
void nrf24_init() {
|
||||
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, true);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, true);
|
||||
}
|
||||
|
||||
furi_hal_spi_bus_handle_init(nrf24_HANDLE);
|
||||
furi_hal_spi_acquire(nrf24_HANDLE);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
|
||||
@@ -19,6 +28,13 @@ void nrf24_deinit() {
|
||||
furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
|
||||
furi_hal_gpio_write(nrf24_CE_PIN, false);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// resetting the CS pins to floating
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf24_spi_trx(
|
||||
@@ -41,7 +57,8 @@ uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data)
|
||||
return rx[0];
|
||||
}
|
||||
|
||||
uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
|
||||
uint8_t
|
||||
nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size) {
|
||||
uint8_t tx[size + 1];
|
||||
uint8_t rx[size + 1];
|
||||
memset(rx, 0, size + 1);
|
||||
@@ -190,7 +207,11 @@ uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len) {
|
||||
return status;
|
||||
}
|
||||
|
||||
uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size) {
|
||||
uint8_t nrf24_rxpacket(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint8_t* packet,
|
||||
uint8_t* ret_packetsize,
|
||||
uint8_t packet_size) {
|
||||
uint8_t status = 0;
|
||||
uint8_t tx_cmd[33] = {0}; // 32 max payload size + 1 for command
|
||||
uint8_t tmp_packet[33] = {0};
|
||||
@@ -204,13 +225,15 @@ uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* re
|
||||
if(status & RX_DR) {
|
||||
if(packet_size == 1)
|
||||
packet_size = nrf24_get_packetlen(handle, (status >> 1) & 7);
|
||||
else if(packet_size == 0){
|
||||
tx_cmd[0] = R_RX_PL_WID; tx_cmd[1] = 0;
|
||||
else if(packet_size == 0) {
|
||||
tx_cmd[0] = R_RX_PL_WID;
|
||||
tx_cmd[1] = 0;
|
||||
nrf24_spi_trx(handle, tx_cmd, tmp_packet, 2, nrf24_TIMEOUT);
|
||||
packet_size = tmp_packet[1];
|
||||
}
|
||||
if(packet_size > 32 || packet_size == 0) packet_size = 32;
|
||||
tx_cmd[0] = R_RX_PAYLOAD; tx_cmd[1] = 0;
|
||||
tx_cmd[0] = R_RX_PAYLOAD;
|
||||
tx_cmd[1] = 0;
|
||||
nrf24_spi_trx(handle, tx_cmd, tmp_packet, packet_size + 1, nrf24_TIMEOUT);
|
||||
memcpy(packet, &tmp_packet[1], packet_size);
|
||||
nrf24_write_reg(handle, REG_STATUS, RX_DR); // clear RX_DR
|
||||
@@ -240,7 +263,8 @@ uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t si
|
||||
nrf24_set_tx_mode(handle);
|
||||
|
||||
uint32_t start_time = furi_get_tick();
|
||||
while(!(status & (TX_DS | MAX_RT)) && furi_get_tick() - start_time < 2000UL) status = nrf24_status(handle);
|
||||
while(!(status & (TX_DS | MAX_RT)) && furi_get_tick() - start_time < 2000UL)
|
||||
status = nrf24_status(handle);
|
||||
|
||||
if(status & MAX_RT) nrf24_flush_tx(handle);
|
||||
|
||||
@@ -525,9 +549,8 @@ uint8_t nrf24_find_channel(
|
||||
return ch;
|
||||
}
|
||||
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen)
|
||||
{
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t* mac, uint8_t mlen) {
|
||||
uint8_t addr[5];
|
||||
for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1];
|
||||
return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen);
|
||||
for(int i = 0; i < mlen; i++) addr[i] = mac[mlen - i - 1];
|
||||
return nrf24_write_buf_reg(nrf24_HANDLE, mac_addr, addr, mlen);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -46,13 +47,15 @@ extern "C" {
|
||||
#define RX_PW_P3 0x14
|
||||
#define RX_PW_P4 0x15
|
||||
#define RX_PW_P5 0x16
|
||||
#define RX_DR 0x40
|
||||
#define TX_DS 0x20
|
||||
#define MAX_RT 0x10
|
||||
#define RX_DR 0x40
|
||||
#define TX_DS 0x20
|
||||
#define MAX_RT 0x10
|
||||
|
||||
#define nrf24_TIMEOUT 500
|
||||
#define nrf24_CE_PIN &gpio_ext_pb2
|
||||
#define nrf24_HANDLE &furi_hal_spi_bus_handle_external
|
||||
#define nrf24_HANDLE \
|
||||
(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : \
|
||||
&furi_hal_spi_bus_handle_external_extra)
|
||||
|
||||
/* Low level API */
|
||||
|
||||
@@ -273,8 +276,11 @@ uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
|
||||
*
|
||||
* @return device status
|
||||
*/
|
||||
uint8_t
|
||||
nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* ret_packetsize, uint8_t packet_size_flag);
|
||||
uint8_t nrf24_rxpacket(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
uint8_t* packet,
|
||||
uint8_t* ret_packetsize,
|
||||
uint8_t packet_size_flag);
|
||||
|
||||
/** Sends TX packet
|
||||
*
|
||||
@@ -310,7 +316,7 @@ void nrf24_configure(
|
||||
bool disable_aa);
|
||||
|
||||
// Set mac address (MSB first), Return: Status
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t *mac, uint8_t mlen);
|
||||
uint8_t nrf24_set_mac(uint8_t mac_addr, uint8_t* mac, uint8_t mlen);
|
||||
|
||||
/** Configures the radio for "promiscuous mode" and primes it for rx
|
||||
* This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were.
|
||||
|
||||
@@ -6,6 +6,15 @@
|
||||
#include <string.h>
|
||||
|
||||
void nrf24_init() {
|
||||
// this is needed if multiple SPI devices are connected to the same bus but with different CS pins
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pc3, true);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
|
||||
furi_hal_gpio_write(&gpio_ext_pa4, true);
|
||||
}
|
||||
|
||||
furi_hal_spi_bus_handle_init(nrf24_HANDLE);
|
||||
furi_hal_spi_acquire(nrf24_HANDLE);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
|
||||
@@ -17,6 +26,13 @@ void nrf24_deinit() {
|
||||
furi_hal_spi_bus_handle_deinit(nrf24_HANDLE);
|
||||
furi_hal_gpio_write(nrf24_CE_PIN, false);
|
||||
furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
// resetting the CS pins to floating
|
||||
if(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
|
||||
} else if(XTREME_SETTINGS()->spi_nrf24_handle == SpiExtra) {
|
||||
furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
|
||||
}
|
||||
}
|
||||
|
||||
void nrf24_spi_trx(
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <furi_hal_spi.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -40,7 +41,9 @@ extern "C" {
|
||||
|
||||
#define nrf24_TIMEOUT 500
|
||||
#define nrf24_CE_PIN &gpio_ext_pb2
|
||||
#define nrf24_HANDLE &furi_hal_spi_bus_handle_external
|
||||
#define nrf24_HANDLE \
|
||||
(XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : \
|
||||
&furi_hal_spi_bus_handle_external_extra)
|
||||
|
||||
/* Low level API */
|
||||
|
||||
|
||||
@@ -12,11 +12,15 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <gui/modules/text_input.h>
|
||||
|
||||
#include <xtreme.h>
|
||||
|
||||
#define NUM_MENU_ITEMS (5)
|
||||
|
||||
#define UART_TERMINAL_TEXT_BOX_STORE_SIZE (4096)
|
||||
#define UART_TERMINAL_TEXT_INPUT_STORE_SIZE (512)
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_general_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
struct UART_TerminalApp {
|
||||
Gui* gui;
|
||||
|
||||
@@ -73,7 +73,12 @@ UART_TerminalUart* uart_terminal_uart_init(UART_TerminalApp* app) {
|
||||
|
||||
furi_thread_start(uart->rx_thread);
|
||||
|
||||
furi_hal_console_disable();
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, app->BAUDRATE);
|
||||
}
|
||||
|
||||
if(app->BAUDRATE == 0) {
|
||||
app->BAUDRATE = 115200;
|
||||
}
|
||||
@@ -91,7 +96,11 @@ void uart_terminal_uart_free(UART_TerminalUart* uart) {
|
||||
furi_thread_free(uart->rx_thread);
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
||||
furi_hal_console_enable();
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
|
||||
free(uart);
|
||||
}
|
||||
@@ -12,6 +12,12 @@
|
||||
#include <gui/modules/text_input.h>
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#define NUM_MENU_ITEMS (11)
|
||||
|
||||
#define WIFI_deauther_TEXT_BOX_STORE_SIZE (4096)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <stream_buffer.h>
|
||||
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define BAUDRATE (115200)
|
||||
|
||||
struct WifideautherUart {
|
||||
@@ -76,7 +75,12 @@ WifideautherUart* wifi_deauther_uart_init(WifideautherApp* app) {
|
||||
|
||||
furi_thread_start(uart->rx_thread);
|
||||
|
||||
furi_hal_console_disable();
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, BAUDRATE);
|
||||
}
|
||||
|
||||
furi_hal_uart_set_br(UART_CH, BAUDRATE);
|
||||
furi_hal_uart_set_irq_cb(UART_CH, wifi_deauther_uart_on_irq_cb, uart);
|
||||
|
||||
@@ -91,7 +95,11 @@ void wifi_deauther_uart_free(WifideautherUart* uart) {
|
||||
furi_thread_free(uart->rx_thread);
|
||||
|
||||
furi_hal_uart_set_irq_cb(UART_CH, NULL, NULL);
|
||||
furi_hal_console_enable();
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
|
||||
free(uart);
|
||||
}
|
||||
@@ -113,9 +113,6 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
|
||||
app->uart,
|
||||
wifi_marauder_console_output_handle_rx_data_cb); // setup callback for general log rx thread
|
||||
}
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->lp_uart,
|
||||
wifi_marauder_console_output_handle_rx_packets_cb); // setup callback for packets rx thread
|
||||
|
||||
if(app->flash_mode) {
|
||||
wifi_marauder_flash_start_thread(app);
|
||||
@@ -207,7 +204,6 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
|
||||
|
||||
// Unregister rx callback
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->lp_uart, NULL);
|
||||
|
||||
wifi_marauder_script_worker_free(app->script_worker);
|
||||
app->script_worker = NULL;
|
||||
|
||||
@@ -164,7 +164,7 @@ void wifi_marauder_app_free(WifiMarauderApp* app) {
|
||||
scene_manager_free(app->scene_manager);
|
||||
|
||||
wifi_marauder_uart_free(app->uart);
|
||||
wifi_marauder_uart_free(app->lp_uart);
|
||||
// wifi_marauder_uart_free(app->lp_uart);
|
||||
|
||||
// Close records
|
||||
furi_record_close(RECORD_GUI);
|
||||
@@ -189,8 +189,8 @@ int32_t wifi_marauder_app(void* p) {
|
||||
wifi_marauder_make_app_folder(wifi_marauder_app);
|
||||
wifi_marauder_load_settings(wifi_marauder_app);
|
||||
|
||||
wifi_marauder_app->uart = wifi_marauder_usart_init(wifi_marauder_app);
|
||||
wifi_marauder_app->lp_uart = wifi_marauder_lp_uart_init(wifi_marauder_app);
|
||||
wifi_marauder_app->uart =
|
||||
wifi_marauder_uart_init(wifi_marauder_app, UART_CH, "WifiMarauderUartRxThread");
|
||||
|
||||
view_dispatcher_run(wifi_marauder_app->view_dispatcher);
|
||||
|
||||
|
||||
@@ -26,6 +26,11 @@
|
||||
#include <storage/storage.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <dialogs/dialogs.h>
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
#define NUM_MENU_ITEMS (19)
|
||||
|
||||
@@ -90,7 +95,6 @@ struct WifiMarauderApp {
|
||||
int open_log_file_num_pages;
|
||||
|
||||
WifiMarauderUart* uart;
|
||||
WifiMarauderUart* lp_uart;
|
||||
int selected_menu_index;
|
||||
int selected_option_index[NUM_MENU_ITEMS];
|
||||
const char* selected_tx_string;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#include "wifi_marauder_app_i.h"
|
||||
#include "wifi_marauder_uart.h"
|
||||
|
||||
#define UART_CH (FuriHalUartIdUSART1)
|
||||
#define LP_UART_CH (FuriHalUartIdLPUART1)
|
||||
#define BAUDRATE (115200)
|
||||
|
||||
struct WifiMarauderUart {
|
||||
@@ -62,10 +60,6 @@ void wifi_marauder_uart_tx(uint8_t* data, size_t len) {
|
||||
furi_hal_uart_tx(UART_CH, data, len);
|
||||
}
|
||||
|
||||
void wifi_marauder_lp_uart_tx(uint8_t* data, size_t len) {
|
||||
furi_hal_uart_tx(LP_UART_CH, data, len);
|
||||
}
|
||||
|
||||
WifiMarauderUart*
|
||||
wifi_marauder_uart_init(WifiMarauderApp* app, FuriHalUartId channel, const char* thread_name) {
|
||||
WifiMarauderUart* uart = malloc(sizeof(WifiMarauderUart));
|
||||
@@ -90,14 +84,6 @@ WifiMarauderUart*
|
||||
return uart;
|
||||
}
|
||||
|
||||
WifiMarauderUart* wifi_marauder_usart_init(WifiMarauderApp* app) {
|
||||
return wifi_marauder_uart_init(app, UART_CH, "WifiMarauderUartRxThread");
|
||||
}
|
||||
|
||||
WifiMarauderUart* wifi_marauder_lp_uart_init(WifiMarauderApp* app) {
|
||||
return wifi_marauder_uart_init(app, LP_UART_CH, "WifiMarauderLPUartRxThread");
|
||||
}
|
||||
|
||||
void wifi_marauder_uart_free(WifiMarauderUart* uart) {
|
||||
furi_assert(uart);
|
||||
|
||||
@@ -108,8 +94,9 @@ void wifi_marauder_uart_free(WifiMarauderUart* uart) {
|
||||
furi_hal_uart_set_irq_cb(uart->channel, NULL, NULL);
|
||||
if(uart->channel == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(uart->channel);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
furi_hal_console_enable();
|
||||
|
||||
free(uart);
|
||||
}
|
||||
|
||||
@@ -14,3 +14,6 @@ void wifi_marauder_lp_uart_tx(uint8_t* data, size_t len);
|
||||
WifiMarauderUart* wifi_marauder_usart_init(WifiMarauderApp* app);
|
||||
WifiMarauderUart* wifi_marauder_lp_uart_init(WifiMarauderApp* app);
|
||||
void wifi_marauder_uart_free(WifiMarauderUart* uart);
|
||||
|
||||
WifiMarauderUart*
|
||||
wifi_marauder_uart_init(WifiMarauderApp* app, FuriHalUartId channel, const char* thread_name);
|
||||
@@ -15,3 +15,9 @@
|
||||
#define FLIPPERZERO_SERIAL_BAUD 115200
|
||||
|
||||
#define NA 0
|
||||
|
||||
#include <xtreme.h>
|
||||
|
||||
#define UART_CH \
|
||||
(XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? FuriHalUartIdUSART1 : \
|
||||
FuriHalUartIdLPUART1)
|
||||
|
||||
@@ -835,7 +835,7 @@ void send_serial_command(ESerialCommand command) {
|
||||
return;
|
||||
};
|
||||
|
||||
furi_hal_uart_tx(FuriHalUartIdUSART1, data, 1);
|
||||
furi_hal_uart_tx(UART_CH, data, 1);
|
||||
}
|
||||
|
||||
int32_t wifi_scanner_app(void* p) {
|
||||
@@ -905,11 +905,14 @@ int32_t wifi_scanner_app(void* p) {
|
||||
WIFI_APP_LOG_I("UART thread allocated");
|
||||
|
||||
// Enable uart listener
|
||||
#if DISABLE_CONSOLE
|
||||
furi_hal_console_disable();
|
||||
#endif
|
||||
furi_hal_uart_set_br(FuriHalUartIdUSART1, FLIPPERZERO_SERIAL_BAUD);
|
||||
furi_hal_uart_set_irq_cb(FuriHalUartIdUSART1, uart_on_irq_cb, app);
|
||||
if(UART_CH == FuriHalUartIdUSART1) {
|
||||
furi_hal_console_disable();
|
||||
} else if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_init(UART_CH, FLIPPERZERO_SERIAL_BAUD);
|
||||
}
|
||||
|
||||
furi_hal_uart_set_br(UART_CH, FLIPPERZERO_SERIAL_BAUD);
|
||||
furi_hal_uart_set_irq_cb(UART_CH, uart_on_irq_cb, app);
|
||||
WIFI_APP_LOG_I("UART Listener created");
|
||||
|
||||
// Because we assume that module was on before we launched the app. We need to ensure that module will be in initial state on app start
|
||||
@@ -1034,9 +1037,11 @@ int32_t wifi_scanner_app(void* p) {
|
||||
// Reset GPIO pins to default state
|
||||
furi_hal_gpio_init(&gpio_ext_pc0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
#if DISABLE_CONSOLE
|
||||
furi_hal_console_enable();
|
||||
#endif
|
||||
if(UART_CH == FuriHalUartIdLPUART1) {
|
||||
furi_hal_uart_deinit(UART_CH);
|
||||
} else {
|
||||
furi_hal_console_enable();
|
||||
}
|
||||
|
||||
view_port_enabled_set(view_port, false);
|
||||
|
||||
|
||||
@@ -35,6 +35,51 @@ static void xtreme_app_scene_protocols_subghz_extend_changed(VariableItem* item)
|
||||
app->save_subghz = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_protocols_cc1101_handle_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
XTREME_SETTINGS()->spi_cc1101_handle =
|
||||
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
||||
variable_item_set_current_value_text(
|
||||
item, XTREME_SETTINGS()->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_protocols_nrf24_handle_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
XTREME_SETTINGS()->spi_nrf24_handle =
|
||||
variable_item_get_current_value_index(item) == 0 ? SpiDefault : SpiExtra;
|
||||
variable_item_set_current_value_text(
|
||||
item, XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_protocols_esp32_channel_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
XTREME_SETTINGS()->uart_esp_channel =
|
||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||
variable_item_set_current_value_text(
|
||||
item, XTREME_SETTINGS()->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_protocols_nmea_channel_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
XTREME_SETTINGS()->uart_nmea_channel =
|
||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||
variable_item_set_current_value_text(
|
||||
item, XTREME_SETTINGS()->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
static void xtreme_app_scene_protocols_general_channel_changed(VariableItem* item) {
|
||||
XtremeApp* app = variable_item_get_context(item);
|
||||
XTREME_SETTINGS()->uart_general_channel =
|
||||
variable_item_get_current_value_index(item) == 0 ? UARTDefault : UARTExtra;
|
||||
variable_item_set_current_value_text(
|
||||
item, XTREME_SETTINGS()->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
||||
app->save_settings = true;
|
||||
}
|
||||
|
||||
void xtreme_app_scene_protocols_on_enter(void* context) {
|
||||
XtremeApp* app = context;
|
||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||
@@ -63,6 +108,52 @@ void xtreme_app_scene_protocols_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, app->subghz_extend);
|
||||
variable_item_set_current_value_text(item, app->subghz_extend ? "ON" : "OFF");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"SPI CC1101 Handle",
|
||||
2,
|
||||
xtreme_app_scene_protocols_cc1101_handle_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->spi_cc1101_handle);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->spi_cc1101_handle == SpiDefault ? "Default" : "Extra");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list, "SPI NRF24 Handle", 2, xtreme_app_scene_protocols_nrf24_handle_changed, app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->spi_nrf24_handle);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->spi_nrf24_handle == SpiDefault ? "Default" : "Extra");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"UART ESP32/ESP8266 Channel",
|
||||
2,
|
||||
xtreme_app_scene_protocols_esp32_channel_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->uart_esp_channel);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->uart_esp_channel == UARTDefault ? "13,14" : "15,16");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"UART NMEA Channel",
|
||||
2,
|
||||
xtreme_app_scene_protocols_nmea_channel_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->uart_nmea_channel);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->uart_nmea_channel == UARTDefault ? "13,14" : "15,16");
|
||||
|
||||
item = variable_item_list_add(
|
||||
var_item_list,
|
||||
"UART General Channel",
|
||||
2,
|
||||
xtreme_app_scene_protocols_general_channel_changed,
|
||||
app);
|
||||
variable_item_set_current_value_index(item, xtreme_settings->uart_general_channel);
|
||||
variable_item_set_current_value_text(
|
||||
item, xtreme_settings->uart_general_channel == UARTDefault ? "13,14" : "15,16");
|
||||
|
||||
variable_item_list_set_enter_callback(
|
||||
var_item_list, xtreme_app_scene_protocols_var_item_list_callback, app);
|
||||
|
||||
|
||||
@@ -3524,6 +3524,7 @@ Variable,+,furi_hal_sd_spi_handle,FuriHalSpiBusHandle*,
|
||||
Variable,+,furi_hal_spi_bus_d,FuriHalSpiBus,
|
||||
Variable,+,furi_hal_spi_bus_handle_display,FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_external,FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_external_extra,FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_nfc,FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_sd_fast,FuriHalSpiBusHandle,
|
||||
Variable,+,furi_hal_spi_bus_handle_sd_slow,FuriHalSpiBusHandle,
|
||||
|
||||
|
@@ -350,6 +350,15 @@ FuriHalSpiBusHandle furi_hal_spi_bus_handle_external = {
|
||||
.cs = &gpio_ext_pa4,
|
||||
};
|
||||
|
||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_external_extra = {
|
||||
.bus = &furi_hal_spi_bus_r,
|
||||
.callback = furi_hal_spi_bus_handle_external_event_callback,
|
||||
.miso = &gpio_ext_pa6,
|
||||
.mosi = &gpio_ext_pa7,
|
||||
.sck = &gpio_ext_pb3,
|
||||
.cs = &gpio_ext_pc3,
|
||||
};
|
||||
|
||||
inline static void furi_hal_spi_bus_d_handle_event_callback(
|
||||
FuriHalSpiBusHandle* handle,
|
||||
FuriHalSpiBusHandleEvent event,
|
||||
|
||||
@@ -47,6 +47,20 @@ extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_nfc;
|
||||
*/
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_external;
|
||||
|
||||
/** External on `furi_hal_spi_bus_r`
|
||||
* Preset: `furi_hal_spi_preset_1edge_low_2m`
|
||||
*
|
||||
* miso: pa6
|
||||
* mosi: pa7
|
||||
* sck: pb3
|
||||
* cs: pc3 (software controlled)
|
||||
*
|
||||
* @warning not initialized by default, call `furi_hal_spi_bus_handle_init` to initialize
|
||||
* Bus pins are floating on inactive state, CS high after initialization
|
||||
*
|
||||
*/
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_external_extra;
|
||||
|
||||
/** ST7567(Display) on `furi_hal_spi_bus_d` */
|
||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_display;
|
||||
|
||||
|
||||
@@ -34,6 +34,11 @@ XtremeSettings xtreme_settings = {
|
||||
.rgb_backlight = false, // OFF
|
||||
.butthurt_timer = 21600, // 6 H
|
||||
.charge_cap = 100, // 100%
|
||||
.spi_cc1101_handle = SpiDefault, // &furi_hal_spi_bus_handle_external
|
||||
.spi_nrf24_handle = SpiDefault, // &furi_hal_spi_bus_handle_external
|
||||
.uart_esp_channel = UARTDefault, // pin 13,14
|
||||
.uart_nmea_channel = UARTDefault, // pin 13,14
|
||||
.uart_general_channel = UARTDefault, // pin 13,14
|
||||
};
|
||||
|
||||
void XTREME_SETTINGS_LOAD() {
|
||||
@@ -161,6 +166,26 @@ void XTREME_SETTINGS_LOAD() {
|
||||
if(flipper_format_read_uint32(file, "charge_cap", &u, 1)) {
|
||||
x->charge_cap = CLAMP(u, 100U, 5U);
|
||||
}
|
||||
flipper_format_rewind(file);
|
||||
if(flipper_format_read_uint32(file, "spi_cc1101_handle", &u, 1)) {
|
||||
x->spi_cc1101_handle = CLAMP(u, SpiCount - 1U, 0U);
|
||||
}
|
||||
flipper_format_rewind(file);
|
||||
if(flipper_format_read_uint32(file, "spi_nrf24_handle", &u, 1)) {
|
||||
x->spi_nrf24_handle = CLAMP(u, SpiCount - 1U, 0U);
|
||||
}
|
||||
flipper_format_rewind(file);
|
||||
if(flipper_format_read_uint32(file, "uart_esp_channel", &u, 1)) {
|
||||
x->uart_esp_channel = CLAMP(u, UARTCount - 1U, 0U);
|
||||
}
|
||||
flipper_format_rewind(file);
|
||||
if(flipper_format_read_uint32(file, "uart_nmea_channel", &u, 1)) {
|
||||
x->uart_nmea_channel = CLAMP(u, UARTCount - 1U, 0U);
|
||||
}
|
||||
flipper_format_rewind(file);
|
||||
if(flipper_format_read_uint32(file, "uart_general_channel", &u, 1)) {
|
||||
x->uart_general_channel = CLAMP(u, UARTCount - 1U, 0U);
|
||||
}
|
||||
}
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
@@ -180,7 +205,8 @@ void XTREME_SETTINGS_SAVE() {
|
||||
e = x->menu_style;
|
||||
flipper_format_write_uint32(file, "menu_style", &e, 1);
|
||||
flipper_format_write_bool(file, "bad_pins_format", &x->bad_pins_format, 1);
|
||||
flipper_format_write_bool(file, "allow_locked_rpc_commands", &x->allow_locked_rpc_commands, 1);
|
||||
flipper_format_write_bool(
|
||||
file, "allow_locked_rpc_commands", &x->allow_locked_rpc_commands, 1);
|
||||
flipper_format_write_bool(file, "lock_on_boot", &x->lock_on_boot, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_time", &x->lockscreen_time, 1);
|
||||
flipper_format_write_bool(file, "lockscreen_seconds", &x->lockscreen_seconds, 1);
|
||||
@@ -203,6 +229,16 @@ void XTREME_SETTINGS_SAVE() {
|
||||
flipper_format_write_bool(file, "rgb_backlight", &x->rgb_backlight, 1);
|
||||
flipper_format_write_uint32(file, "butthurt_timer", &x->butthurt_timer, 1);
|
||||
flipper_format_write_uint32(file, "charge_cap", &x->charge_cap, 1);
|
||||
e = x->spi_cc1101_handle;
|
||||
flipper_format_write_uint32(file, "spi_cc1101_handle", &e, 1);
|
||||
e = x->spi_nrf24_handle;
|
||||
flipper_format_write_uint32(file, "spi_nrf24_handle", &e, 1);
|
||||
e = x->uart_esp_channel;
|
||||
flipper_format_write_uint32(file, "uart_esp_channel", &e, 1);
|
||||
e = x->uart_nmea_channel;
|
||||
flipper_format_write_uint32(file, "uart_nmea_channel", &e, 1);
|
||||
e = x->uart_general_channel;
|
||||
flipper_format_write_uint32(file, "uart_general_channel", &e, 1);
|
||||
}
|
||||
flipper_format_free(file);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
@@ -32,6 +32,18 @@ typedef enum {
|
||||
MenuStyleCount,
|
||||
} MenuStyle;
|
||||
|
||||
typedef enum {
|
||||
SpiDefault, // cs on pa4
|
||||
SpiExtra, // cs on pc3
|
||||
SpiCount,
|
||||
} SpiHandle;
|
||||
|
||||
typedef enum {
|
||||
UARTDefault, // pin 13,14
|
||||
UARTExtra, // pin 15,16
|
||||
UARTCount,
|
||||
} UARTChannel;
|
||||
|
||||
typedef struct {
|
||||
bool is_nsfw; // TODO: replace with packs text support
|
||||
|
||||
@@ -64,6 +76,11 @@ typedef struct {
|
||||
bool rgb_backlight;
|
||||
uint32_t butthurt_timer;
|
||||
uint32_t charge_cap;
|
||||
SpiHandle spi_cc1101_handle;
|
||||
SpiHandle spi_nrf24_handle;
|
||||
UARTChannel uart_esp_channel;
|
||||
UARTChannel uart_nmea_channel;
|
||||
UARTChannel uart_general_channel;
|
||||
} XtremeSettings;
|
||||
|
||||
void XTREME_SETTINGS_LOAD();
|
||||
|
||||
Reference in New Issue
Block a user