mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGhz: add some consts and fix unit tests
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
#include <lib/subghz/devices/devices.h>
|
||||
#include <lib/subghz/devices/cc1101_configs.h>
|
||||
|
||||
#define TAG "SubGhz TEST"
|
||||
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
|
||||
|
||||
@@ -226,7 +226,7 @@ void subghz_device_cc1101_ext_dump_state() {
|
||||
furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
}
|
||||
|
||||
void subghz_device_cc1101_ext_load_custom_preset(uint8_t* preset_data) {
|
||||
void subghz_device_cc1101_ext_load_custom_preset(const uint8_t* preset_data) {
|
||||
//load config
|
||||
furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
cc1101_reset(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
@@ -257,7 +257,7 @@ void subghz_device_cc1101_ext_load_custom_preset(uint8_t* preset_data) {
|
||||
}
|
||||
}
|
||||
|
||||
void subghz_device_cc1101_ext_load_registers(uint8_t* data) {
|
||||
void subghz_device_cc1101_ext_load_registers(const uint8_t* data) {
|
||||
furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
cc1101_reset(subghz_device_cc1101_ext->spi_bus_handle);
|
||||
uint32_t i = 0;
|
||||
|
||||
@@ -58,13 +58,13 @@ void subghz_device_cc1101_ext_dump_state();
|
||||
*
|
||||
* @param preset_data registers to load
|
||||
*/
|
||||
void subghz_device_cc1101_ext_load_custom_preset(uint8_t* preset_data);
|
||||
void subghz_device_cc1101_ext_load_custom_preset(const uint8_t* preset_data);
|
||||
|
||||
/** Load registers
|
||||
*
|
||||
* @param data Registers data
|
||||
*/
|
||||
void subghz_device_cc1101_ext_load_registers(uint8_t* data);
|
||||
void subghz_device_cc1101_ext_load_registers(const uint8_t* data);
|
||||
|
||||
/** Load PATABLE
|
||||
*
|
||||
|
||||
@@ -33,27 +33,27 @@ static void subghz_device_cc1101_ext_interconnect_load_preset(
|
||||
switch(preset) {
|
||||
case FuriHalSubGhzPresetOok650Async:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetOok270Async:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_270khz_async_regs);
|
||||
subghz_device_cc1101_preset_ook_270khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPreset2FSKDev238Async:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs);
|
||||
subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPreset2FSKDev476Async:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs);
|
||||
subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetMSK99_97KbAsync:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_msk_99_97kb_async_regs);
|
||||
subghz_device_cc1101_preset_msk_99_97kb_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetGFSK9_99KbAsync:
|
||||
subghz_device_cc1101_ext_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_gfsk_9_99kb_async_regs);
|
||||
subghz_device_cc1101_preset_gfsk_9_99kb_async_regs);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -61,8 +61,7 @@ void subghz_cli_command_tx_carrier(Cli* cli, FuriString* args, void* context) {
|
||||
}
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
||||
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
@@ -106,8 +105,7 @@ void subghz_cli_command_rx_carrier(Cli* cli, FuriString* args, void* context) {
|
||||
}
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
||||
printf("Receiving at frequency %lu Hz\r\n", frequency);
|
||||
printf("Press CTRL+C to stop\r\n");
|
||||
@@ -403,8 +401,7 @@ void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
|
||||
|
||||
// Configure radio
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
|
||||
@@ -141,8 +141,7 @@ void subghz_test_carrier_enter(void* context) {
|
||||
SubGhzTestCarrier* subghz_test_carrier = context;
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||
|
||||
|
||||
@@ -195,8 +195,7 @@ void subghz_test_packet_enter(void* context) {
|
||||
SubGhzTestPacket* instance = context;
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
|
||||
with_view_model(
|
||||
instance->view,
|
||||
|
||||
@@ -144,8 +144,7 @@ void subghz_test_static_enter(void* context) {
|
||||
SubGhzTestStatic* instance = context;
|
||||
|
||||
furi_hal_subghz_reset();
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
|
||||
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||
furi_hal_gpio_write(&gpio_cc1101_g0, false);
|
||||
|
||||
@@ -1397,9 +1397,9 @@ Function,+,furi_hal_subghz_is_async_tx_complete,_Bool,
|
||||
Function,+,furi_hal_subghz_is_frequency_valid,_Bool,uint32_t
|
||||
Function,+,furi_hal_subghz_is_rx_data_crc_valid,_Bool,
|
||||
Function,+,furi_hal_subghz_is_tx_allowed,_Bool,uint32_t
|
||||
Function,+,furi_hal_subghz_load_custom_preset,void,uint8_t*
|
||||
Function,+,furi_hal_subghz_load_custom_preset,void,const uint8_t*
|
||||
Function,+,furi_hal_subghz_load_patable,void,const uint8_t[8]
|
||||
Function,+,furi_hal_subghz_load_registers,void,uint8_t*
|
||||
Function,+,furi_hal_subghz_load_registers,void,const uint8_t*
|
||||
Function,+,furi_hal_subghz_read_packet,void,"uint8_t*, uint8_t*"
|
||||
Function,+,furi_hal_subghz_reset,void,
|
||||
Function,+,furi_hal_subghz_rx,void,
|
||||
|
||||
|
@@ -152,7 +152,7 @@ void furi_hal_subghz_dump_state() {
|
||||
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||
}
|
||||
|
||||
void furi_hal_subghz_load_custom_preset(uint8_t* preset_data) {
|
||||
void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data) {
|
||||
//load config
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||
@@ -182,7 +182,7 @@ void furi_hal_subghz_load_custom_preset(uint8_t* preset_data) {
|
||||
}
|
||||
}
|
||||
|
||||
void furi_hal_subghz_load_registers(uint8_t* data) {
|
||||
void furi_hal_subghz_load_registers(const uint8_t* data) {
|
||||
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||
uint32_t i = 0;
|
||||
|
||||
@@ -64,13 +64,13 @@ void furi_hal_subghz_dump_state();
|
||||
*
|
||||
* @param preset_data registers to load
|
||||
*/
|
||||
void furi_hal_subghz_load_custom_preset(uint8_t* preset_data);
|
||||
void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data);
|
||||
|
||||
/** Load registers
|
||||
*
|
||||
* @param data Registers data
|
||||
*/
|
||||
void furi_hal_subghz_load_registers(uint8_t* data);
|
||||
void furi_hal_subghz_load_registers(const uint8_t* data);
|
||||
|
||||
/** Load PATABLE
|
||||
*
|
||||
|
||||
@@ -30,28 +30,22 @@ static void subghz_device_cc1101_int_interconnect_load_preset(
|
||||
uint8_t* preset_data) {
|
||||
switch(preset) {
|
||||
case FuriHalSubGhzPresetOok650Async:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetOok270Async:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_ook_270khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_ook_270khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPreset2FSKDev238Async:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPreset2FSKDev476Async:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetMSK99_97KbAsync:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_msk_99_97kb_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_msk_99_97kb_async_regs);
|
||||
break;
|
||||
case FuriHalSubGhzPresetGFSK9_99KbAsync:
|
||||
furi_hal_subghz_load_custom_preset(
|
||||
(uint8_t*)subghz_device_cc1101_preset_gfsk_9_99kb_async_regs);
|
||||
furi_hal_subghz_load_custom_preset(subghz_device_cc1101_preset_gfsk_9_99kb_async_regs);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user