mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
prt2
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
#include <lib/subghz/subghz_file_encoder_worker.h>
|
#include <lib/subghz/subghz_file_encoder_worker.h>
|
||||||
#include <lib/subghz/protocols/protocol_items.h>
|
#include <lib/subghz/protocols/protocol_items.h>
|
||||||
#include <flipper_format/flipper_format_i.h>
|
#include <flipper_format/flipper_format_i.h>
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
|
|
||||||
#define TAG "SubGhz TEST"
|
#define TAG "SubGhz TEST"
|
||||||
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
|
#define KEYSTORE_DIR_NAME EXT_PATH("subghz/assets/keeloq_mfcodes")
|
||||||
@@ -49,12 +50,15 @@ static void subghz_test_init(void) {
|
|||||||
subghz_environment_set_protocol_registry(
|
subghz_environment_set_protocol_registry(
|
||||||
environment_handler, (void*)&subghz_protocol_registry);
|
environment_handler, (void*)&subghz_protocol_registry);
|
||||||
|
|
||||||
|
subghz_devices_init();
|
||||||
|
|
||||||
receiver_handler = subghz_receiver_alloc_init(environment_handler);
|
receiver_handler = subghz_receiver_alloc_init(environment_handler);
|
||||||
subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable);
|
subghz_receiver_set_filter(receiver_handler, SubGhzProtocolFlag_Decodable);
|
||||||
subghz_receiver_set_rx_callback(receiver_handler, subghz_test_rx_callback, NULL);
|
subghz_receiver_set_rx_callback(receiver_handler, subghz_test_rx_callback, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void subghz_test_deinit(void) {
|
static void subghz_test_deinit(void) {
|
||||||
|
subghz_devices_deinit();
|
||||||
subghz_receiver_free(receiver_handler);
|
subghz_receiver_free(receiver_handler);
|
||||||
subghz_environment_free(environment_handler);
|
subghz_environment_free(environment_handler);
|
||||||
}
|
}
|
||||||
@@ -68,7 +72,7 @@ static bool subghz_decoder_test(const char* path, const char* name_decoder) {
|
|||||||
|
|
||||||
if(decoder) {
|
if(decoder) {
|
||||||
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
||||||
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
|
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path, NULL)) {
|
||||||
// the worker needs a file in order to open and read part of the file
|
// the worker needs a file in order to open and read part of the file
|
||||||
furi_delay_ms(100);
|
furi_delay_ms(100);
|
||||||
|
|
||||||
@@ -108,7 +112,7 @@ static bool subghz_decode_random_test(const char* path) {
|
|||||||
uint32_t test_start = furi_get_tick();
|
uint32_t test_start = furi_get_tick();
|
||||||
|
|
||||||
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
file_worker_encoder_handler = subghz_file_encoder_worker_alloc();
|
||||||
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path)) {
|
if(subghz_file_encoder_worker_start(file_worker_encoder_handler, path, NULL)) {
|
||||||
// the worker needs a file in order to open and read part of the file
|
// the worker needs a file in order to open and read part of the file
|
||||||
furi_delay_ms(100);
|
furi_delay_ms(100);
|
||||||
|
|
||||||
|
|||||||
@@ -76,12 +76,15 @@ void subghz_chat_worker_free(SubGhzChatWorker* instance) {
|
|||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_chat_worker_start(SubGhzChatWorker* instance, uint32_t frequency) {
|
bool subghz_chat_worker_start(
|
||||||
|
SubGhzChatWorker* instance,
|
||||||
|
const SubGhzDevice* device,
|
||||||
|
uint32_t frequency) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(!instance->worker_running);
|
furi_assert(!instance->worker_running);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
|
|
||||||
if(subghz_tx_rx_worker_start(instance->subghz_txrx, frequency)) {
|
if(subghz_tx_rx_worker_start(instance->subghz_txrx, device, frequency)) {
|
||||||
furi_message_queue_reset(instance->event_queue);
|
furi_message_queue_reset(instance->event_queue);
|
||||||
subghz_tx_rx_worker_set_callback_have_read(
|
subghz_tx_rx_worker_set_callback_have_read(
|
||||||
instance->subghz_txrx, subghz_chat_worker_update_rx_event_chat, instance);
|
instance->subghz_txrx, subghz_chat_worker_update_rx_event_chat, instance);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
#include <cli/cli.h>
|
#include <cli/cli.h>
|
||||||
|
|
||||||
typedef struct SubGhzChatWorker SubGhzChatWorker;
|
typedef struct SubGhzChatWorker SubGhzChatWorker;
|
||||||
@@ -20,7 +21,10 @@ typedef struct {
|
|||||||
|
|
||||||
SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli);
|
SubGhzChatWorker* subghz_chat_worker_alloc(Cli* cli);
|
||||||
void subghz_chat_worker_free(SubGhzChatWorker* instance);
|
void subghz_chat_worker_free(SubGhzChatWorker* instance);
|
||||||
bool subghz_chat_worker_start(SubGhzChatWorker* instance, uint32_t frequency);
|
bool subghz_chat_worker_start(
|
||||||
|
SubGhzChatWorker* instance,
|
||||||
|
const SubGhzDevice* device,
|
||||||
|
uint32_t frequency);
|
||||||
void subghz_chat_worker_stop(SubGhzChatWorker* instance);
|
void subghz_chat_worker_stop(SubGhzChatWorker* instance);
|
||||||
bool subghz_chat_worker_is_running(SubGhzChatWorker* instance);
|
bool subghz_chat_worker_is_running(SubGhzChatWorker* instance);
|
||||||
SubGhzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance);
|
SubGhzChatEvent subghz_chat_worker_get_event_chat(SubGhzChatWorker* instance);
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ float subghz_threshold_rssi_get(SubGhzThresholdRssi* instance) {
|
|||||||
return instance->threshold_rssi;
|
return instance->threshold_rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
SubGhzThresholdRssiData subghz_threshold_get_rssi_data(SubGhzThresholdRssi* instance) {
|
SubGhzThresholdRssiData subghz_threshold_get_rssi_data(SubGhzThresholdRssi* instance, float rssi) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
float rssi = furi_hal_subghz_get_rssi();
|
|
||||||
SubGhzThresholdRssiData ret = {.rssi = rssi, .is_above = false};
|
SubGhzThresholdRssiData ret = {.rssi = rssi, .is_above = false};
|
||||||
|
|
||||||
if(float_is_equal(instance->threshold_rssi, SUBGHZ_RAW_THRESHOLD_MIN)) {
|
if(float_is_equal(instance->threshold_rssi, SUBGHZ_RAW_THRESHOLD_MIN)) {
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ float subghz_threshold_rssi_get(SubGhzThresholdRssi* instance);
|
|||||||
/** Check threshold
|
/** Check threshold
|
||||||
*
|
*
|
||||||
* @param instance Pointer to a SubGhzThresholdRssi
|
* @param instance Pointer to a SubGhzThresholdRssi
|
||||||
|
* @param rssi Current RSSI
|
||||||
* @return SubGhzThresholdRssiData
|
* @return SubGhzThresholdRssiData
|
||||||
*/
|
*/
|
||||||
SubGhzThresholdRssiData subghz_threshold_get_rssi_data(SubGhzThresholdRssi* instance);
|
SubGhzThresholdRssiData subghz_threshold_get_rssi_data(SubGhzThresholdRssi* instance, float rssi);
|
||||||
|
|||||||
@@ -1,9 +1,28 @@
|
|||||||
#include "subghz_txrx_i.h"
|
#include "subghz_txrx_i.h"
|
||||||
|
|
||||||
#include <lib/subghz/protocols/protocol_items.h>
|
#include <lib/subghz/protocols/protocol_items.h>
|
||||||
|
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||||
|
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||||
|
|
||||||
#include <lib/subghz/blocks/custom_btn.h>
|
#include <lib/subghz/blocks/custom_btn.h>
|
||||||
|
|
||||||
#define TAG "SubGhz"
|
#define TAG "SubGhz"
|
||||||
|
|
||||||
|
static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) {
|
||||||
|
UNUSED(instance);
|
||||||
|
uint8_t attempts = 0;
|
||||||
|
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
||||||
|
furi_hal_power_enable_otg();
|
||||||
|
//CC1101 power-up time
|
||||||
|
furi_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void subghz_txrx_radio_device_power_off(SubGhzTxRx* instance) {
|
||||||
|
UNUSED(instance);
|
||||||
|
if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg();
|
||||||
|
}
|
||||||
|
|
||||||
SubGhzTxRx* subghz_txrx_alloc() {
|
SubGhzTxRx* subghz_txrx_alloc() {
|
||||||
SubGhzTxRx* instance = malloc(sizeof(SubGhzTxRx));
|
SubGhzTxRx* instance = malloc(sizeof(SubGhzTxRx));
|
||||||
instance->setting = subghz_setting_alloc();
|
instance->setting = subghz_setting_alloc();
|
||||||
@@ -43,12 +62,24 @@ SubGhzTxRx* subghz_txrx_alloc() {
|
|||||||
instance->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
|
instance->worker, (SubGhzWorkerPairCallback)subghz_receiver_decode);
|
||||||
subghz_worker_set_context(instance->worker, instance->receiver);
|
subghz_worker_set_context(instance->worker, instance->receiver);
|
||||||
|
|
||||||
|
//set default device External
|
||||||
|
subghz_devices_init();
|
||||||
|
instance->radio_device_type =
|
||||||
|
subghz_txrx_radio_device_set(instance, SubGhzRadioDeviceTypeExternalCC1101);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_txrx_free(SubGhzTxRx* instance) {
|
void subghz_txrx_free(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
|
if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
|
||||||
|
subghz_txrx_radio_device_power_off(instance);
|
||||||
|
subghz_devices_end(instance->radio_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
subghz_devices_deinit();
|
||||||
|
|
||||||
subghz_worker_free(instance->worker);
|
subghz_worker_free(instance->worker);
|
||||||
subghz_receiver_free(instance->receiver);
|
subghz_receiver_free(instance->receiver);
|
||||||
subghz_environment_free(instance->environment);
|
subghz_environment_free(instance->environment);
|
||||||
@@ -128,29 +159,29 @@ void subghz_txrx_get_frequency_and_modulation(
|
|||||||
|
|
||||||
static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) {
|
static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_hal_subghz_reset();
|
subghz_devices_reset(instance->radio_device);
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->radio_device);
|
||||||
furi_hal_subghz_load_custom_preset(preset_data);
|
subghz_devices_load_preset(instance->radio_device, FuriHalSubGhzPresetCustom, preset_data);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
|
||||||
instance->txrx_state = SubGhzTxRxStateIDLE;
|
instance->txrx_state = SubGhzTxRxStateIDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) {
|
static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
// TODO
|
||||||
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
||||||
furi_crash("SubGhz: Incorrect RX frequency.");
|
furi_crash("SubGhz: Incorrect RX frequency.");
|
||||||
}
|
}
|
||||||
furi_assert(
|
furi_assert(
|
||||||
instance->txrx_state != SubGhzTxRxStateRx && instance->txrx_state != SubGhzTxRxStateSleep);
|
instance->txrx_state != SubGhzTxRxStateRx && instance->txrx_state != SubGhzTxRxStateSleep);
|
||||||
|
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->radio_device);
|
||||||
uint32_t value = furi_hal_subghz_set_frequency_and_path(frequency);
|
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
|
||||||
furi_hal_subghz_flush_rx();
|
|
||||||
subghz_txrx_speaker_on(instance);
|
|
||||||
furi_hal_subghz_rx();
|
|
||||||
|
|
||||||
furi_hal_subghz_start_async_rx(subghz_worker_rx_callback, instance->worker);
|
uint32_t value = subghz_devices_set_frequency(instance->radio_device, frequency);
|
||||||
|
subghz_devices_flush_rx(instance->radio_device);
|
||||||
|
subghz_txrx_speaker_on(instance);
|
||||||
|
|
||||||
|
subghz_devices_start_async_rx(
|
||||||
|
instance->radio_device, subghz_worker_rx_callback, instance->worker);
|
||||||
subghz_worker_start(instance->worker);
|
subghz_worker_start(instance->worker);
|
||||||
instance->txrx_state = SubGhzTxRxStateRx;
|
instance->txrx_state = SubGhzTxRxStateRx;
|
||||||
return value;
|
return value;
|
||||||
@@ -159,7 +190,7 @@ static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) {
|
|||||||
static void subghz_txrx_idle(SubGhzTxRx* instance) {
|
static void subghz_txrx_idle(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
|
furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->radio_device);
|
||||||
subghz_txrx_speaker_off(instance);
|
subghz_txrx_speaker_off(instance);
|
||||||
instance->txrx_state = SubGhzTxRxStateIDLE;
|
instance->txrx_state = SubGhzTxRxStateIDLE;
|
||||||
}
|
}
|
||||||
@@ -170,31 +201,30 @@ static void subghz_txrx_rx_end(SubGhzTxRx* instance) {
|
|||||||
|
|
||||||
if(subghz_worker_is_running(instance->worker)) {
|
if(subghz_worker_is_running(instance->worker)) {
|
||||||
subghz_worker_stop(instance->worker);
|
subghz_worker_stop(instance->worker);
|
||||||
furi_hal_subghz_stop_async_rx();
|
subghz_devices_stop_async_rx(instance->radio_device);
|
||||||
}
|
}
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->radio_device);
|
||||||
subghz_txrx_speaker_off(instance);
|
subghz_txrx_speaker_off(instance);
|
||||||
instance->txrx_state = SubGhzTxRxStateIDLE;
|
instance->txrx_state = SubGhzTxRxStateIDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_txrx_sleep(SubGhzTxRx* instance) {
|
void subghz_txrx_sleep(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_hal_subghz_sleep();
|
subghz_devices_sleep(instance->radio_device);
|
||||||
instance->txrx_state = SubGhzTxRxStateSleep;
|
instance->txrx_state = SubGhzTxRxStateSleep;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) {
|
static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
// TODO
|
||||||
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
||||||
furi_crash("SubGhz: Incorrect TX frequency.");
|
furi_crash("SubGhz: Incorrect TX frequency.");
|
||||||
}
|
}
|
||||||
furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
|
furi_assert(instance->txrx_state != SubGhzTxRxStateSleep);
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->radio_device);
|
||||||
furi_hal_subghz_set_frequency_and_path(frequency);
|
subghz_devices_set_frequency(instance->radio_device, frequency);
|
||||||
furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false);
|
|
||||||
furi_hal_gpio_init(
|
bool ret = subghz_devices_set_tx(instance->radio_device);
|
||||||
furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
|
||||||
bool ret = furi_hal_subghz_tx();
|
|
||||||
if(ret) {
|
if(ret) {
|
||||||
subghz_txrx_speaker_on(instance);
|
subghz_txrx_speaker_on(instance);
|
||||||
instance->txrx_state = SubGhzTxRxStateTx;
|
instance->txrx_state = SubGhzTxRxStateTx;
|
||||||
@@ -256,8 +286,8 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat*
|
|||||||
|
|
||||||
if(ret == SubGhzTxRxStartTxStateOk) {
|
if(ret == SubGhzTxRxStartTxStateOk) {
|
||||||
//Start TX
|
//Start TX
|
||||||
furi_hal_subghz_start_async_tx(
|
subghz_devices_start_async_tx(
|
||||||
subghz_transmitter_yield, instance->transmitter);
|
instance->radio_device, subghz_transmitter_yield, instance->transmitter);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = SubGhzTxRxStartTxStateErrorParserOthers;
|
ret = SubGhzTxRxStartTxStateErrorParserOthers;
|
||||||
@@ -300,7 +330,7 @@ static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
|
|||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(instance->txrx_state == SubGhzTxRxStateTx);
|
furi_assert(instance->txrx_state == SubGhzTxRxStateTx);
|
||||||
//Stop TX
|
//Stop TX
|
||||||
furi_hal_subghz_stop_async_tx();
|
subghz_devices_stop_async_tx(instance->radio_device);
|
||||||
subghz_transmitter_stop(instance->transmitter);
|
subghz_transmitter_stop(instance->transmitter);
|
||||||
subghz_transmitter_free(instance->transmitter);
|
subghz_transmitter_free(instance->transmitter);
|
||||||
|
|
||||||
@@ -313,7 +343,6 @@ static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
|
|||||||
subghz_txrx_idle(instance);
|
subghz_txrx_idle(instance);
|
||||||
subghz_txrx_speaker_off(instance);
|
subghz_txrx_speaker_off(instance);
|
||||||
//Todo: Show message
|
//Todo: Show message
|
||||||
// notification_message(notifications, &sequence_reset_red);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
|
FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
|
||||||
@@ -363,7 +392,7 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
|
|||||||
float rssi = -127.0f;
|
float rssi = -127.0f;
|
||||||
if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) {
|
if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) {
|
||||||
// See RSSI Calculation timings in CC1101 17.3 RSSI
|
// See RSSI Calculation timings in CC1101 17.3 RSSI
|
||||||
rssi = furi_hal_subghz_get_rssi();
|
rssi = subghz_devices_get_rssi(instance->radio_device);
|
||||||
|
|
||||||
// Stay if RSSI is high enough
|
// Stay if RSSI is high enough
|
||||||
if(rssi > -90.0f) {
|
if(rssi > -90.0f) {
|
||||||
@@ -420,13 +449,13 @@ void subghz_txrx_hopper_pause(SubGhzTxRx* instance) {
|
|||||||
void subghz_txrx_speaker_on(SubGhzTxRx* instance) {
|
void subghz_txrx_speaker_on(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
if(instance->debug_pin_state) {
|
if(instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(&gpio_ibutton);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_ibutton);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
||||||
if(furi_hal_speaker_acquire(30)) {
|
if(furi_hal_speaker_acquire(30)) {
|
||||||
if(!instance->debug_pin_state) {
|
if(!instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
instance->speaker_state = SubGhzSpeakerStateDisable;
|
instance->speaker_state = SubGhzSpeakerStateDisable;
|
||||||
@@ -437,12 +466,12 @@ void subghz_txrx_speaker_on(SubGhzTxRx* instance) {
|
|||||||
void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
|
void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
if(instance->debug_pin_state) {
|
if(instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
|
||||||
}
|
}
|
||||||
if(instance->speaker_state != SubGhzSpeakerStateDisable) {
|
if(instance->speaker_state != SubGhzSpeakerStateDisable) {
|
||||||
if(furi_hal_speaker_is_mine()) {
|
if(furi_hal_speaker_is_mine()) {
|
||||||
if(!instance->debug_pin_state) {
|
if(!instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
|
||||||
}
|
}
|
||||||
furi_hal_speaker_release();
|
furi_hal_speaker_release();
|
||||||
if(instance->speaker_state == SubGhzSpeakerStateShutdown)
|
if(instance->speaker_state == SubGhzSpeakerStateShutdown)
|
||||||
@@ -454,12 +483,12 @@ void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
|
|||||||
void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
|
void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
if(instance->debug_pin_state) {
|
if(instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
|
||||||
}
|
}
|
||||||
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
||||||
if(furi_hal_speaker_is_mine()) {
|
if(furi_hal_speaker_is_mine()) {
|
||||||
if(!instance->debug_pin_state) {
|
if(!instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(NULL);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,12 +497,12 @@ void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
|
|||||||
void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
|
void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
if(instance->debug_pin_state) {
|
if(instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(&gpio_ibutton);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_ibutton);
|
||||||
}
|
}
|
||||||
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
if(instance->speaker_state == SubGhzSpeakerStateEnable) {
|
||||||
if(furi_hal_speaker_is_mine()) {
|
if(furi_hal_speaker_is_mine()) {
|
||||||
if(!instance->debug_pin_state) {
|
if(!instance->debug_pin_state) {
|
||||||
furi_hal_subghz_set_async_mirror_pin(&gpio_speaker);
|
subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -548,6 +577,66 @@ void subghz_txrx_set_raw_file_encoder_worker_callback_end(
|
|||||||
context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool subghz_txrx_radio_device_is_connect_external(SubGhzTxRx* instance, const char* name) {
|
||||||
|
furi_assert(instance);
|
||||||
|
|
||||||
|
bool is_connect = false;
|
||||||
|
bool is_otg_enabled = furi_hal_power_is_otg_enabled();
|
||||||
|
|
||||||
|
if(!is_otg_enabled) {
|
||||||
|
subghz_txrx_radio_device_power_on(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
is_connect = subghz_devices_is_connect(subghz_devices_get_by_name(name));
|
||||||
|
|
||||||
|
if(!is_otg_enabled) {
|
||||||
|
subghz_txrx_radio_device_power_off(instance);
|
||||||
|
}
|
||||||
|
return is_connect;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubGhzRadioDeviceType
|
||||||
|
subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type) {
|
||||||
|
furi_assert(instance);
|
||||||
|
|
||||||
|
if(radio_device_type == SubGhzRadioDeviceTypeExternalCC1101 &&
|
||||||
|
subghz_txrx_radio_device_is_connect_external(instance, SUBGHZ_DEVICE_CC1101_EXT_NAME)) {
|
||||||
|
subghz_txrx_radio_device_power_on(instance);
|
||||||
|
instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
|
||||||
|
subghz_devices_begin(instance->radio_device);
|
||||||
|
instance->radio_device_type = SubGhzRadioDeviceTypeExternalCC1101;
|
||||||
|
} else {
|
||||||
|
subghz_txrx_radio_device_power_off(instance);
|
||||||
|
if(instance->radio_device_type != SubGhzRadioDeviceTypeInternal) {
|
||||||
|
subghz_devices_end(instance->radio_device);
|
||||||
|
}
|
||||||
|
instance->radio_device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||||
|
instance->radio_device_type = SubGhzRadioDeviceTypeInternal;
|
||||||
|
}
|
||||||
|
|
||||||
|
return instance->radio_device_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance) {
|
||||||
|
furi_assert(instance);
|
||||||
|
return instance->radio_device_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
float subghz_txrx_radio_device_get_rssi(SubGhzTxRx* instance) {
|
||||||
|
furi_assert(instance);
|
||||||
|
return subghz_devices_get_rssi(instance->radio_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) {
|
||||||
|
furi_assert(instance);
|
||||||
|
return subghz_devices_get_name(instance->radio_device);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency) {
|
||||||
|
furi_assert(instance);
|
||||||
|
return subghz_devices_is_frequency_valid(instance->radio_device, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) {
|
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
instance->debug_pin_state = state;
|
instance->debug_pin_state = state;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <lib/subghz/receiver.h>
|
#include <lib/subghz/receiver.h>
|
||||||
#include <lib/subghz/transmitter.h>
|
#include <lib/subghz/transmitter.h>
|
||||||
#include <lib/subghz/protocols/raw.h>
|
#include <lib/subghz/protocols/raw.h>
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
|
|
||||||
typedef struct SubGhzTxRx SubGhzTxRx;
|
typedef struct SubGhzTxRx SubGhzTxRx;
|
||||||
|
|
||||||
@@ -290,6 +291,51 @@ void subghz_txrx_set_raw_file_encoder_worker_callback_end(
|
|||||||
SubGhzProtocolEncoderRAWCallbackEnd callback,
|
SubGhzProtocolEncoderRAWCallbackEnd callback,
|
||||||
void* context);
|
void* context);
|
||||||
|
|
||||||
|
/* Checking if an external radio device is connected
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @param name Name of external radio device
|
||||||
|
* @return bool True if is connected to the external radio device
|
||||||
|
*/
|
||||||
|
bool subghz_txrx_radio_device_is_connect_external(SubGhzTxRx* instance, const char* name);
|
||||||
|
|
||||||
|
/* Set the selected radio device to use
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @param radio_device_type Radio device type
|
||||||
|
* @return SubGhzRadioDeviceType Type of installed radio device
|
||||||
|
*/
|
||||||
|
SubGhzRadioDeviceType
|
||||||
|
subghz_txrx_radio_device_set(SubGhzTxRx* instance, SubGhzRadioDeviceType radio_device_type);
|
||||||
|
|
||||||
|
/* Get the selected radio device to use
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @return SubGhzRadioDeviceType Type of installed radio device
|
||||||
|
*/
|
||||||
|
SubGhzRadioDeviceType subghz_txrx_radio_device_get(SubGhzTxRx* instance);
|
||||||
|
|
||||||
|
/* Get RSSI the selected radio device to use
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @return float RSSI
|
||||||
|
*/
|
||||||
|
float subghz_txrx_radio_device_get_rssi(SubGhzTxRx* instance);
|
||||||
|
|
||||||
|
/* Get name the selected radio device to use
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @return const char* Name of installed radio device
|
||||||
|
*/
|
||||||
|
const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance);
|
||||||
|
|
||||||
|
/* Get get intelligence whether frequency the selected radio device to use
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @return bool True if the frequency is valid
|
||||||
|
*/
|
||||||
|
bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency);
|
||||||
|
|
||||||
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state);
|
void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state);
|
||||||
bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);
|
bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "subghz_txrx.h"
|
#include "subghz_txrx.h"
|
||||||
|
|
||||||
struct SubGhzTxRx {
|
struct SubGhzTxRx {
|
||||||
@@ -21,6 +21,8 @@ struct SubGhzTxRx {
|
|||||||
|
|
||||||
SubGhzTxRxState txrx_state;
|
SubGhzTxRxState txrx_state;
|
||||||
SubGhzSpeakerState speaker_state;
|
SubGhzSpeakerState speaker_state;
|
||||||
|
const SubGhzDevice* radio_device;
|
||||||
|
SubGhzRadioDeviceType radio_device_type;
|
||||||
|
|
||||||
SubGhzTxRxNeedSaveCallback need_save_callback;
|
SubGhzTxRxNeedSaveCallback need_save_callback;
|
||||||
void* need_save_context;
|
void* need_save_context;
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ typedef enum {
|
|||||||
SubGhzSpeakerStateEnable,
|
SubGhzSpeakerStateEnable,
|
||||||
} SubGhzSpeakerState;
|
} SubGhzSpeakerState;
|
||||||
|
|
||||||
|
/** SubGhzRadioDeviceType */
|
||||||
|
typedef enum {
|
||||||
|
SubGhzRadioDeviceTypeAuto,
|
||||||
|
SubGhzRadioDeviceTypeInternal,
|
||||||
|
SubGhzRadioDeviceTypeExternalCC1101,
|
||||||
|
} SubGhzRadioDeviceType;
|
||||||
|
|
||||||
/** SubGhzRxKeyState state */
|
/** SubGhzRxKeyState state */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SubGhzRxKeyStateIDLE,
|
SubGhzRxKeyStateIDLE,
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ ADD_SCENE(subghz, decode_raw, DecodeRAW)
|
|||||||
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
ADD_SCENE(subghz, delete_raw, DeleteRAW)
|
||||||
ADD_SCENE(subghz, need_saving, NeedSaving)
|
ADD_SCENE(subghz, need_saving, NeedSaving)
|
||||||
ADD_SCENE(subghz, rpc, Rpc)
|
ADD_SCENE(subghz, rpc, Rpc)
|
||||||
|
ADD_SCENE(subghz, radio_setting, RadioSettings)
|
||||||
|
|||||||
@@ -93,7 +93,9 @@ bool subghz_scene_decode_raw_start(SubGhz* subghz) {
|
|||||||
|
|
||||||
subghz->decode_raw_file_worker_encoder = subghz_file_encoder_worker_alloc();
|
subghz->decode_raw_file_worker_encoder = subghz_file_encoder_worker_alloc();
|
||||||
if(subghz_file_encoder_worker_start(
|
if(subghz_file_encoder_worker_start(
|
||||||
subghz->decode_raw_file_worker_encoder, furi_string_get_cstr(file_name))) {
|
subghz->decode_raw_file_worker_encoder,
|
||||||
|
furi_string_get_cstr(file_name),
|
||||||
|
subghz_txrx_radio_device_get_name(subghz->txrx))) {
|
||||||
//the worker needs a file in order to open and read part of the file
|
//the worker needs a file in order to open and read part of the file
|
||||||
furi_delay_ms(100);
|
furi_delay_ms(100);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
65
applications/main/subghz/scenes/subghz_scene_radio_setting.c
Normal file
65
applications/main/subghz/scenes/subghz_scene_radio_setting.c
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#include "../subghz_i.h"
|
||||||
|
#include <lib/toolbox/value_index.h>
|
||||||
|
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||||
|
|
||||||
|
enum SubGhzRadioSettingIndex {
|
||||||
|
SubGhzRadioSettingIndexDevice,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define RADIO_DEVICE_COUNT 2
|
||||||
|
const char* const radio_device_text[RADIO_DEVICE_COUNT] = {
|
||||||
|
"Internal",
|
||||||
|
"External",
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32_t radio_device_value[RADIO_DEVICE_COUNT] = {
|
||||||
|
SubGhzRadioDeviceTypeInternal,
|
||||||
|
SubGhzRadioDeviceTypeExternalCC1101,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void subghz_scene_radio_setting_set_device(VariableItem* item) {
|
||||||
|
SubGhz* subghz = variable_item_get_context(item);
|
||||||
|
uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
|
if(!subghz_txrx_radio_device_is_connect_external(subghz->txrx, SUBGHZ_DEVICE_CC1101_EXT_NAME) &&
|
||||||
|
radio_device_value[index] == SubGhzRadioDeviceTypeExternalCC1101) {
|
||||||
|
//ToDo correct if there is more than 1 module
|
||||||
|
index = 0;
|
||||||
|
}
|
||||||
|
variable_item_set_current_value_text(item, radio_device_text[index]);
|
||||||
|
subghz_txrx_radio_device_set(subghz->txrx, radio_device_value[index]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void subghz_scene_radio_setting_on_enter(void* context) {
|
||||||
|
SubGhz* subghz = context;
|
||||||
|
VariableItem* item;
|
||||||
|
uint8_t value_index;
|
||||||
|
|
||||||
|
item = variable_item_list_add(
|
||||||
|
subghz->variable_item_list,
|
||||||
|
"Module",
|
||||||
|
RADIO_DEVICE_COUNT,
|
||||||
|
subghz_scene_radio_setting_set_device,
|
||||||
|
subghz);
|
||||||
|
value_index = value_index_uint32(
|
||||||
|
subghz_txrx_radio_device_get(subghz->txrx), radio_device_value, RADIO_DEVICE_COUNT);
|
||||||
|
variable_item_set_current_value_index(item, value_index);
|
||||||
|
variable_item_set_current_value_text(item, radio_device_text[value_index]);
|
||||||
|
|
||||||
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool subghz_scene_radio_setting_on_event(void* context, SceneManagerEvent event) {
|
||||||
|
SubGhz* subghz = context;
|
||||||
|
bool consumed = false;
|
||||||
|
UNUSED(subghz);
|
||||||
|
UNUSED(event);
|
||||||
|
|
||||||
|
return consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void subghz_scene_radio_setting_on_exit(void* context) {
|
||||||
|
SubGhz* subghz = context;
|
||||||
|
variable_item_list_set_selected_item(subghz->variable_item_list, 0);
|
||||||
|
variable_item_list_reset(subghz->variable_item_list);
|
||||||
|
}
|
||||||
@@ -1,17 +1,17 @@
|
|||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
|
|
||||||
#define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
// #define EXT_MODULES_COUNT (sizeof(radio_modules_variables_text) / sizeof(char* const))
|
||||||
const char* const radio_modules_variables_text[] = {
|
// const char* const radio_modules_variables_text[] = {
|
||||||
"Internal",
|
// "Internal",
|
||||||
"External",
|
// "External",
|
||||||
};
|
// };
|
||||||
|
|
||||||
#define EXT_MOD_POWER_COUNT 2
|
// #define EXT_MOD_POWER_COUNT 2
|
||||||
const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
// const char* const ext_mod_power_text[EXT_MOD_POWER_COUNT] = {
|
||||||
"ON",
|
// "ON",
|
||||||
"OFF",
|
// "OFF",
|
||||||
};
|
// };
|
||||||
|
|
||||||
#define TIMESTAMP_NAMES_COUNT 2
|
#define TIMESTAMP_NAMES_COUNT 2
|
||||||
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
const char* const timestamp_names_text[TIMESTAMP_NAMES_COUNT] = {
|
||||||
@@ -35,20 +35,20 @@ const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
|
|||||||
"+10",
|
"+10",
|
||||||
};
|
};
|
||||||
|
|
||||||
static void subghz_scene_ext_module_changed(VariableItem* item) {
|
// static void subghz_scene_ext_module_changed(VariableItem* item) {
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
// SubGhz* subghz = variable_item_get_context(item);
|
||||||
uint8_t value_index_exm = variable_item_get_current_value_index(item);
|
// uint8_t value_index_exm = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index_exm]);
|
||||||
|
|
||||||
subghz->last_settings->external_module_enabled = value_index_exm == 1;
|
// subghz->last_settings->external_module_enabled = value_index_exm == 1;
|
||||||
subghz_last_settings_save(subghz->last_settings);
|
// subghz_last_settings_save(subghz->last_settings);
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void subghz_ext_module_start_var_list_enter_callback(void* context, uint32_t index) {
|
// static void subghz_ext_module_start_var_list_enter_callback(void* context, uint32_t index) {
|
||||||
SubGhz* subghz = context;
|
// SubGhz* subghz = context;
|
||||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
// view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) {
|
static void subghz_scene_receiver_config_set_debug_pin(VariableItem* item) {
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
SubGhz* subghz = variable_item_get_context(item);
|
||||||
@@ -88,22 +88,22 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
// static void subghz_scene_receiver_config_set_ext_mod_power(VariableItem* item) {
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
// SubGhz* subghz = variable_item_get_context(item);
|
||||||
uint8_t index = variable_item_get_current_value_index(item);
|
// uint8_t index = variable_item_get_current_value_index(item);
|
||||||
|
|
||||||
variable_item_set_current_value_text(item, ext_mod_power_text[index]);
|
// variable_item_set_current_value_text(item, ext_mod_power_text[index]);
|
||||||
|
|
||||||
furi_hal_subghz_set_external_power_disable(index == 1);
|
// furi_hal_subghz_set_external_power_disable(index == 1);
|
||||||
if(index == 1) {
|
// if(index == 1) {
|
||||||
furi_hal_subghz_disable_ext_power();
|
// furi_hal_subghz_disable_ext_power();
|
||||||
} else {
|
// } else {
|
||||||
furi_hal_subghz_enable_ext_power();
|
// furi_hal_subghz_enable_ext_power();
|
||||||
}
|
// }
|
||||||
|
|
||||||
subghz->last_settings->external_module_power_5v_disable = index == 1;
|
// subghz->last_settings->external_module_power_5v_disable = index == 1;
|
||||||
subghz_last_settings_save(subghz->last_settings);
|
// subghz_last_settings_save(subghz->last_settings);
|
||||||
}
|
// }
|
||||||
|
|
||||||
static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* item) {
|
static void subghz_scene_receiver_config_set_timestamp_file_names(VariableItem* item) {
|
||||||
SubGhz* subghz = variable_item_get_context(item);
|
SubGhz* subghz = variable_item_get_context(item);
|
||||||
@@ -120,26 +120,26 @@ void subghz_scene_radio_settings_on_enter(void* context) {
|
|||||||
|
|
||||||
VariableItemList* variable_item_list = subghz->variable_item_list;
|
VariableItemList* variable_item_list = subghz->variable_item_list;
|
||||||
uint8_t value_index;
|
uint8_t value_index;
|
||||||
|
VariableItem* item;
|
||||||
|
|
||||||
value_index = furi_hal_subghz.radio_type;
|
// VariableItem* item = variable_item_list_add(
|
||||||
VariableItem* item = variable_item_list_add(
|
// variable_item_list, "Module", EXT_MODULES_COUNT, subghz_scene_ext_module_changed, subghz);
|
||||||
variable_item_list, "Module", EXT_MODULES_COUNT, subghz_scene_ext_module_changed, subghz);
|
|
||||||
|
|
||||||
variable_item_list_set_enter_callback(
|
// variable_item_list_set_enter_callback(
|
||||||
variable_item_list, subghz_ext_module_start_var_list_enter_callback, subghz);
|
// variable_item_list, subghz_ext_module_start_var_list_enter_callback, subghz);
|
||||||
|
// value_index = furi_hal_subghz.radio_type;
|
||||||
|
// variable_item_set_current_value_index(item, value_index);
|
||||||
|
// variable_item_set_current_value_text(item, radio_modules_variables_text[value_index]);
|
||||||
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
// item = variable_item_list_add(
|
||||||
variable_item_set_current_value_text(item, radio_modules_variables_text[value_index]);
|
// subghz->variable_item_list,
|
||||||
|
// "Ext Radio 5v",
|
||||||
item = variable_item_list_add(
|
// EXT_MOD_POWER_COUNT,
|
||||||
subghz->variable_item_list,
|
// subghz_scene_receiver_config_set_ext_mod_power,
|
||||||
"Ext Radio 5v",
|
// subghz);
|
||||||
EXT_MOD_POWER_COUNT,
|
// value_index = furi_hal_subghz_get_external_power_disable();
|
||||||
subghz_scene_receiver_config_set_ext_mod_power,
|
// variable_item_set_current_value_index(item, value_index);
|
||||||
subghz);
|
// variable_item_set_current_value_text(item, ext_mod_power_text[value_index]);
|
||||||
value_index = furi_hal_subghz_get_external_power_disable();
|
|
||||||
variable_item_set_current_value_index(item, value_index);
|
|
||||||
variable_item_set_current_value_text(item, ext_mod_power_text[value_index]);
|
|
||||||
|
|
||||||
item = variable_item_list_add(
|
item = variable_item_list_add(
|
||||||
subghz->variable_item_list,
|
subghz->variable_item_list,
|
||||||
@@ -228,19 +228,19 @@ bool subghz_scene_radio_settings_on_event(void* context, SceneManagerEvent event
|
|||||||
UNUSED(event);
|
UNUSED(event);
|
||||||
|
|
||||||
// Set selected radio module
|
// Set selected radio module
|
||||||
furi_hal_subghz_select_radio_type(subghz->last_settings->external_module_enabled);
|
// furi_hal_subghz_select_radio_type(subghz->last_settings->external_module_enabled);
|
||||||
furi_hal_subghz_init_radio_type(subghz->last_settings->external_module_enabled);
|
// furi_hal_subghz_init_radio_type(subghz->last_settings->external_module_enabled);
|
||||||
|
|
||||||
furi_hal_subghz_enable_ext_power();
|
// furi_hal_subghz_enable_ext_power();
|
||||||
|
|
||||||
// Check if module is present, if no -> show error
|
// Check if module is present, if no -> show error
|
||||||
if(!furi_hal_subghz_check_radio()) {
|
// if(!furi_hal_subghz_check_radio()) {
|
||||||
subghz->last_settings->external_module_enabled = false;
|
// subghz->last_settings->external_module_enabled = false;
|
||||||
furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
// furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
||||||
furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
// furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
||||||
furi_string_set(subghz->error_str, "Please connect\nexternal radio");
|
// furi_string_set(subghz->error_str, "Please connect\nexternal radio");
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
// scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
|
|||||||
|
|
||||||
furi_string_free(frequency_str);
|
furi_string_free(frequency_str);
|
||||||
furi_string_free(modulation_str);
|
furi_string_free(modulation_str);
|
||||||
|
|
||||||
|
subghz_read_raw_set_radio_device_type(
|
||||||
|
subghz->subghz_read_raw, subghz_txrx_radio_device_get(subghz->txrx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
|
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
|
||||||
@@ -247,7 +250,9 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
|||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
|
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
|
||||||
subghz_protocol_raw_gen_fff_data(
|
subghz_protocol_raw_gen_fff_data(
|
||||||
subghz_txrx_get_fff_data(subghz->txrx), furi_string_get_cstr(temp_str));
|
subghz_txrx_get_fff_data(subghz->txrx),
|
||||||
|
furi_string_get_cstr(temp_str),
|
||||||
|
subghz_txrx_radio_device_get_name(subghz->txrx));
|
||||||
furi_string_free(temp_str);
|
furi_string_free(temp_str);
|
||||||
|
|
||||||
if(spl_count > 0) {
|
if(spl_count > 0) {
|
||||||
@@ -307,8 +312,8 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
|||||||
subghz_read_raw_update_sample_write(
|
subghz_read_raw_update_sample_write(
|
||||||
subghz->subghz_read_raw, subghz_protocol_raw_get_sample_write(decoder_raw));
|
subghz->subghz_read_raw, subghz_protocol_raw_get_sample_write(decoder_raw));
|
||||||
|
|
||||||
SubGhzThresholdRssiData ret_rssi =
|
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(
|
||||||
subghz_threshold_get_rssi_data(subghz->threshold_rssi);
|
subghz->threshold_rssi, subghz_txrx_radio_device_get_rssi(subghz->txrx));
|
||||||
subghz_read_raw_add_data_rssi(
|
subghz_read_raw_add_data_rssi(
|
||||||
subghz->subghz_read_raw, ret_rssi.rssi, ret_rssi.is_above);
|
subghz->subghz_read_raw, ret_rssi.rssi, ret_rssi.is_above);
|
||||||
subghz_protocol_raw_save_to_file_pause(decoder_raw, !ret_rssi.is_above);
|
subghz_protocol_raw_save_to_file_pause(decoder_raw, !ret_rssi.is_above);
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
|||||||
furi_string_printf(
|
furi_string_printf(
|
||||||
modulation_str,
|
modulation_str,
|
||||||
"%s Mod: %s",
|
"%s Mod: %s",
|
||||||
furi_hal_subghz_get_radio_type() ? "Ext" : "Int",
|
(subghz_txrx_radio_device_get(subghz->txrx) == SubGhzRadioDeviceTypeInternal) ?
|
||||||
|
"Int" :
|
||||||
|
"Ext",
|
||||||
furi_string_get_cstr(temp_str));
|
furi_string_get_cstr(temp_str));
|
||||||
furi_string_free(temp_str);
|
furi_string_free(temp_str);
|
||||||
}
|
}
|
||||||
@@ -78,6 +80,9 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
|||||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||||
}
|
}
|
||||||
furi_string_free(history_stat_str);
|
furi_string_free(history_stat_str);
|
||||||
|
|
||||||
|
subghz_view_receiver_set_radio_device_type(
|
||||||
|
subghz->subghz_receiver, subghz_txrx_radio_device_get(subghz->txrx));
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_scene_receiver_callback(SubGhzCustomEvent event, void* context) {
|
void subghz_scene_receiver_callback(SubGhzCustomEvent event, void* context) {
|
||||||
@@ -273,8 +278,8 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
|||||||
subghz_scene_receiver_update_statusbar(subghz);
|
subghz_scene_receiver_update_statusbar(subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get RSSI
|
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(
|
||||||
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(subghz->threshold_rssi);
|
subghz->threshold_rssi, subghz_txrx_radio_device_get_rssi(subghz->txrx));
|
||||||
|
|
||||||
subghz_receiver_rssi(subghz->subghz_receiver, ret_rssi.rssi);
|
subghz_receiver_rssi(subghz->subghz_receiver, ret_rssi.rssi);
|
||||||
subghz_protocol_decoder_bin_raw_data_input_rssi(
|
subghz_protocol_decoder_bin_raw_data_input_rssi(
|
||||||
|
|||||||
@@ -165,7 +165,8 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
|||||||
SubGhzCustomEventManagerNoSet) {
|
SubGhzCustomEventManagerNoSet) {
|
||||||
subghz_protocol_raw_gen_fff_data(
|
subghz_protocol_raw_gen_fff_data(
|
||||||
subghz_txrx_get_fff_data(subghz->txrx),
|
subghz_txrx_get_fff_data(subghz->txrx),
|
||||||
furi_string_get_cstr(subghz->file_path));
|
furi_string_get_cstr(subghz->file_path),
|
||||||
|
subghz_txrx_radio_device_get_name(subghz->txrx));
|
||||||
scene_manager_set_scene_state(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "../subghz_i.h"
|
#include "../subghz_i.h"
|
||||||
#include <dolphin/dolphin.h>
|
#include <dolphin/dolphin.h>
|
||||||
|
|
||||||
|
// TODO move RadioSettings to ExtraSettings
|
||||||
#include <lib/subghz/protocols/raw.h>
|
#include <lib/subghz/protocols/raw.h>
|
||||||
|
|
||||||
enum SubmenuIndex {
|
enum SubmenuIndex {
|
||||||
@@ -11,6 +12,7 @@ enum SubmenuIndex {
|
|||||||
SubmenuIndexFrequencyAnalyzer,
|
SubmenuIndexFrequencyAnalyzer,
|
||||||
SubmenuIndexReadRAW,
|
SubmenuIndexReadRAW,
|
||||||
SubmenuIndexExtSettings,
|
SubmenuIndexExtSettings,
|
||||||
|
SubmenuIndexRadioSetting,
|
||||||
};
|
};
|
||||||
|
|
||||||
void subghz_scene_start_submenu_callback(void* context, uint32_t index) {
|
void subghz_scene_start_submenu_callback(void* context, uint32_t index) {
|
||||||
@@ -52,6 +54,12 @@ void subghz_scene_start_on_enter(void* context) {
|
|||||||
SubmenuIndexExtSettings,
|
SubmenuIndexExtSettings,
|
||||||
subghz_scene_start_submenu_callback,
|
subghz_scene_start_submenu_callback,
|
||||||
subghz);
|
subghz);
|
||||||
|
submenu_add_item(
|
||||||
|
subghz->submenu,
|
||||||
|
"Radio Settings2",
|
||||||
|
SubmenuIndexRadioSetting,
|
||||||
|
subghz_scene_start_submenu_callback,
|
||||||
|
subghz);
|
||||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
||||||
submenu_add_item(
|
submenu_add_item(
|
||||||
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
subghz->submenu, "Test", SubmenuIndexTest, subghz_scene_start_submenu_callback, subghz);
|
||||||
@@ -70,54 +78,48 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
|||||||
view_dispatcher_stop(subghz->view_dispatcher);
|
view_dispatcher_stop(subghz->view_dispatcher);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == SubmenuIndexExtSettings) {
|
if(event.event == SubmenuIndexReadRAW) {
|
||||||
scene_manager_set_scene_state(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexExtSettings);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexReadRAW);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneExtModuleSettings);
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||||
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||||
|
return true;
|
||||||
|
} else if(event.event == SubmenuIndexRead) {
|
||||||
|
scene_manager_set_scene_state(
|
||||||
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexRead);
|
||||||
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);
|
||||||
|
return true;
|
||||||
|
} else if(event.event == SubmenuIndexSaved) {
|
||||||
|
scene_manager_set_scene_state(
|
||||||
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexSaved);
|
||||||
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexAddManually) {
|
} else if(event.event == SubmenuIndexAddManually) {
|
||||||
scene_manager_set_scene_state(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexAddManually);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexAddManually);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetType);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSetType);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else if(event.event == SubmenuIndexFrequencyAnalyzer) {
|
||||||
furi_hal_subghz_enable_ext_power();
|
scene_manager_set_scene_state(
|
||||||
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer);
|
||||||
if(!furi_hal_subghz_check_radio()) {
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer);
|
||||||
furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
dolphin_deed(DolphinDeedSubGhzFrequencyAnalyzer);
|
||||||
furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
return true;
|
||||||
subghz->last_settings->external_module_enabled = false;
|
} else if(event.event == SubmenuIndexTest) {
|
||||||
furi_string_set(subghz->error_str, "Please connect\nexternal radio");
|
scene_manager_set_scene_state(
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
|
||||||
return true;
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTest);
|
||||||
} else if(event.event == SubmenuIndexReadRAW) {
|
return true;
|
||||||
scene_manager_set_scene_state(
|
} else if(event.event == SubmenuIndexExtSettings) {
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexReadRAW);
|
scene_manager_set_scene_state(
|
||||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexExtSettings);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneExtModuleSettings);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexRead) {
|
} else if(event.event == SubmenuIndexRadioSetting) {
|
||||||
scene_manager_set_scene_state(
|
scene_manager_set_scene_state(
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexRead);
|
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexRadioSetting);
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneRadioSettings);
|
||||||
return true;
|
return true;
|
||||||
} else if(event.event == SubmenuIndexSaved) {
|
|
||||||
scene_manager_set_scene_state(
|
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexSaved);
|
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
|
||||||
return true;
|
|
||||||
} else if(event.event == SubmenuIndexFrequencyAnalyzer) {
|
|
||||||
scene_manager_set_scene_state(
|
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer);
|
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer);
|
|
||||||
dolphin_deed(DolphinDeedSubGhzFrequencyAnalyzer);
|
|
||||||
return true;
|
|
||||||
} else if(event.event == SubmenuIndexTest) {
|
|
||||||
scene_manager_set_scene_state(
|
|
||||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);
|
|
||||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTest);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
|||||||
furi_string_free(modulation_str);
|
furi_string_free(modulation_str);
|
||||||
furi_string_free(key_str);
|
furi_string_free(key_str);
|
||||||
}
|
}
|
||||||
|
subghz_view_transmitter_set_radio_device_type(
|
||||||
|
subghz->subghz_transmitter, subghz_txrx_radio_device_get(subghz->txrx));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,9 @@
|
|||||||
#include <lib/subghz/transmitter.h>
|
#include <lib/subghz/transmitter.h>
|
||||||
#include <lib/subghz/subghz_file_encoder_worker.h>
|
#include <lib/subghz/subghz_file_encoder_worker.h>
|
||||||
#include <lib/subghz/protocols/protocol_items.h>
|
#include <lib/subghz/protocols/protocol_items.h>
|
||||||
|
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h>
|
||||||
|
#include <lib/subghz/devices/cc1101_int/cc1101_int_interconnect.h>
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
|
|
||||||
#include "helpers/subghz_chat.h"
|
#include "helpers/subghz_chat.h"
|
||||||
|
|
||||||
@@ -19,6 +22,19 @@
|
|||||||
#define SUBGHZ_FREQUENCY_RANGE_STR \
|
#define SUBGHZ_FREQUENCY_RANGE_STR \
|
||||||
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
|
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
|
||||||
|
|
||||||
|
static void subghz_cli_radio_device_power_on() {
|
||||||
|
uint8_t attempts = 0;
|
||||||
|
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
||||||
|
furi_hal_power_enable_otg();
|
||||||
|
//CC1101 power-up time
|
||||||
|
furi_delay_ms(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void subghz_cli_radio_device_power_off() {
|
||||||
|
if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg();
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_cli_command_tx_carrier(Cli* cli, FuriString* args, void* context) {
|
void subghz_cli_command_tx_carrier(Cli* cli, FuriString* args, void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
uint32_t frequency = 433920000;
|
uint32_t frequency = 433920000;
|
||||||
@@ -41,10 +57,9 @@ void subghz_cli_command_tx_carrier(Cli* cli, FuriString* args, void* context) {
|
|||||||
furi_hal_subghz_reset();
|
furi_hal_subghz_reset();
|
||||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
||||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
||||||
|
// TODO external device
|
||||||
furi_hal_gpio_init(
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||||
furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_write(&gpio_cc1101_g0, true);
|
||||||
furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, true);
|
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
@@ -105,44 +120,70 @@ void subghz_cli_command_rx_carrier(Cli* cli, FuriString* args, void* context) {
|
|||||||
furi_hal_subghz_sleep();
|
furi_hal_subghz_sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const SubGhzDevice* subghz_cli_command_get_device(uint32_t device_ind) {
|
||||||
|
const SubGhzDevice* device = NULL;
|
||||||
|
switch(device_ind) {
|
||||||
|
case 1:
|
||||||
|
subghz_cli_radio_device_power_on();
|
||||||
|
device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_EXT_NAME);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
device = subghz_devices_get_by_name(SUBGHZ_DEVICE_CC1101_INT_NAME);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
|
void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
uint32_t frequency = 433920000;
|
uint32_t frequency = 433920000;
|
||||||
uint32_t key = 0x0074BADE;
|
uint32_t key = 0x0074BADE;
|
||||||
uint32_t repeat = 10;
|
uint32_t repeat = 10;
|
||||||
uint32_t te = 403;
|
uint32_t te = 403;
|
||||||
|
uint32_t device_ind = 0; // 0 - CC1101_INT, 1 - CC1101_EXT
|
||||||
|
|
||||||
if(furi_string_size(args)) {
|
if(furi_string_size(args)) {
|
||||||
int ret =
|
int ret = sscanf(
|
||||||
sscanf(furi_string_get_cstr(args), "%lx %lu %lu %lu", &key, &frequency, &te, &repeat);
|
furi_string_get_cstr(args),
|
||||||
if(ret != 4) {
|
"%lx %lu %lu %lu %lu",
|
||||||
|
&key,
|
||||||
|
&frequency,
|
||||||
|
&te,
|
||||||
|
&repeat,
|
||||||
|
&device_ind);
|
||||||
|
if(ret != 5) {
|
||||||
printf(
|
printf(
|
||||||
"sscanf returned %d, key: %lx, frequency: %lu, te:%lu, repeat: %lu\r\n",
|
"sscanf returned %d, key: %lx, frequency: %lu, te: %lu, repeat: %lu, device: %lu\r\n ",
|
||||||
ret,
|
ret,
|
||||||
key,
|
key,
|
||||||
frequency,
|
frequency,
|
||||||
te,
|
te,
|
||||||
repeat);
|
repeat,
|
||||||
|
device_ind);
|
||||||
cli_print_usage(
|
cli_print_usage(
|
||||||
"subghz tx",
|
"subghz tx",
|
||||||
"<3 Byte Key: in hex> <Frequency: in Hz> <Te us> <Repeat count>",
|
"<3 Byte Key: in hex> <Frequency: in Hz> <Te us> <Repeat count> <Device: 0 - CC1101_INT, 1 - CC1101_EXT>",
|
||||||
furi_string_get_cstr(args));
|
furi_string_get_cstr(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
|
||||||
printf(
|
|
||||||
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
|
||||||
frequency);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
subghz_devices_init();
|
||||||
|
const SubGhzDevice* device = subghz_cli_command_get_device(device_ind);
|
||||||
|
if(!subghz_devices_is_frequency_valid(device, frequency)) {
|
||||||
|
printf(
|
||||||
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency);
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
return;
|
||||||
|
}
|
||||||
printf(
|
printf(
|
||||||
"Transmitting at %lu, key %lx, te %lu, repeat %lu. Press CTRL+C to stop\r\n",
|
"Transmitting at %lu, key %lx, te %lu, repeat %lu device %lu. Press CTRL+C to stop\r\n",
|
||||||
frequency,
|
frequency,
|
||||||
key,
|
key,
|
||||||
te,
|
te,
|
||||||
repeat);
|
repeat,
|
||||||
|
device_ind);
|
||||||
|
|
||||||
FuriString* flipper_format_string = furi_string_alloc_printf(
|
FuriString* flipper_format_string = furi_string_alloc_printf(
|
||||||
"Protocol: Princeton\n"
|
"Protocol: Princeton\n"
|
||||||
@@ -166,25 +207,30 @@ void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
|
|||||||
SubGhzTransmitter* transmitter = subghz_transmitter_alloc_init(environment, "Princeton");
|
SubGhzTransmitter* transmitter = subghz_transmitter_alloc_init(environment, "Princeton");
|
||||||
subghz_transmitter_deserialize(transmitter, flipper_format);
|
subghz_transmitter_deserialize(transmitter, flipper_format);
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
subghz_devices_begin(device);
|
||||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
subghz_devices_reset(device);
|
||||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
subghz_devices_load_preset(device, FuriHalSubGhzPresetOok650Async, NULL);
|
||||||
|
frequency = subghz_devices_set_frequency(device, frequency);
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
if(subghz_devices_start_async_tx(device, subghz_transmitter_yield, transmitter)) {
|
||||||
if(furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter)) {
|
while(!(subghz_devices_is_async_complete_tx(device) || cli_cmd_interrupt_received(cli))) {
|
||||||
while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
|
|
||||||
printf(".");
|
printf(".");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
furi_delay_ms(333);
|
furi_delay_ms(333);
|
||||||
}
|
}
|
||||||
furi_hal_subghz_stop_async_tx();
|
subghz_devices_stop_async_tx(device);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
printf("Transmission on this frequency is restricted in your region\r\n");
|
printf("Transmission on this frequency is restricted in your region\r\n");
|
||||||
|
// TODO region?
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_hal_subghz_sleep();
|
subghz_devices_sleep(device);
|
||||||
|
subghz_devices_end(device);
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
|
||||||
flipper_format_free(flipper_format);
|
flipper_format_free(flipper_format);
|
||||||
@@ -228,21 +274,29 @@ static void subghz_cli_command_rx_callback(
|
|||||||
void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
uint32_t frequency = 433920000;
|
uint32_t frequency = 433920000;
|
||||||
|
uint32_t device_ind = 0; // 0 - CC1101_INT, 1 - CC1101_EXT
|
||||||
|
|
||||||
if(furi_string_size(args)) {
|
if(furi_string_size(args)) {
|
||||||
int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
|
int ret = sscanf(furi_string_get_cstr(args), "%lu %lu", &frequency, &device_ind);
|
||||||
if(ret != 1) {
|
if(ret != 2) {
|
||||||
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
|
||||||
cli_print_usage("subghz rx", "<Frequency: in Hz>", furi_string_get_cstr(args));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
|
||||||
printf(
|
printf(
|
||||||
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
"sscanf returned %d, frequency: %lu device: %lu\r\n", ret, frequency, device_ind);
|
||||||
frequency);
|
cli_print_usage(
|
||||||
|
"subghz rx",
|
||||||
|
"<Frequency: in Hz> <Device: 0 - CC1101_INT, 1 - CC1101_EXT>",
|
||||||
|
furi_string_get_cstr(args));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
subghz_devices_init();
|
||||||
|
const SubGhzDevice* device = subghz_cli_command_get_device(device_ind);
|
||||||
|
if(!subghz_devices_is_frequency_valid(device, frequency)) {
|
||||||
|
printf(
|
||||||
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency);
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate context and buffers
|
// Allocate context and buffers
|
||||||
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
||||||
@@ -251,14 +305,14 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
|||||||
furi_check(instance->stream);
|
furi_check(instance->stream);
|
||||||
|
|
||||||
SubGhzEnvironment* environment = subghz_environment_alloc();
|
SubGhzEnvironment* environment = subghz_environment_alloc();
|
||||||
subghz_environment_load_keystore(environment, EXT_PATH("subghz/assets/keeloq_mfcodes"));
|
subghz_environment_load_keystore(environment, SUBGHZ_KEYSTORE_DIR_NAME);
|
||||||
subghz_environment_load_keystore(environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"));
|
subghz_environment_load_keystore(environment, SUBGHZ_KEYSTORE_DIR_USER_NAME);
|
||||||
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/came_atomo"));
|
environment, SUBGHZ_CAME_ATOMO_DIR_NAME);
|
||||||
subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/alutech_at_4n"));
|
environment, SUBGHZ_ALUTECH_AT_4N_DIR_NAME);
|
||||||
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/nice_flor_s"));
|
environment, SUBGHZ_NICE_FLOR_S_DIR_NAME);
|
||||||
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);
|
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);
|
||||||
|
|
||||||
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
||||||
@@ -266,18 +320,21 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
|||||||
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
||||||
|
|
||||||
// Configure radio
|
// Configure radio
|
||||||
furi_hal_subghz_reset();
|
subghz_devices_begin(device);
|
||||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
subghz_devices_reset(device);
|
||||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
subghz_devices_load_preset(device, FuriHalSubGhzPresetOok650Async, NULL);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
frequency = subghz_devices_set_frequency(device, frequency);
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
// Prepare and start RX
|
// Prepare and start RX
|
||||||
furi_hal_subghz_start_async_rx(subghz_cli_command_rx_capture_callback, instance);
|
subghz_devices_start_async_rx(device, subghz_cli_command_rx_capture_callback, instance);
|
||||||
|
|
||||||
// Wait for packets to arrive
|
// Wait for packets to arrive
|
||||||
printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
|
printf(
|
||||||
|
"Listening at frequency: %lu device: %lu. Press CTRL+C to stop\r\n",
|
||||||
|
frequency,
|
||||||
|
device_ind);
|
||||||
LevelDuration level_duration;
|
LevelDuration level_duration;
|
||||||
while(!cli_cmd_interrupt_received(cli)) {
|
while(!cli_cmd_interrupt_received(cli)) {
|
||||||
int ret = furi_stream_buffer_receive(
|
int ret = furi_stream_buffer_receive(
|
||||||
@@ -295,8 +352,11 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown radio
|
// Shutdown radio
|
||||||
furi_hal_subghz_stop_async_rx();
|
subghz_devices_stop_async_rx(device);
|
||||||
furi_hal_subghz_sleep();
|
subghz_devices_sleep(device);
|
||||||
|
subghz_devices_end(device);
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
|
|
||||||
@@ -338,7 +398,7 @@ void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
|
|||||||
furi_hal_subghz_reset();
|
furi_hal_subghz_reset();
|
||||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok270Async);
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok270Async);
|
||||||
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_enter();
|
furi_hal_power_suppress_charge_enter();
|
||||||
|
|
||||||
@@ -384,6 +444,7 @@ void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
|
|||||||
furi_stream_buffer_free(instance->stream);
|
furi_stream_buffer_free(instance->stream);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
||||||
UNUSED(context);
|
UNUSED(context);
|
||||||
FuriString* file_name = furi_string_alloc();
|
FuriString* file_name = furi_string_alloc();
|
||||||
@@ -435,25 +496,23 @@ void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
|||||||
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
||||||
|
|
||||||
SubGhzEnvironment* environment = subghz_environment_alloc();
|
SubGhzEnvironment* environment = subghz_environment_alloc();
|
||||||
if(subghz_environment_load_keystore(
|
if(subghz_environment_load_keystore(environment, SUBGHZ_KEYSTORE_DIR_NAME)) {
|
||||||
environment, EXT_PATH("subghz/assets/keeloq_mfcodes"))) {
|
|
||||||
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;32mOK\033[0m\r\n");
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;32mOK\033[0m\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;31mERROR\033[0m\r\n");
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;31mERROR\033[0m\r\n");
|
||||||
}
|
}
|
||||||
if(subghz_environment_load_keystore(
|
if(subghz_environment_load_keystore(environment, SUBGHZ_KEYSTORE_DIR_USER_NAME)) {
|
||||||
environment, EXT_PATH("subghz/assets/keeloq_mfcodes_user"))) {
|
|
||||||
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;32mOK\033[0m\r\n");
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;32mOK\033[0m\r\n");
|
||||||
} else {
|
} else {
|
||||||
printf(
|
printf(
|
||||||
"SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;31mERROR\033[0m\r\n");
|
"SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;31mERROR\033[0m\r\n");
|
||||||
}
|
}
|
||||||
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/came_atomo"));
|
environment, SUBGHZ_CAME_ATOMO_DIR_NAME);
|
||||||
subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
subghz_environment_set_alutech_at_4n_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/alutech_at_4n"));
|
environment, SUBGHZ_ALUTECH_AT_4N_DIR_NAME);
|
||||||
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
||||||
environment, EXT_PATH("subghz/assets/nice_flor_s"));
|
environment, SUBGHZ_NICE_FLOR_S_DIR_NAME);
|
||||||
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);
|
subghz_environment_set_protocol_registry(environment, (void*)&subghz_protocol_registry);
|
||||||
|
|
||||||
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
||||||
@@ -461,7 +520,8 @@ void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
|||||||
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
||||||
|
|
||||||
SubGhzFileEncoderWorker* file_worker_encoder = subghz_file_encoder_worker_alloc();
|
SubGhzFileEncoderWorker* file_worker_encoder = subghz_file_encoder_worker_alloc();
|
||||||
if(subghz_file_encoder_worker_start(file_worker_encoder, furi_string_get_cstr(file_name))) {
|
if(subghz_file_encoder_worker_start(
|
||||||
|
file_worker_encoder, furi_string_get_cstr(file_name), NULL)) {
|
||||||
//the worker needs a file in order to open and read part of the file
|
//the worker needs a file in order to open and read part of the file
|
||||||
furi_delay_ms(100);
|
furi_delay_ms(100);
|
||||||
}
|
}
|
||||||
@@ -503,10 +563,11 @@ static void subghz_cli_command_print_usage() {
|
|||||||
printf("subghz <cmd> <args>\r\n");
|
printf("subghz <cmd> <args>\r\n");
|
||||||
printf("Cmd list:\r\n");
|
printf("Cmd list:\r\n");
|
||||||
|
|
||||||
printf("\tchat <frequency:in Hz>\t - Chat with other Flippers\r\n");
|
|
||||||
printf(
|
printf(
|
||||||
"\ttx <3 byte Key: in hex> <frequency: in Hz> <te: us> <repeat: count>\t - Transmitting key\r\n");
|
"\tchat <frequency:in Hz> <device: 0 - CC1101_INT, 1 - CC1101_EXT>\t - Chat with other Flippers\r\n");
|
||||||
printf("\trx <frequency:in Hz>\t - Receive\r\n");
|
printf(
|
||||||
|
"\ttx <3 byte Key: in hex> <frequency: in Hz> <te: us> <repeat: count> <device: 0 - CC1101_INT, 1 - CC1101_EXT>\t - Transmitting key\r\n");
|
||||||
|
printf("\trx <frequency:in Hz> <device: 0 - CC1101_INT, 1 - CC1101_EXT>\t - Receive\r\n");
|
||||||
printf("\trx_raw <frequency:in Hz>\t - Receive RAW\r\n");
|
printf("\trx_raw <frequency:in Hz>\t - Receive RAW\r\n");
|
||||||
printf("\tdecode_raw <file_name: path_RAW_file>\t - Testing\r\n");
|
printf("\tdecode_raw <file_name: path_RAW_file>\t - Testing\r\n");
|
||||||
|
|
||||||
@@ -600,21 +661,31 @@ static void subghz_cli_command_encrypt_raw(Cli* cli, FuriString* args) {
|
|||||||
|
|
||||||
static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
||||||
uint32_t frequency = 433920000;
|
uint32_t frequency = 433920000;
|
||||||
|
uint32_t device_ind = 0; // 0 - CC1101_INT, 1 - CC1101_EXT
|
||||||
|
|
||||||
if(furi_string_size(args)) {
|
if(furi_string_size(args)) {
|
||||||
int ret = sscanf(furi_string_get_cstr(args), "%lu", &frequency);
|
int ret = sscanf(furi_string_get_cstr(args), "%lu %lu", &frequency, &device_ind);
|
||||||
if(ret != 1) {
|
if(ret != 2) {
|
||||||
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
printf("sscanf returned %d, Frequency: %lu\r\n", ret, frequency);
|
||||||
cli_print_usage("subghz chat", "<Frequency: in Hz>", furi_string_get_cstr(args));
|
printf("sscanf returned %d, Device: %lu\r\n", ret, device_ind);
|
||||||
return;
|
cli_print_usage(
|
||||||
}
|
"subghz chat",
|
||||||
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
"<Frequency: in Hz> <Device: 0 - CC1101_INT, 1 - CC1101_EXT>",
|
||||||
printf(
|
furi_string_get_cstr(args));
|
||||||
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
|
||||||
frequency);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
subghz_devices_init();
|
||||||
|
const SubGhzDevice* device = subghz_cli_command_get_device(device_ind);
|
||||||
|
if(!subghz_devices_is_frequency_valid(device, frequency)) {
|
||||||
|
printf(
|
||||||
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency);
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO
|
||||||
if(!furi_hal_subghz_is_tx_allowed(frequency)) {
|
if(!furi_hal_subghz_is_tx_allowed(frequency)) {
|
||||||
printf(
|
printf(
|
||||||
"In your settings, only reception on this frequency (%lu) is allowed,\r\n"
|
"In your settings, only reception on this frequency (%lu) is allowed,\r\n"
|
||||||
@@ -624,7 +695,8 @@ static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SubGhzChatWorker* subghz_chat = subghz_chat_worker_alloc(cli);
|
SubGhzChatWorker* subghz_chat = subghz_chat_worker_alloc(cli);
|
||||||
if(!subghz_chat_worker_start(subghz_chat, frequency)) {
|
|
||||||
|
if(!subghz_chat_worker_start(subghz_chat, device, frequency)) {
|
||||||
printf("Startup error SubGhzChatWorker\r\n");
|
printf("Startup error SubGhzChatWorker\r\n");
|
||||||
|
|
||||||
if(subghz_chat_worker_is_running(subghz_chat)) {
|
if(subghz_chat_worker_is_running(subghz_chat)) {
|
||||||
@@ -766,6 +838,10 @@ static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
|||||||
furi_string_free(name);
|
furi_string_free(name);
|
||||||
furi_string_free(output);
|
furi_string_free(output);
|
||||||
furi_string_free(sysmsg);
|
furi_string_free(sysmsg);
|
||||||
|
|
||||||
|
subghz_devices_deinit();
|
||||||
|
subghz_cli_radio_device_power_off();
|
||||||
|
|
||||||
furi_hal_power_suppress_charge_exit();
|
furi_hal_power_suppress_charge_exit();
|
||||||
furi_record_close(RECORD_NOTIFICATION);
|
furi_record_close(RECORD_NOTIFICATION);
|
||||||
|
|
||||||
@@ -779,14 +855,7 @@ static void subghz_cli_command_chat(Cli* cli, FuriString* args) {
|
|||||||
static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
|
static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
|
||||||
FuriString* cmd = furi_string_alloc();
|
FuriString* cmd = furi_string_alloc();
|
||||||
|
|
||||||
// Enable power for External CC1101 if it is connected
|
// TODO external
|
||||||
furi_hal_subghz_enable_ext_power();
|
|
||||||
// Auto switch to internal radio if external radio is not available
|
|
||||||
furi_delay_ms(15);
|
|
||||||
if(!furi_hal_subghz_check_radio()) {
|
|
||||||
furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
|
||||||
furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if(!args_read_string_and_trim(args, cmd)) {
|
if(!args_read_string_and_trim(args, cmd)) {
|
||||||
@@ -844,11 +913,6 @@ static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
|
|||||||
subghz_cli_command_print_usage();
|
subghz_cli_command_print_usage();
|
||||||
} while(false);
|
} while(false);
|
||||||
|
|
||||||
// Disable power for External CC1101 if it was enabled and module is connected
|
|
||||||
furi_hal_subghz_disable_ext_power();
|
|
||||||
// Reinit SPI handles for internal radio / nfc
|
|
||||||
furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
|
||||||
|
|
||||||
furi_string_free(cmd);
|
furi_string_free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!furi_hal_subghz_is_frequency_valid(temp_data32)) {
|
if(!subghz_txrx_radio_device_is_frequecy_valid(subghz->txrx, temp_data32)) {
|
||||||
FURI_LOG_E(TAG, "Frequency not supported");
|
FURI_LOG_E(TAG, "Frequency not supported");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,8 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
|||||||
if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) {
|
if(!strcmp(furi_string_get_cstr(temp_str), "RAW")) {
|
||||||
//if RAW
|
//if RAW
|
||||||
subghz->load_type_file = SubGhzLoadTypeFileRaw;
|
subghz->load_type_file = SubGhzLoadTypeFileRaw;
|
||||||
subghz_protocol_raw_gen_fff_data(fff_data, file_path);
|
subghz_protocol_raw_gen_fff_data(
|
||||||
|
fff_data, file_path, subghz_txrx_radio_device_get_name(subghz->txrx));
|
||||||
} else {
|
} else {
|
||||||
subghz->load_type_file = SubGhzLoadTypeFileKey;
|
subghz->load_type_file = SubGhzLoadTypeFileKey;
|
||||||
stream_copy_full(
|
stream_copy_full(
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ typedef struct {
|
|||||||
SubGhzViewReceiverBarShow bar_show;
|
SubGhzViewReceiverBarShow bar_show;
|
||||||
SubGhzViewReceiverMode mode;
|
SubGhzViewReceiverMode mode;
|
||||||
uint8_t u_rssi;
|
uint8_t u_rssi;
|
||||||
|
SubGhzRadioDeviceType device_type;
|
||||||
size_t scroll_counter;
|
size_t scroll_counter;
|
||||||
bool nodraw;
|
bool nodraw;
|
||||||
} SubGhzViewReceiverModel;
|
} SubGhzViewReceiverModel;
|
||||||
@@ -202,6 +203,17 @@ void subghz_view_receiver_add_data_progress(
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_view_receiver_set_radio_device_type(
|
||||||
|
SubGhzViewReceiver* subghz_receiver,
|
||||||
|
SubGhzRadioDeviceType device_type) {
|
||||||
|
furi_assert(subghz_receiver);
|
||||||
|
with_view_model(
|
||||||
|
subghz_receiver->view,
|
||||||
|
SubGhzViewReceiverModel * model,
|
||||||
|
{ model->device_type = device_type; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
static void subghz_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
|
static void subghz_view_receiver_draw_frame(Canvas* canvas, uint16_t idx, bool scrollbar) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
canvas_draw_box(canvas, 0, 0 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT);
|
canvas_draw_box(canvas, 0, 0 + idx * FRAME_HEIGHT, scrollbar ? 122 : 127, FRAME_HEIGHT);
|
||||||
@@ -289,12 +301,14 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
|
|||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|
||||||
if(model->history_item == 0) {
|
if(model->history_item == 0) {
|
||||||
|
// TODO
|
||||||
if(model->mode == SubGhzViewReceiverModeLive) {
|
if(model->mode == SubGhzViewReceiverModeLive) {
|
||||||
canvas_draw_icon(
|
canvas_draw_icon(
|
||||||
canvas,
|
canvas,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
furi_hal_subghz_get_radio_type() ? &I_Fishing_123x52 : &I_Scanning_123x52);
|
(model->device_type == SubGhzRadioDeviceTypeInternal) ? &I_Scanning_123x52 :
|
||||||
|
&I_Fishing_123x52);
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
canvas_draw_str(canvas, 63, 46, "Scanning...");
|
canvas_draw_str(canvas, 63, 46, "Scanning...");
|
||||||
//canvas_draw_line(canvas, 46, 51, 125, 51);
|
//canvas_draw_line(canvas, 46, 51, 125, 51);
|
||||||
@@ -304,7 +318,8 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) {
|
|||||||
canvas,
|
canvas,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
furi_hal_subghz_get_radio_type() ? &I_Fishing_123x52 : &I_Scanning_123x52);
|
(model->device_type == SubGhzRadioDeviceTypeInternal) ? &I_Scanning_123x52 :
|
||||||
|
&I_Fishing_123x52);
|
||||||
canvas_set_font(canvas, FontPrimary);
|
canvas_set_font(canvas, FontPrimary);
|
||||||
canvas_draw_str(canvas, 63, 46, "Decoding...");
|
canvas_draw_str(canvas, 63, 46, "Decoding...");
|
||||||
canvas_set_font(canvas, FontSecondary);
|
canvas_set_font(canvas, FontSecondary);
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ void subghz_view_receiver_add_data_statusbar(
|
|||||||
const char* preset_str,
|
const char* preset_str,
|
||||||
const char* history_stat_str);
|
const char* history_stat_str);
|
||||||
|
|
||||||
|
void subghz_view_receiver_set_radio_device_type(
|
||||||
|
SubGhzViewReceiver* subghz_receiver,
|
||||||
|
SubGhzRadioDeviceType device_type);
|
||||||
|
|
||||||
void subghz_view_receiver_add_data_progress(
|
void subghz_view_receiver_add_data_progress(
|
||||||
SubGhzViewReceiver* subghz_receiver,
|
SubGhzViewReceiver* subghz_receiver,
|
||||||
const char* progress_str);
|
const char* progress_str);
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <assets_icons.h>
|
#include <assets_icons.h>
|
||||||
#include <float_tools.h>
|
#include <float_tools.h>
|
||||||
|
|
||||||
|
// TODO remove furi_hal_subghz
|
||||||
|
|
||||||
#define TAG "frequency_analyzer"
|
#define TAG "frequency_analyzer"
|
||||||
|
|
||||||
#define RSSI_MIN -97
|
#define RSSI_MIN -97
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ typedef struct {
|
|||||||
bool raw_send_only;
|
bool raw_send_only;
|
||||||
float raw_threshold_rssi;
|
float raw_threshold_rssi;
|
||||||
bool not_showing_samples;
|
bool not_showing_samples;
|
||||||
|
SubGhzRadioDeviceType device_type;
|
||||||
} SubGhzReadRAWModel;
|
} SubGhzReadRAWModel;
|
||||||
|
|
||||||
void subghz_read_raw_set_callback(
|
void subghz_read_raw_set_callback(
|
||||||
@@ -58,6 +59,14 @@ void subghz_read_raw_add_data_statusbar(
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_read_raw_set_radio_device_type(
|
||||||
|
SubGhzReadRAW* instance,
|
||||||
|
SubGhzRadioDeviceType device_type) {
|
||||||
|
furi_assert(instance);
|
||||||
|
with_view_model(
|
||||||
|
instance->view, SubGhzReadRAWModel * model, { model->device_type = device_type; }, true);
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi, bool trace) {
|
void subghz_read_raw_add_data_rssi(SubGhzReadRAW* instance, float rssi, bool trace) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
uint8_t u_rssi = 0;
|
uint8_t u_rssi = 0;
|
||||||
@@ -288,9 +297,15 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
|
|||||||
canvas_draw_str(canvas, 35, 7, furi_string_get_cstr(model->preset_str));
|
canvas_draw_str(canvas, 35, 7, furi_string_get_cstr(model->preset_str));
|
||||||
|
|
||||||
if(model->not_showing_samples) {
|
if(model->not_showing_samples) {
|
||||||
canvas_draw_str(canvas, 77, 7, furi_hal_subghz_get_radio_type() ? "R: Ext" : "R: Int");
|
// TODO
|
||||||
|
canvas_draw_str(
|
||||||
|
canvas,
|
||||||
|
77,
|
||||||
|
7,
|
||||||
|
(model->device_type == SubGhzRadioDeviceTypeInternal) ? "R: Int" : "R: Ext");
|
||||||
} else {
|
} else {
|
||||||
canvas_draw_str(canvas, 70, 7, furi_hal_subghz_get_radio_type() ? "E" : "I");
|
canvas_draw_str(
|
||||||
|
canvas, 70, 7, (model->device_type == SubGhzRadioDeviceTypeInternal) ? "I" : "E");
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
#include "../helpers/subghz_types.h"
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
|
|
||||||
#define SUBGHZ_RAW_THRESHOLD_MIN -90.0f
|
#define SUBGHZ_RAW_THRESHOLD_MIN -90.0f
|
||||||
@@ -36,6 +37,10 @@ void subghz_read_raw_add_data_statusbar(
|
|||||||
const char* frequency_str,
|
const char* frequency_str,
|
||||||
const char* preset_str);
|
const char* preset_str);
|
||||||
|
|
||||||
|
void subghz_read_raw_set_radio_device_type(
|
||||||
|
SubGhzReadRAW* instance,
|
||||||
|
SubGhzRadioDeviceType device_type);
|
||||||
|
|
||||||
void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample);
|
void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample);
|
||||||
|
|
||||||
void subghz_read_raw_stop_send(SubGhzReadRAW* instance);
|
void subghz_read_raw_stop_send(SubGhzReadRAW* instance);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ typedef struct {
|
|||||||
FuriString* preset_str;
|
FuriString* preset_str;
|
||||||
FuriString* key_str;
|
FuriString* key_str;
|
||||||
bool show_button;
|
bool show_button;
|
||||||
|
SubGhzRadioDeviceType device_type;
|
||||||
FuriString* temp_button_id;
|
FuriString* temp_button_id;
|
||||||
bool draw_temp_button;
|
bool draw_temp_button;
|
||||||
} SubGhzViewTransmitterModel;
|
} SubGhzViewTransmitterModel;
|
||||||
@@ -50,6 +51,17 @@ void subghz_view_transmitter_add_data_to_show(
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_view_transmitter_set_radio_device_type(
|
||||||
|
SubGhzViewTransmitter* subghz_transmitter,
|
||||||
|
SubGhzRadioDeviceType device_type) {
|
||||||
|
furi_assert(subghz_transmitter);
|
||||||
|
with_view_model(
|
||||||
|
subghz_transmitter->view,
|
||||||
|
SubGhzViewTransmitterModel * model,
|
||||||
|
{ model->device_type = device_type; },
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) {
|
static void subghz_view_transmitter_button_right(Canvas* canvas, const char* str) {
|
||||||
const uint8_t button_height = 12;
|
const uint8_t button_height = 12;
|
||||||
const uint8_t vertical_offset = 3;
|
const uint8_t vertical_offset = 3;
|
||||||
@@ -100,7 +112,12 @@ void subghz_view_transmitter_draw(Canvas* canvas, SubGhzViewTransmitterModel* mo
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(model->show_button) {
|
if(model->show_button) {
|
||||||
canvas_draw_str(canvas, 58, 62, furi_hal_subghz_get_radio_type() ? "R: Ext" : "R: Int");
|
// TODO
|
||||||
|
canvas_draw_str(
|
||||||
|
canvas,
|
||||||
|
58,
|
||||||
|
62,
|
||||||
|
(model->device_type == SubGhzRadioDeviceTypeInternal) ? "R: Int" : "R: Ext");
|
||||||
subghz_view_transmitter_button_right(canvas, "Send");
|
subghz_view_transmitter_button_right(canvas, "Send");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
|
#include "../helpers/subghz_types.h"
|
||||||
#include "../helpers/subghz_custom_event.h"
|
#include "../helpers/subghz_custom_event.h"
|
||||||
|
|
||||||
typedef struct SubGhzViewTransmitter SubGhzViewTransmitter;
|
typedef struct SubGhzViewTransmitter SubGhzViewTransmitter;
|
||||||
@@ -12,6 +13,10 @@ void subghz_view_transmitter_set_callback(
|
|||||||
SubGhzViewTransmitterCallback callback,
|
SubGhzViewTransmitterCallback callback,
|
||||||
void* context);
|
void* context);
|
||||||
|
|
||||||
|
void subghz_view_transmitter_set_radio_device_type(
|
||||||
|
SubGhzViewTransmitter* subghz_transmitter,
|
||||||
|
SubGhzRadioDeviceType device_type);
|
||||||
|
|
||||||
SubGhzViewTransmitter* subghz_view_transmitter_alloc();
|
SubGhzViewTransmitter* subghz_view_transmitter_alloc();
|
||||||
|
|
||||||
void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter);
|
void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
entry,status,name,type,params
|
entry,status,name,type,params
|
||||||
Version,+,30.1,,
|
Version,+,32.0,,
|
||||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||||
Header,+,applications/services/cli/cli.h,,
|
Header,+,applications/services/cli/cli.h,,
|
||||||
Header,+,applications/services/cli/cli_vcp.h,,
|
Header,+,applications/services/cli/cli_vcp.h,,
|
||||||
@@ -56,7 +56,6 @@ Header,+,firmware/targets/f7/furi_hal/furi_hal_rfid.h,,
|
|||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_config.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_config.h,,
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_types.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_spi_types.h,,
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_subghz.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_subghz.h,,
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_subghz_configs.h,,
|
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_target_hw.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_target_hw.h,,
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_uart.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_uart.h,,
|
||||||
Header,+,firmware/targets/f7/furi_hal/furi_hal_usb_cdc.h,,
|
Header,+,firmware/targets/f7/furi_hal/furi_hal_usb_cdc.h,,
|
||||||
@@ -316,6 +315,7 @@ Function,-,LL_mDelay,void,uint32_t
|
|||||||
Function,-,SystemCoreClockUpdate,void,
|
Function,-,SystemCoreClockUpdate,void,
|
||||||
Function,-,SystemInit,void,
|
Function,-,SystemInit,void,
|
||||||
Function,-,_Exit,void,int
|
Function,-,_Exit,void,int
|
||||||
|
Function,+,__aeabi_uldivmod,void*,"uint64_t, uint64_t"
|
||||||
Function,-,__assert,void,"const char*, int, const char*"
|
Function,-,__assert,void,"const char*, int, const char*"
|
||||||
Function,+,__assert_func,void,"const char*, int, const char*, const char*"
|
Function,+,__assert_func,void,"const char*, int, const char*, const char*"
|
||||||
Function,+,__clear_cache,void,"void*, void*"
|
Function,+,__clear_cache,void,"void*, void*"
|
||||||
@@ -668,26 +668,6 @@ Function,+,canvas_width,uint8_t,const Canvas*
|
|||||||
Function,-,cbrt,double,double
|
Function,-,cbrt,double,double
|
||||||
Function,-,cbrtf,float,float
|
Function,-,cbrtf,float,float
|
||||||
Function,-,cbrtl,long double,long double
|
Function,-,cbrtl,long double,long double
|
||||||
Function,+,cc1101_calibrate,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_flush_rx,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_flush_tx,void,FuriHalSpiBusHandle*
|
|
||||||
Function,-,cc1101_get_partnumber,uint8_t,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_get_rssi,uint8_t,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_get_status,CC1101Status,FuriHalSpiBusHandle*
|
|
||||||
Function,-,cc1101_get_version,uint8_t,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_read_fifo,uint8_t,"FuriHalSpiBusHandle*, uint8_t*, uint8_t*"
|
|
||||||
Function,+,cc1101_read_reg,CC1101Status,"FuriHalSpiBusHandle*, uint8_t, uint8_t*"
|
|
||||||
Function,+,cc1101_reset,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_set_frequency,uint32_t,"FuriHalSpiBusHandle*, uint32_t"
|
|
||||||
Function,-,cc1101_set_intermediate_frequency,uint32_t,"FuriHalSpiBusHandle*, uint32_t"
|
|
||||||
Function,+,cc1101_set_pa_table,void,"FuriHalSpiBusHandle*, const uint8_t[8]"
|
|
||||||
Function,+,cc1101_shutdown,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_strobe,CC1101Status,"FuriHalSpiBusHandle*, uint8_t"
|
|
||||||
Function,+,cc1101_switch_to_idle,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_switch_to_rx,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_switch_to_tx,void,FuriHalSpiBusHandle*
|
|
||||||
Function,+,cc1101_write_fifo,uint8_t,"FuriHalSpiBusHandle*, const uint8_t*, uint8_t"
|
|
||||||
Function,+,cc1101_write_reg,CC1101Status,"FuriHalSpiBusHandle*, uint8_t, uint8_t"
|
|
||||||
Function,-,ceil,double,double
|
Function,-,ceil,double,double
|
||||||
Function,-,ceilf,float,float
|
Function,-,ceilf,float,float
|
||||||
Function,-,ceill,long double,long double
|
Function,-,ceill,long double,long double
|
||||||
@@ -1394,21 +1374,15 @@ Function,-,furi_hal_spi_config_init,void,
|
|||||||
Function,-,furi_hal_spi_config_init_early,void,
|
Function,-,furi_hal_spi_config_init_early,void,
|
||||||
Function,-,furi_hal_spi_dma_init,void,
|
Function,-,furi_hal_spi_dma_init,void,
|
||||||
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
|
Function,+,furi_hal_spi_release,void,FuriHalSpiBusHandle*
|
||||||
Function,+,furi_hal_subghz_check_radio,_Bool,
|
|
||||||
Function,+,furi_hal_subghz_disable_ext_power,void,
|
|
||||||
Function,-,furi_hal_subghz_dump_state,void,
|
Function,-,furi_hal_subghz_dump_state,void,
|
||||||
Function,+,furi_hal_subghz_enable_ext_power,_Bool,
|
|
||||||
Function,+,furi_hal_subghz_flush_rx,void,
|
Function,+,furi_hal_subghz_flush_rx,void,
|
||||||
Function,+,furi_hal_subghz_flush_tx,void,
|
Function,+,furi_hal_subghz_flush_tx,void,
|
||||||
Function,+,furi_hal_subghz_get_external_power_disable,_Bool,
|
Function,+,furi_hal_subghz_get_data_gpio,const GpioPin*,
|
||||||
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
||||||
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
|
||||||
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
||||||
Function,+,furi_hal_subghz_get_rssi,float,
|
Function,+,furi_hal_subghz_get_rssi,float,
|
||||||
Function,+,furi_hal_subghz_idle,void,
|
Function,+,furi_hal_subghz_idle,void,
|
||||||
Function,-,furi_hal_subghz_init,void,
|
Function,-,furi_hal_subghz_init,void,
|
||||||
Function,-,furi_hal_subghz_init_check,_Bool,
|
|
||||||
Function,+,furi_hal_subghz_init_radio_type,_Bool,SubGhzRadioType
|
|
||||||
Function,+,furi_hal_subghz_is_async_tx_complete,_Bool,
|
Function,+,furi_hal_subghz_is_async_tx_complete,_Bool,
|
||||||
Function,+,furi_hal_subghz_is_frequency_valid,_Bool,uint32_t
|
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_rx_data_crc_valid,_Bool,
|
||||||
@@ -1421,9 +1395,7 @@ Function,+,furi_hal_subghz_read_packet,void,"uint8_t*, uint8_t*"
|
|||||||
Function,+,furi_hal_subghz_reset,void,
|
Function,+,furi_hal_subghz_reset,void,
|
||||||
Function,+,furi_hal_subghz_rx,void,
|
Function,+,furi_hal_subghz_rx,void,
|
||||||
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
||||||
Function,+,furi_hal_subghz_select_radio_type,void,SubGhzRadioType
|
|
||||||
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
||||||
Function,+,furi_hal_subghz_set_external_power_disable,void,_Bool
|
|
||||||
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||||
@@ -2706,6 +2678,36 @@ Function,+,subghz_block_generic_deserialize,SubGhzProtocolStatus,"SubGhzBlockGen
|
|||||||
Function,+,subghz_block_generic_deserialize_check_count_bit,SubGhzProtocolStatus,"SubGhzBlockGeneric*, FlipperFormat*, uint16_t"
|
Function,+,subghz_block_generic_deserialize_check_count_bit,SubGhzProtocolStatus,"SubGhzBlockGeneric*, FlipperFormat*, uint16_t"
|
||||||
Function,+,subghz_block_generic_get_preset_name,void,"const char*, FuriString*"
|
Function,+,subghz_block_generic_get_preset_name,void,"const char*, FuriString*"
|
||||||
Function,+,subghz_block_generic_serialize,SubGhzProtocolStatus,"SubGhzBlockGeneric*, FlipperFormat*, SubGhzRadioPreset*"
|
Function,+,subghz_block_generic_serialize,SubGhzProtocolStatus,"SubGhzBlockGeneric*, FlipperFormat*, SubGhzRadioPreset*"
|
||||||
|
Function,+,subghz_devices_begin,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_deinit,void,
|
||||||
|
Function,+,subghz_devices_end,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_flush_rx,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_flush_tx,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_get_by_name,const SubGhzDevice*,const char*
|
||||||
|
Function,+,subghz_devices_get_data_gpio,const GpioPin*,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_get_lqi,uint8_t,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_get_name,const char*,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_get_rssi,float,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_idle,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_init,void,
|
||||||
|
Function,+,subghz_devices_is_async_complete_tx,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_is_connect,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_is_frequency_valid,_Bool,"const SubGhzDevice*, uint32_t"
|
||||||
|
Function,+,subghz_devices_is_rx_data_crc_valid,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_load_preset,void,"const SubGhzDevice*, FuriHalSubGhzPreset, uint8_t*"
|
||||||
|
Function,+,subghz_devices_read_packet,void,"const SubGhzDevice*, uint8_t*, uint8_t*"
|
||||||
|
Function,+,subghz_devices_reset,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_rx_pipe_not_empty,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_set_async_mirror_pin,void,"const SubGhzDevice*, const GpioPin*"
|
||||||
|
Function,+,subghz_devices_set_frequency,uint32_t,"const SubGhzDevice*, uint32_t"
|
||||||
|
Function,+,subghz_devices_set_rx,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_set_tx,_Bool,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_sleep,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_start_async_rx,void,"const SubGhzDevice*, void*, void*"
|
||||||
|
Function,+,subghz_devices_start_async_tx,_Bool,"const SubGhzDevice*, void*, void*"
|
||||||
|
Function,+,subghz_devices_stop_async_rx,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_stop_async_tx,void,const SubGhzDevice*
|
||||||
|
Function,+,subghz_devices_write_packet,void,"const SubGhzDevice*, const uint8_t*, uint8_t"
|
||||||
Function,+,subghz_environment_alloc,SubGhzEnvironment*,
|
Function,+,subghz_environment_alloc,SubGhzEnvironment*,
|
||||||
Function,+,subghz_environment_free,void,SubGhzEnvironment*
|
Function,+,subghz_environment_free,void,SubGhzEnvironment*
|
||||||
Function,+,subghz_environment_get_alutech_at_4n_rainbow_table_file_name,const char*,SubGhzEnvironment*
|
Function,+,subghz_environment_get_alutech_at_4n_rainbow_table_file_name,const char*,SubGhzEnvironment*
|
||||||
@@ -2766,7 +2768,7 @@ Function,+,subghz_protocol_encoder_raw_free,void,void*
|
|||||||
Function,+,subghz_protocol_encoder_raw_stop,void,void*
|
Function,+,subghz_protocol_encoder_raw_stop,void,void*
|
||||||
Function,+,subghz_protocol_encoder_raw_yield,LevelDuration,void*
|
Function,+,subghz_protocol_encoder_raw_yield,LevelDuration,void*
|
||||||
Function,+,subghz_protocol_raw_file_encoder_worker_set_callback_end,void,"SubGhzProtocolEncoderRAW*, SubGhzProtocolEncoderRAWCallbackEnd, void*"
|
Function,+,subghz_protocol_raw_file_encoder_worker_set_callback_end,void,"SubGhzProtocolEncoderRAW*, SubGhzProtocolEncoderRAWCallbackEnd, void*"
|
||||||
Function,+,subghz_protocol_raw_gen_fff_data,void,"FlipperFormat*, const char*"
|
Function,+,subghz_protocol_raw_gen_fff_data,void,"FlipperFormat*, const char*, const char*"
|
||||||
Function,+,subghz_protocol_raw_get_sample_write,size_t,SubGhzProtocolDecoderRAW*
|
Function,+,subghz_protocol_raw_get_sample_write,size_t,SubGhzProtocolDecoderRAW*
|
||||||
Function,+,subghz_protocol_raw_save_to_file_init,_Bool,"SubGhzProtocolDecoderRAW*, const char*, SubGhzRadioPreset*"
|
Function,+,subghz_protocol_raw_save_to_file_init,_Bool,"SubGhzProtocolDecoderRAW*, const char*, SubGhzRadioPreset*"
|
||||||
Function,+,subghz_protocol_raw_save_to_file_pause,void,"SubGhzProtocolDecoderRAW*, _Bool"
|
Function,+,subghz_protocol_raw_save_to_file_pause,void,"SubGhzProtocolDecoderRAW*, _Bool"
|
||||||
@@ -2811,7 +2813,7 @@ Function,+,subghz_tx_rx_worker_free,void,SubGhzTxRxWorker*
|
|||||||
Function,+,subghz_tx_rx_worker_is_running,_Bool,SubGhzTxRxWorker*
|
Function,+,subghz_tx_rx_worker_is_running,_Bool,SubGhzTxRxWorker*
|
||||||
Function,+,subghz_tx_rx_worker_read,size_t,"SubGhzTxRxWorker*, uint8_t*, size_t"
|
Function,+,subghz_tx_rx_worker_read,size_t,"SubGhzTxRxWorker*, uint8_t*, size_t"
|
||||||
Function,+,subghz_tx_rx_worker_set_callback_have_read,void,"SubGhzTxRxWorker*, SubGhzTxRxWorkerCallbackHaveRead, void*"
|
Function,+,subghz_tx_rx_worker_set_callback_have_read,void,"SubGhzTxRxWorker*, SubGhzTxRxWorkerCallbackHaveRead, void*"
|
||||||
Function,+,subghz_tx_rx_worker_start,_Bool,"SubGhzTxRxWorker*, uint32_t"
|
Function,+,subghz_tx_rx_worker_start,_Bool,"SubGhzTxRxWorker*, const SubGhzDevice*, uint32_t"
|
||||||
Function,+,subghz_tx_rx_worker_stop,void,SubGhzTxRxWorker*
|
Function,+,subghz_tx_rx_worker_stop,void,SubGhzTxRxWorker*
|
||||||
Function,+,subghz_tx_rx_worker_write,_Bool,"SubGhzTxRxWorker*, uint8_t*, size_t"
|
Function,+,subghz_tx_rx_worker_write,_Bool,"SubGhzTxRxWorker*, uint8_t*, size_t"
|
||||||
Function,+,subghz_worker_alloc,SubGhzWorker*,
|
Function,+,subghz_worker_alloc,SubGhzWorker*,
|
||||||
@@ -3165,15 +3167,12 @@ Variable,+,furi_hal_spi_bus_handle_nfc,FuriHalSpiBusHandle,
|
|||||||
Variable,+,furi_hal_spi_bus_handle_sd_fast,FuriHalSpiBusHandle,
|
Variable,+,furi_hal_spi_bus_handle_sd_fast,FuriHalSpiBusHandle,
|
||||||
Variable,+,furi_hal_spi_bus_handle_sd_slow,FuriHalSpiBusHandle,
|
Variable,+,furi_hal_spi_bus_handle_sd_slow,FuriHalSpiBusHandle,
|
||||||
Variable,+,furi_hal_spi_bus_handle_subghz,FuriHalSpiBusHandle,
|
Variable,+,furi_hal_spi_bus_handle_subghz,FuriHalSpiBusHandle,
|
||||||
Variable,+,furi_hal_spi_bus_handle_subghz_ext,FuriHalSpiBusHandle,
|
|
||||||
Variable,+,furi_hal_spi_bus_handle_subghz_int,FuriHalSpiBusHandle,
|
|
||||||
Variable,+,furi_hal_spi_bus_r,FuriHalSpiBus,
|
Variable,+,furi_hal_spi_bus_r,FuriHalSpiBus,
|
||||||
Variable,+,furi_hal_spi_preset_1edge_low_16m,const LL_SPI_InitTypeDef,
|
Variable,+,furi_hal_spi_preset_1edge_low_16m,const LL_SPI_InitTypeDef,
|
||||||
Variable,+,furi_hal_spi_preset_1edge_low_2m,const LL_SPI_InitTypeDef,
|
Variable,+,furi_hal_spi_preset_1edge_low_2m,const LL_SPI_InitTypeDef,
|
||||||
Variable,+,furi_hal_spi_preset_1edge_low_4m,const LL_SPI_InitTypeDef,
|
Variable,+,furi_hal_spi_preset_1edge_low_4m,const LL_SPI_InitTypeDef,
|
||||||
Variable,+,furi_hal_spi_preset_1edge_low_8m,const LL_SPI_InitTypeDef,
|
Variable,+,furi_hal_spi_preset_1edge_low_8m,const LL_SPI_InitTypeDef,
|
||||||
Variable,+,furi_hal_spi_preset_2edge_low_8m,const LL_SPI_InitTypeDef,
|
Variable,+,furi_hal_spi_preset_2edge_low_8m,const LL_SPI_InitTypeDef,
|
||||||
Variable,+,furi_hal_subghz,volatile FuriHalSubGhz,
|
|
||||||
Variable,+,gpio_button_back,const GpioPin,
|
Variable,+,gpio_button_back,const GpioPin,
|
||||||
Variable,+,gpio_button_down,const GpioPin,
|
Variable,+,gpio_button_down,const GpioPin,
|
||||||
Variable,+,gpio_button_left,const GpioPin,
|
Variable,+,gpio_button_left,const GpioPin,
|
||||||
@@ -3181,7 +3180,6 @@ Variable,+,gpio_button_ok,const GpioPin,
|
|||||||
Variable,+,gpio_button_right,const GpioPin,
|
Variable,+,gpio_button_right,const GpioPin,
|
||||||
Variable,+,gpio_button_up,const GpioPin,
|
Variable,+,gpio_button_up,const GpioPin,
|
||||||
Variable,+,gpio_cc1101_g0,const GpioPin,
|
Variable,+,gpio_cc1101_g0,const GpioPin,
|
||||||
Variable,+,gpio_cc1101_g0_ext,const GpioPin,
|
|
||||||
Variable,+,gpio_display_cs,const GpioPin,
|
Variable,+,gpio_display_cs,const GpioPin,
|
||||||
Variable,+,gpio_display_di,const GpioPin,
|
Variable,+,gpio_display_di,const GpioPin,
|
||||||
Variable,+,gpio_display_rst_n,const GpioPin,
|
Variable,+,gpio_display_rst_n,const GpioPin,
|
||||||
@@ -3214,13 +3212,9 @@ Variable,+,gpio_spi_d_miso,const GpioPin,
|
|||||||
Variable,+,gpio_spi_d_mosi,const GpioPin,
|
Variable,+,gpio_spi_d_mosi,const GpioPin,
|
||||||
Variable,+,gpio_spi_d_sck,const GpioPin,
|
Variable,+,gpio_spi_d_sck,const GpioPin,
|
||||||
Variable,+,gpio_spi_r_miso,const GpioPin,
|
Variable,+,gpio_spi_r_miso,const GpioPin,
|
||||||
Variable,+,gpio_spi_r_miso_ext,const GpioPin,
|
|
||||||
Variable,+,gpio_spi_r_mosi,const GpioPin,
|
Variable,+,gpio_spi_r_mosi,const GpioPin,
|
||||||
Variable,+,gpio_spi_r_mosi_ext,const GpioPin,
|
|
||||||
Variable,+,gpio_spi_r_sck,const GpioPin,
|
Variable,+,gpio_spi_r_sck,const GpioPin,
|
||||||
Variable,+,gpio_spi_r_sck_ext,const GpioPin,
|
|
||||||
Variable,+,gpio_subghz_cs,const GpioPin,
|
Variable,+,gpio_subghz_cs,const GpioPin,
|
||||||
Variable,+,gpio_subghz_cs_ext,const GpioPin,
|
|
||||||
Variable,+,gpio_swclk,const GpioPin,
|
Variable,+,gpio_swclk,const GpioPin,
|
||||||
Variable,+,gpio_swdio,const GpioPin,
|
Variable,+,gpio_swdio,const GpioPin,
|
||||||
Variable,+,gpio_usart_rx,const GpioPin,
|
Variable,+,gpio_usart_rx,const GpioPin,
|
||||||
|
|||||||
|
@@ -14,11 +14,9 @@ const GpioPin gpio_vibro = {.port = VIBRO_GPIO_Port, .pin = VIBRO_Pin};
|
|||||||
const GpioPin gpio_ibutton = {.port = iBTN_GPIO_Port, .pin = iBTN_Pin};
|
const GpioPin gpio_ibutton = {.port = iBTN_GPIO_Port, .pin = iBTN_Pin};
|
||||||
|
|
||||||
const GpioPin gpio_cc1101_g0 = {.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin};
|
const GpioPin gpio_cc1101_g0 = {.port = CC1101_G0_GPIO_Port, .pin = CC1101_G0_Pin};
|
||||||
const GpioPin gpio_cc1101_g0_ext = {.port = GPIOB, .pin = LL_GPIO_PIN_2};
|
|
||||||
const GpioPin gpio_rf_sw_0 = {.port = RF_SW_0_GPIO_Port, .pin = RF_SW_0_Pin};
|
const GpioPin gpio_rf_sw_0 = {.port = RF_SW_0_GPIO_Port, .pin = RF_SW_0_Pin};
|
||||||
|
|
||||||
const GpioPin gpio_subghz_cs = {.port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin};
|
const GpioPin gpio_subghz_cs = {.port = CC1101_CS_GPIO_Port, .pin = CC1101_CS_Pin};
|
||||||
const GpioPin gpio_subghz_cs_ext = {.port = GPIOA, .pin = LL_GPIO_PIN_4};
|
|
||||||
const GpioPin gpio_display_cs = {.port = DISPLAY_CS_GPIO_Port, .pin = DISPLAY_CS_Pin};
|
const GpioPin gpio_display_cs = {.port = DISPLAY_CS_GPIO_Port, .pin = DISPLAY_CS_Pin};
|
||||||
const GpioPin gpio_display_rst_n = {.port = DISPLAY_RST_GPIO_Port, .pin = DISPLAY_RST_Pin};
|
const GpioPin gpio_display_rst_n = {.port = DISPLAY_RST_GPIO_Port, .pin = DISPLAY_RST_Pin};
|
||||||
const GpioPin gpio_display_di = {.port = DISPLAY_DI_GPIO_Port, .pin = DISPLAY_DI_Pin};
|
const GpioPin gpio_display_di = {.port = DISPLAY_DI_GPIO_Port, .pin = DISPLAY_DI_Pin};
|
||||||
@@ -39,9 +37,6 @@ const GpioPin gpio_spi_d_sck = {.port = SPI_D_SCK_GPIO_Port, .pin = SPI_D_SCK_Pi
|
|||||||
const GpioPin gpio_spi_r_miso = {.port = SPI_R_MISO_GPIO_Port, .pin = SPI_R_MISO_Pin};
|
const GpioPin gpio_spi_r_miso = {.port = SPI_R_MISO_GPIO_Port, .pin = SPI_R_MISO_Pin};
|
||||||
const GpioPin gpio_spi_r_mosi = {.port = SPI_R_MOSI_GPIO_Port, .pin = SPI_R_MOSI_Pin};
|
const GpioPin gpio_spi_r_mosi = {.port = SPI_R_MOSI_GPIO_Port, .pin = SPI_R_MOSI_Pin};
|
||||||
const GpioPin gpio_spi_r_sck = {.port = SPI_R_SCK_GPIO_Port, .pin = SPI_R_SCK_Pin};
|
const GpioPin gpio_spi_r_sck = {.port = SPI_R_SCK_GPIO_Port, .pin = SPI_R_SCK_Pin};
|
||||||
const GpioPin gpio_spi_r_miso_ext = {.port = GPIOA, .pin = LL_GPIO_PIN_6};
|
|
||||||
const GpioPin gpio_spi_r_mosi_ext = {.port = GPIOA, .pin = LL_GPIO_PIN_7};
|
|
||||||
const GpioPin gpio_spi_r_sck_ext = {.port = GPIOB, .pin = LL_GPIO_PIN_3};
|
|
||||||
|
|
||||||
const GpioPin gpio_ext_pc0 = {.port = GPIOC, .pin = LL_GPIO_PIN_0};
|
const GpioPin gpio_ext_pc0 = {.port = GPIOC, .pin = LL_GPIO_PIN_0};
|
||||||
const GpioPin gpio_ext_pc1 = {.port = GPIOC, .pin = LL_GPIO_PIN_1};
|
const GpioPin gpio_ext_pc1 = {.port = GPIOC, .pin = LL_GPIO_PIN_1};
|
||||||
|
|||||||
@@ -57,11 +57,9 @@ extern const GpioPin gpio_vibro;
|
|||||||
extern const GpioPin gpio_ibutton;
|
extern const GpioPin gpio_ibutton;
|
||||||
|
|
||||||
extern const GpioPin gpio_cc1101_g0;
|
extern const GpioPin gpio_cc1101_g0;
|
||||||
extern const GpioPin gpio_cc1101_g0_ext;
|
|
||||||
extern const GpioPin gpio_rf_sw_0;
|
extern const GpioPin gpio_rf_sw_0;
|
||||||
|
|
||||||
extern const GpioPin gpio_subghz_cs;
|
extern const GpioPin gpio_subghz_cs;
|
||||||
extern const GpioPin gpio_subghz_cs_ext;
|
|
||||||
extern const GpioPin gpio_display_cs;
|
extern const GpioPin gpio_display_cs;
|
||||||
extern const GpioPin gpio_display_rst_n;
|
extern const GpioPin gpio_display_rst_n;
|
||||||
extern const GpioPin gpio_display_di;
|
extern const GpioPin gpio_display_di;
|
||||||
@@ -82,9 +80,6 @@ extern const GpioPin gpio_spi_d_sck;
|
|||||||
extern const GpioPin gpio_spi_r_miso;
|
extern const GpioPin gpio_spi_r_miso;
|
||||||
extern const GpioPin gpio_spi_r_mosi;
|
extern const GpioPin gpio_spi_r_mosi;
|
||||||
extern const GpioPin gpio_spi_r_sck;
|
extern const GpioPin gpio_spi_r_sck;
|
||||||
extern const GpioPin gpio_spi_r_miso_ext;
|
|
||||||
extern const GpioPin gpio_spi_r_mosi_ext;
|
|
||||||
extern const GpioPin gpio_spi_r_sck_ext;
|
|
||||||
|
|
||||||
extern const GpioPin gpio_ext_pc0;
|
extern const GpioPin gpio_ext_pc0;
|
||||||
extern const GpioPin gpio_ext_pc1;
|
extern const GpioPin gpio_ext_pc1;
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <furi_hal_spi.h>
|
#include <furi_hal_spi.h>
|
||||||
#include <furi_hal_bus.h>
|
#include <furi_hal_bus.h>
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <furi_hal_subghz.h>
|
|
||||||
|
|
||||||
#define TAG "FuriHalSpiConfig"
|
#define TAG "FuriHalSpiConfig"
|
||||||
|
|
||||||
@@ -91,7 +90,7 @@ void furi_hal_spi_config_deinit_early() {
|
|||||||
void furi_hal_spi_config_init() {
|
void furi_hal_spi_config_init() {
|
||||||
furi_hal_spi_bus_init(&furi_hal_spi_bus_r);
|
furi_hal_spi_bus_init(&furi_hal_spi_bus_r);
|
||||||
|
|
||||||
furi_hal_spi_bus_handle_init(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_nfc);
|
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_nfc);
|
||||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast);
|
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast);
|
||||||
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow);
|
furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow);
|
||||||
@@ -265,15 +264,6 @@ static void furi_hal_spi_bus_handle_subghz_event_callback(
|
|||||||
furi_hal_spi_bus_r_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_8m);
|
furi_hal_spi_bus_r_handle_event_callback(handle, event, &furi_hal_spi_preset_1edge_low_8m);
|
||||||
}
|
}
|
||||||
|
|
||||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz_int = {
|
|
||||||
.bus = &furi_hal_spi_bus_r,
|
|
||||||
.callback = furi_hal_spi_bus_handle_subghz_event_callback,
|
|
||||||
.miso = &gpio_spi_r_miso,
|
|
||||||
.mosi = &gpio_spi_r_mosi,
|
|
||||||
.sck = &gpio_spi_r_sck,
|
|
||||||
.cs = &gpio_subghz_cs,
|
|
||||||
};
|
|
||||||
|
|
||||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz = {
|
FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz = {
|
||||||
.bus = &furi_hal_spi_bus_r,
|
.bus = &furi_hal_spi_bus_r,
|
||||||
.callback = furi_hal_spi_bus_handle_subghz_event_callback,
|
.callback = furi_hal_spi_bus_handle_subghz_event_callback,
|
||||||
@@ -283,15 +273,6 @@ FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz = {
|
|||||||
.cs = &gpio_subghz_cs,
|
.cs = &gpio_subghz_cs,
|
||||||
};
|
};
|
||||||
|
|
||||||
FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz_ext = {
|
|
||||||
.bus = &furi_hal_spi_bus_r,
|
|
||||||
.callback = furi_hal_spi_bus_handle_subghz_event_callback,
|
|
||||||
.miso = &gpio_ext_pa6,
|
|
||||||
.mosi = &gpio_ext_pa7,
|
|
||||||
.sck = &gpio_ext_pb3,
|
|
||||||
.cs = &gpio_ext_pa4,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void furi_hal_spi_bus_handle_nfc_event_callback(
|
static void furi_hal_spi_bus_handle_nfc_event_callback(
|
||||||
FuriHalSpiBusHandle* handle,
|
FuriHalSpiBusHandle* handle,
|
||||||
FuriHalSpiBusHandleEvent event) {
|
FuriHalSpiBusHandleEvent event) {
|
||||||
|
|||||||
@@ -27,12 +27,8 @@ extern FuriHalSpiBus furi_hal_spi_bus_r;
|
|||||||
/** Furi Hal Spi Bus D (Display, SdCard) */
|
/** Furi Hal Spi Bus D (Display, SdCard) */
|
||||||
extern FuriHalSpiBus furi_hal_spi_bus_d;
|
extern FuriHalSpiBus furi_hal_spi_bus_d;
|
||||||
|
|
||||||
/** CC1101 on current SPI bus */
|
|
||||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz;
|
|
||||||
/** CC1101 on `furi_hal_spi_bus_r` */
|
/** CC1101 on `furi_hal_spi_bus_r` */
|
||||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz_int;
|
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz;
|
||||||
/** CC1101 on external `furi_hal_spi_bus_r` */
|
|
||||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_subghz_ext;
|
|
||||||
|
|
||||||
/** ST25R3916 on `furi_hal_spi_bus_r` */
|
/** ST25R3916 on `furi_hal_spi_bus_r` */
|
||||||
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_nfc;
|
extern FuriHalSpiBusHandle furi_hal_spi_bus_handle_nfc;
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
#include <furi_hal_subghz.h>
|
#include <furi_hal_subghz.h>
|
||||||
#include <furi_hal_subghz_configs.h>
|
#include <lib/subghz/devices/cc1101_configs.h>
|
||||||
|
|
||||||
#include <furi_hal_version.h>
|
#include <furi_hal_version.h>
|
||||||
#include <furi_hal_rtc.h>
|
#include <furi_hal_rtc.h>
|
||||||
#include <furi_hal_spi.h>
|
#include <furi_hal_spi.h>
|
||||||
#include <furi_hal_interrupt.h>
|
#include <furi_hal_interrupt.h>
|
||||||
#include <furi_hal_resources.h>
|
#include <furi_hal_resources.h>
|
||||||
#include <furi_hal_power.h>
|
|
||||||
#include <furi_hal_bus.h>
|
#include <furi_hal_bus.h>
|
||||||
|
|
||||||
#include <stm32wbxx_ll_dma.h>
|
#include <stm32wbxx_ll_dma.h>
|
||||||
|
|
||||||
#include <lib/flipper_format/flipper_format.h>
|
#include <lib/flipper_format/flipper_format.h> // TODO
|
||||||
|
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <cc1101.h>
|
#include <cc1101.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#define TAG "FuriHalSubGhz"
|
#define TAG "FuriHalSubGhz"
|
||||||
//Initialisation timeout (ms)
|
|
||||||
#define INIT_TIMEOUT 10
|
|
||||||
|
|
||||||
static uint32_t furi_hal_subghz_debug_gpio_buff[2];
|
static uint32_t furi_hal_subghz_debug_gpio_buff[2];
|
||||||
|
|
||||||
@@ -31,48 +28,47 @@ static uint32_t furi_hal_subghz_debug_gpio_buff[2];
|
|||||||
#define SUBGHZ_DMA_CH1_DEF SUBGHZ_DMA, SUBGHZ_DMA_CH1_CHANNEL
|
#define SUBGHZ_DMA_CH1_DEF SUBGHZ_DMA, SUBGHZ_DMA_CH1_CHANNEL
|
||||||
#define SUBGHZ_DMA_CH2_DEF SUBGHZ_DMA, SUBGHZ_DMA_CH2_CHANNEL
|
#define SUBGHZ_DMA_CH2_DEF SUBGHZ_DMA, SUBGHZ_DMA_CH2_CHANNEL
|
||||||
|
|
||||||
|
/** SubGhz state */
|
||||||
|
typedef enum {
|
||||||
|
SubGhzStateInit, /**< Init pending */
|
||||||
|
|
||||||
|
SubGhzStateIdle, /**< Idle, energy save mode */
|
||||||
|
|
||||||
|
SubGhzStateAsyncRx, /**< Async RX started */
|
||||||
|
|
||||||
|
SubGhzStateAsyncTx, /**< Async TX started, DMA and timer is on */
|
||||||
|
SubGhzStateAsyncTxLast, /**< Async TX continue, DMA completed and timer got last value to go */
|
||||||
|
SubGhzStateAsyncTxEnd, /**< Async TX complete, cleanup needed */
|
||||||
|
|
||||||
|
} SubGhzState;
|
||||||
|
|
||||||
|
/** SubGhz regulation, receive transmission on the current frequency for the
|
||||||
|
* region */
|
||||||
|
typedef enum {
|
||||||
|
SubGhzRegulationOnlyRx, /**only Rx*/
|
||||||
|
SubGhzRegulationTxRx, /**TxRx*/
|
||||||
|
} SubGhzRegulation;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile SubGhzState state;
|
||||||
|
volatile SubGhzRegulation regulation;
|
||||||
|
volatile FuriHalSubGhzPreset preset;
|
||||||
|
const GpioPin* async_mirror_pin;
|
||||||
|
|
||||||
|
uint8_t rolling_counter_mult;
|
||||||
|
bool timestamp_file_names : 1;
|
||||||
|
bool dangerous_frequency_i : 1;
|
||||||
|
} FuriHalSubGhz;
|
||||||
|
|
||||||
volatile FuriHalSubGhz furi_hal_subghz = {
|
volatile FuriHalSubGhz furi_hal_subghz = {
|
||||||
.state = SubGhzStateInit,
|
.state = SubGhzStateInit,
|
||||||
.regulation = SubGhzRegulationTxRx,
|
.regulation = SubGhzRegulationTxRx,
|
||||||
.preset = FuriHalSubGhzPresetIDLE,
|
.preset = FuriHalSubGhzPresetIDLE,
|
||||||
.async_mirror_pin = NULL,
|
.async_mirror_pin = NULL,
|
||||||
.radio_type = SubGhzRadioInternal,
|
|
||||||
.spi_bus_handle = &furi_hal_spi_bus_handle_subghz,
|
|
||||||
.cc1101_g0_pin = &gpio_cc1101_g0,
|
|
||||||
.rolling_counter_mult = 1,
|
.rolling_counter_mult = 1,
|
||||||
.ext_module_power_disabled = false,
|
|
||||||
.dangerous_frequency_i = false,
|
.dangerous_frequency_i = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
void furi_hal_subghz_select_radio_type(SubGhzRadioType state) {
|
|
||||||
furi_hal_subghz.radio_type = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_subghz_init_radio_type(SubGhzRadioType state) {
|
|
||||||
if(state == SubGhzRadioInternal && furi_hal_subghz.cc1101_g0_pin == &gpio_cc1101_g0) {
|
|
||||||
return true;
|
|
||||||
} else if(state == SubGhzRadioExternal && furi_hal_subghz.cc1101_g0_pin == &gpio_cc1101_g0_ext) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
furi_hal_spi_bus_handle_deinit(furi_hal_subghz.spi_bus_handle);
|
|
||||||
|
|
||||||
if(state == SubGhzRadioInternal) {
|
|
||||||
furi_hal_subghz.spi_bus_handle = &furi_hal_spi_bus_handle_subghz;
|
|
||||||
furi_hal_subghz.cc1101_g0_pin = &gpio_cc1101_g0;
|
|
||||||
} else {
|
|
||||||
furi_hal_subghz.spi_bus_handle = &furi_hal_spi_bus_handle_subghz_ext;
|
|
||||||
furi_hal_subghz.cc1101_g0_pin = &gpio_cc1101_g0_ext;
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_hal_spi_bus_handle_init(furi_hal_subghz.spi_bus_handle);
|
|
||||||
furi_hal_subghz_init_check();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
SubGhzRadioType furi_hal_subghz_get_radio_type(void) {
|
|
||||||
return furi_hal_subghz.radio_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t furi_hal_subghz_get_rolling_counter_mult(void) {
|
uint8_t furi_hal_subghz_get_rolling_counter_mult(void) {
|
||||||
return furi_hal_subghz.rolling_counter_mult;
|
return furi_hal_subghz.rolling_counter_mult;
|
||||||
}
|
}
|
||||||
@@ -81,14 +77,6 @@ void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult) {
|
|||||||
furi_hal_subghz.rolling_counter_mult = mult;
|
furi_hal_subghz.rolling_counter_mult = mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_external_power_disable(bool state) {
|
|
||||||
furi_hal_subghz.ext_module_power_disabled = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_subghz_get_external_power_disable(void) {
|
|
||||||
return furi_hal_subghz.ext_module_power_disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_subghz_set_dangerous_frequency(bool state_i) {
|
void furi_hal_subghz_set_dangerous_frequency(bool state_i) {
|
||||||
furi_hal_subghz.dangerous_frequency_i = state_i;
|
furi_hal_subghz.dangerous_frequency_i = state_i;
|
||||||
}
|
}
|
||||||
@@ -97,158 +85,105 @@ void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
|||||||
furi_hal_subghz.async_mirror_pin = pin;
|
furi_hal_subghz.async_mirror_pin = pin;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_init(void) {
|
const GpioPin* furi_hal_subghz_get_data_gpio() {
|
||||||
furi_hal_subghz_init_check();
|
return &gpio_cc1101_g0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_enable_ext_power(void) {
|
void furi_hal_subghz_init() {
|
||||||
if(furi_hal_subghz.ext_module_power_disabled) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(furi_hal_subghz.radio_type != SubGhzRadioInternal) {
|
|
||||||
uint8_t attempts = 0;
|
|
||||||
while(!furi_hal_power_is_otg_enabled() && attempts++ < 5) {
|
|
||||||
furi_hal_power_enable_otg();
|
|
||||||
//CC1101 power-up time
|
|
||||||
furi_delay_ms(10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return furi_hal_power_is_otg_enabled();
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_subghz_disable_ext_power(void) {
|
|
||||||
if(furi_hal_power_is_otg_enabled()) {
|
|
||||||
furi_hal_power_disable_otg();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_subghz_check_radio(void) {
|
|
||||||
bool result = true;
|
|
||||||
|
|
||||||
furi_hal_subghz_init_radio_type(furi_hal_subghz.radio_type);
|
|
||||||
|
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
|
||||||
|
|
||||||
uint8_t ver = cc1101_get_version(furi_hal_subghz.spi_bus_handle);
|
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
|
||||||
|
|
||||||
if((ver != 0) && (ver != 255)) {
|
|
||||||
FURI_LOG_D(TAG, "Radio check ok");
|
|
||||||
} else {
|
|
||||||
FURI_LOG_D(TAG, "Radio check failed, revert to default");
|
|
||||||
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool furi_hal_subghz_init_check(void) {
|
|
||||||
bool result = true;
|
|
||||||
|
|
||||||
furi_assert(furi_hal_subghz.state == SubGhzStateInit);
|
furi_assert(furi_hal_subghz.state == SubGhzStateInit);
|
||||||
furi_hal_subghz.state = SubGhzStateIdle;
|
furi_hal_subghz.state = SubGhzStateIdle;
|
||||||
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
||||||
|
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
#ifdef FURI_HAL_SUBGHZ_TX_GPIO
|
#ifdef FURI_HAL_SUBGHZ_TX_GPIO
|
||||||
furi_hal_gpio_init(&FURI_HAL_SUBGHZ_TX_GPIO, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&FURI_HAL_SUBGHZ_TX_GPIO, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Reset
|
// Reset
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
cc1101_reset(furi_hal_subghz.spi_bus_handle);
|
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
||||||
|
|
||||||
// Prepare GD0 for power on self test
|
// Prepare GD0 for power on self test
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
// GD0 low
|
// GD0 low
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHW);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHW);
|
||||||
uint32_t test_start_time = furi_get_tick();
|
while(furi_hal_gpio_read(&gpio_cc1101_g0) != false)
|
||||||
while(furi_hal_gpio_read(furi_hal_subghz.cc1101_g0_pin) != false && result) {
|
;
|
||||||
if(furi_get_tick() - test_start_time > INIT_TIMEOUT) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GD0 high
|
// GD0 high
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHW | CC1101_IOCFG_INV);
|
&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHW | CC1101_IOCFG_INV);
|
||||||
test_start_time = furi_get_tick();
|
while(furi_hal_gpio_read(&gpio_cc1101_g0) != true)
|
||||||
while(furi_hal_gpio_read(furi_hal_subghz.cc1101_g0_pin) != true && result) {
|
;
|
||||||
if(furi_get_tick() - test_start_time > INIT_TIMEOUT) {
|
|
||||||
result = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset GD0 to floating state
|
// Reset GD0 to floating state
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
// RF switches
|
// RF switches
|
||||||
furi_hal_gpio_init(&gpio_rf_sw_0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_rf_sw_0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG2, CC1101IocfgHW);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG2, CC1101IocfgHW);
|
||||||
|
|
||||||
// Go to sleep
|
// Go to sleep
|
||||||
cc1101_shutdown(furi_hal_subghz.spi_bus_handle);
|
cc1101_shutdown(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
FURI_LOG_I(TAG, "Init OK");
|
||||||
if(result) {
|
|
||||||
FURI_LOG_I(TAG, "Init OK");
|
|
||||||
} else {
|
|
||||||
FURI_LOG_E(TAG, "Selected CC1101 module init failed, revert to default");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_sleep() {
|
void furi_hal_subghz_sleep() {
|
||||||
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
cc1101_shutdown(furi_hal_subghz.spi_bus_handle);
|
cc1101_shutdown(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
furi_hal_subghz.preset = FuriHalSubGhzPresetIDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_dump_state() {
|
void furi_hal_subghz_dump_state() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
printf(
|
printf(
|
||||||
"[furi_hal_subghz] cc1101 chip %d, version %d\r\n",
|
"[furi_hal_subghz] cc1101 chip %d, version %d\r\n",
|
||||||
cc1101_get_partnumber(furi_hal_subghz.spi_bus_handle),
|
cc1101_get_partnumber(&furi_hal_spi_bus_handle_subghz),
|
||||||
cc1101_get_version(furi_hal_subghz.spi_bus_handle));
|
cc1101_get_version(&furi_hal_spi_bus_handle_subghz));
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) {
|
void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) {
|
||||||
if(preset == FuriHalSubGhzPresetOok650Async) {
|
if(preset == FuriHalSubGhzPresetOok650Async) {
|
||||||
furi_hal_subghz_load_registers((uint8_t*)furi_hal_subghz_preset_ook_650khz_async_regs);
|
furi_hal_subghz_load_registers(
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_ook_async_patable);
|
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs);
|
||||||
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_ook_async_patable);
|
||||||
} else if(preset == FuriHalSubGhzPresetOok270Async) {
|
} else if(preset == FuriHalSubGhzPresetOok270Async) {
|
||||||
furi_hal_subghz_load_registers((uint8_t*)furi_hal_subghz_preset_ook_270khz_async_regs);
|
furi_hal_subghz_load_registers(
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_ook_async_patable);
|
(uint8_t*)subghz_device_cc1101_preset_ook_270khz_async_regs);
|
||||||
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_ook_async_patable);
|
||||||
} else if(preset == FuriHalSubGhzPreset2FSKDev238Async) {
|
} else if(preset == FuriHalSubGhzPreset2FSKDev238Async) {
|
||||||
furi_hal_subghz_load_registers(
|
furi_hal_subghz_load_registers(
|
||||||
(uint8_t*)furi_hal_subghz_preset_2fsk_dev2_38khz_async_regs);
|
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs);
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_2fsk_async_patable);
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_2fsk_async_patable);
|
||||||
} else if(preset == FuriHalSubGhzPreset2FSKDev476Async) {
|
} else if(preset == FuriHalSubGhzPreset2FSKDev476Async) {
|
||||||
furi_hal_subghz_load_registers(
|
furi_hal_subghz_load_registers(
|
||||||
(uint8_t*)furi_hal_subghz_preset_2fsk_dev47_6khz_async_regs);
|
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs);
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_2fsk_async_patable);
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_2fsk_async_patable);
|
||||||
} else if(preset == FuriHalSubGhzPresetMSK99_97KbAsync) {
|
} else if(preset == FuriHalSubGhzPresetMSK99_97KbAsync) {
|
||||||
furi_hal_subghz_load_registers((uint8_t*)furi_hal_subghz_preset_msk_99_97kb_async_regs);
|
furi_hal_subghz_load_registers(
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_msk_async_patable);
|
(uint8_t*)subghz_device_cc1101_preset_msk_99_97kb_async_regs);
|
||||||
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_msk_async_patable);
|
||||||
} else if(preset == FuriHalSubGhzPresetGFSK9_99KbAsync) {
|
} else if(preset == FuriHalSubGhzPresetGFSK9_99KbAsync) {
|
||||||
furi_hal_subghz_load_registers((uint8_t*)furi_hal_subghz_preset_gfsk_9_99kb_async_regs);
|
furi_hal_subghz_load_registers(
|
||||||
furi_hal_subghz_load_patable(furi_hal_subghz_preset_gfsk_async_patable);
|
(uint8_t*)subghz_device_cc1101_preset_gfsk_9_99kb_async_regs);
|
||||||
|
furi_hal_subghz_load_patable(subghz_device_cc1101_preset_gfsk_async_patable);
|
||||||
} else {
|
} else {
|
||||||
furi_crash("SubGhz: Missing config.");
|
furi_crash("SubGhz: Missing config.");
|
||||||
}
|
}
|
||||||
@@ -257,15 +192,15 @@ void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) {
|
|||||||
|
|
||||||
void furi_hal_subghz_load_custom_preset(uint8_t* preset_data) {
|
void furi_hal_subghz_load_custom_preset(uint8_t* preset_data) {
|
||||||
//load config
|
//load config
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_reset(furi_hal_subghz.spi_bus_handle);
|
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint8_t pa[8] = {0};
|
uint8_t pa[8] = {0};
|
||||||
while(preset_data[i]) {
|
while(preset_data[i]) {
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, preset_data[i], preset_data[i + 1]);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, preset_data[i], preset_data[i + 1]);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
//load pa table
|
//load pa table
|
||||||
memcpy(&pa[0], &preset_data[i + 2], 8);
|
memcpy(&pa[0], &preset_data[i + 2], 8);
|
||||||
@@ -287,48 +222,48 @@ 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(uint8_t* data) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_reset(furi_hal_subghz.spi_bus_handle);
|
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
while(data[i]) {
|
while(data[i]) {
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, data[i], data[i + 1]);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, data[i], data[i + 1]);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_load_patable(const uint8_t data[8]) {
|
void furi_hal_subghz_load_patable(const uint8_t data[8]) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_set_pa_table(furi_hal_subghz.spi_bus_handle, data);
|
cc1101_set_pa_table(&furi_hal_spi_bus_handle_subghz, data);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) {
|
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_flush_tx(furi_hal_subghz.spi_bus_handle);
|
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_FIFO, size);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_FIFO, size);
|
||||||
cc1101_write_fifo(furi_hal_subghz.spi_bus_handle, data, size);
|
cc1101_write_fifo(&furi_hal_spi_bus_handle_subghz, data, size);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_flush_rx() {
|
void furi_hal_subghz_flush_rx() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_flush_rx(furi_hal_subghz.spi_bus_handle);
|
cc1101_flush_rx(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_flush_tx() {
|
void furi_hal_subghz_flush_tx() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_flush_tx(furi_hal_subghz.spi_bus_handle);
|
cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_rx_pipe_not_empty() {
|
bool furi_hal_subghz_rx_pipe_not_empty() {
|
||||||
CC1101RxBytes status[1];
|
CC1101RxBytes status[1];
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_read_reg(
|
cc1101_read_reg(
|
||||||
furi_hal_subghz.spi_bus_handle, (CC1101_STATUS_RXBYTES) | CC1101_BURST, (uint8_t*)status);
|
&furi_hal_spi_bus_handle_subghz, (CC1101_STATUS_RXBYTES) | CC1101_BURST, (uint8_t*)status);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
// TODO: you can add a buffer overflow flag if needed
|
// TODO: you can add a buffer overflow flag if needed
|
||||||
if(status->NUM_RXBYTES > 0) {
|
if(status->NUM_RXBYTES > 0) {
|
||||||
return true;
|
return true;
|
||||||
@@ -338,10 +273,10 @@ bool furi_hal_subghz_rx_pipe_not_empty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_is_rx_data_crc_valid() {
|
bool furi_hal_subghz_is_rx_data_crc_valid() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
uint8_t data[1];
|
uint8_t data[1];
|
||||||
cc1101_read_reg(furi_hal_subghz.spi_bus_handle, CC1101_STATUS_LQI | CC1101_BURST, data);
|
cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
if(((data[0] >> 7) & 0x01)) {
|
if(((data[0] >> 7) & 0x01)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -350,51 +285,51 @@ bool furi_hal_subghz_is_rx_data_crc_valid() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size) {
|
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_read_fifo(furi_hal_subghz.spi_bus_handle, data, size);
|
cc1101_read_fifo(&furi_hal_spi_bus_handle_subghz, data, size);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_shutdown() {
|
void furi_hal_subghz_shutdown() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
// Reset and shutdown
|
// Reset and shutdown
|
||||||
cc1101_shutdown(furi_hal_subghz.spi_bus_handle);
|
cc1101_shutdown(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_reset() {
|
void furi_hal_subghz_reset() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_reset(furi_hal_subghz.spi_bus_handle);
|
cc1101_reset(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG0, CC1101IocfgHighImpedance);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_idle() {
|
void furi_hal_subghz_idle() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_switch_to_idle(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_rx() {
|
void furi_hal_subghz_rx() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_switch_to_rx(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_tx() {
|
bool furi_hal_subghz_tx() {
|
||||||
if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false;
|
if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false;
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
cc1101_switch_to_tx(furi_hal_subghz.spi_bus_handle);
|
cc1101_switch_to_tx(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float furi_hal_subghz_get_rssi() {
|
float furi_hal_subghz_get_rssi() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
int32_t rssi_dec = cc1101_get_rssi(furi_hal_subghz.spi_bus_handle);
|
int32_t rssi_dec = cc1101_get_rssi(&furi_hal_spi_bus_handle_subghz);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
float rssi = rssi_dec;
|
float rssi = rssi_dec;
|
||||||
if(rssi_dec >= 128) {
|
if(rssi_dec >= 128) {
|
||||||
@@ -407,10 +342,10 @@ float furi_hal_subghz_get_rssi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t furi_hal_subghz_get_lqi() {
|
uint8_t furi_hal_subghz_get_lqi() {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
uint8_t data[1];
|
uint8_t data[1];
|
||||||
cc1101_read_reg(furi_hal_subghz.spi_bus_handle, CC1101_STATUS_LQI | CC1101_BURST, data);
|
cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data);
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
return data[0] & 0x7F;
|
return data[0] & 0x7F;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,39 +403,39 @@ bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
|||||||
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
uint32_t furi_hal_subghz_set_frequency(uint32_t value) {
|
||||||
furi_hal_subghz.regulation = SubGhzRegulationTxRx;
|
furi_hal_subghz.regulation = SubGhzRegulationTxRx;
|
||||||
|
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
uint32_t real_frequency = cc1101_set_frequency(furi_hal_subghz.spi_bus_handle, value);
|
uint32_t real_frequency = cc1101_set_frequency(&furi_hal_spi_bus_handle_subghz, value);
|
||||||
cc1101_calibrate(furi_hal_subghz.spi_bus_handle);
|
cc1101_calibrate(&furi_hal_spi_bus_handle_subghz);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
CC1101Status status = cc1101_get_status(furi_hal_subghz.spi_bus_handle);
|
CC1101Status status = cc1101_get_status(&furi_hal_spi_bus_handle_subghz);
|
||||||
if(status.STATE == CC1101StateIDLE) break;
|
if(status.STATE == CC1101StateIDLE) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
return real_frequency;
|
return real_frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void furi_hal_subghz_set_path(FuriHalSubGhzPath path) {
|
void furi_hal_subghz_set_path(FuriHalSubGhzPath path) {
|
||||||
furi_hal_spi_acquire(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz);
|
||||||
if(path == FuriHalSubGhzPath433) {
|
if(path == FuriHalSubGhzPath433) {
|
||||||
furi_hal_gpio_write(&gpio_rf_sw_0, 0);
|
furi_hal_gpio_write(&gpio_rf_sw_0, 0);
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
furi_hal_subghz.spi_bus_handle, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV);
|
&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV);
|
||||||
} else if(path == FuriHalSubGhzPath315) {
|
} else if(path == FuriHalSubGhzPath315) {
|
||||||
furi_hal_gpio_write(&gpio_rf_sw_0, 1);
|
furi_hal_gpio_write(&gpio_rf_sw_0, 1);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG2, CC1101IocfgHW);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG2, CC1101IocfgHW);
|
||||||
} else if(path == FuriHalSubGhzPath868) {
|
} else if(path == FuriHalSubGhzPath868) {
|
||||||
furi_hal_gpio_write(&gpio_rf_sw_0, 1);
|
furi_hal_gpio_write(&gpio_rf_sw_0, 1);
|
||||||
cc1101_write_reg(
|
cc1101_write_reg(
|
||||||
furi_hal_subghz.spi_bus_handle, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV);
|
&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG2, CC1101IocfgHW | CC1101_IOCFG_INV);
|
||||||
} else if(path == FuriHalSubGhzPathIsolate) {
|
} else if(path == FuriHalSubGhzPathIsolate) {
|
||||||
furi_hal_gpio_write(&gpio_rf_sw_0, 0);
|
furi_hal_gpio_write(&gpio_rf_sw_0, 0);
|
||||||
cc1101_write_reg(furi_hal_subghz.spi_bus_handle, CC1101_IOCFG2, CC1101IocfgHW);
|
cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_IOCFG2, CC1101IocfgHW);
|
||||||
} else {
|
} else {
|
||||||
furi_crash("SubGhz: Incorrect path during set.");
|
furi_crash("SubGhz: Incorrect path during set.");
|
||||||
}
|
}
|
||||||
furi_hal_spi_release(furi_hal_subghz.spi_bus_handle);
|
furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool furi_hal_subghz_start_debug() {
|
static bool furi_hal_subghz_start_debug() {
|
||||||
@@ -530,7 +465,7 @@ volatile uint32_t furi_hal_subghz_capture_delta_duration = 0;
|
|||||||
volatile FuriHalSubGhzCaptureCallback furi_hal_subghz_capture_callback = NULL;
|
volatile FuriHalSubGhzCaptureCallback furi_hal_subghz_capture_callback = NULL;
|
||||||
volatile void* furi_hal_subghz_capture_callback_context = NULL;
|
volatile void* furi_hal_subghz_capture_callback_context = NULL;
|
||||||
|
|
||||||
static void furi_hal_subghz_capture_int_ISR() {
|
static void furi_hal_subghz_capture_ISR() {
|
||||||
// Channel 1
|
// Channel 1
|
||||||
if(LL_TIM_IsActiveFlag_CC1(TIM2)) {
|
if(LL_TIM_IsActiveFlag_CC1(TIM2)) {
|
||||||
LL_TIM_ClearFlag_CC1(TIM2);
|
LL_TIM_ClearFlag_CC1(TIM2);
|
||||||
@@ -560,27 +495,6 @@ static void furi_hal_subghz_capture_int_ISR() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void furi_hal_subghz_capture_ext_ISR() {
|
|
||||||
if(!furi_hal_gpio_read(furi_hal_subghz.cc1101_g0_pin)) {
|
|
||||||
if(furi_hal_subghz_capture_callback) {
|
|
||||||
if(furi_hal_subghz.async_mirror_pin != NULL)
|
|
||||||
furi_hal_gpio_write(furi_hal_subghz.async_mirror_pin, false);
|
|
||||||
|
|
||||||
furi_hal_subghz_capture_callback(
|
|
||||||
true, TIM2->CNT, (void*)furi_hal_subghz_capture_callback_context);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(furi_hal_subghz_capture_callback) {
|
|
||||||
if(furi_hal_subghz.async_mirror_pin != NULL)
|
|
||||||
furi_hal_gpio_write(furi_hal_subghz.async_mirror_pin, true);
|
|
||||||
|
|
||||||
furi_hal_subghz_capture_callback(
|
|
||||||
false, TIM2->CNT, (void*)furi_hal_subghz_capture_callback_context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TIM2->CNT = 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context) {
|
void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context) {
|
||||||
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
furi_assert(furi_hal_subghz.state == SubGhzStateIdle);
|
||||||
furi_hal_subghz.state = SubGhzStateAsyncRx;
|
furi_hal_subghz.state = SubGhzStateAsyncRx;
|
||||||
@@ -588,6 +502,9 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void*
|
|||||||
furi_hal_subghz_capture_callback = callback;
|
furi_hal_subghz_capture_callback = callback;
|
||||||
furi_hal_subghz_capture_callback_context = context;
|
furi_hal_subghz_capture_callback_context = context;
|
||||||
|
|
||||||
|
furi_hal_gpio_init_ex(
|
||||||
|
&gpio_cc1101_g0, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn1TIM2);
|
||||||
|
|
||||||
furi_hal_bus_enable(FuriHalBusTIM2);
|
furi_hal_bus_enable(FuriHalBusTIM2);
|
||||||
|
|
||||||
// Timer: base
|
// Timer: base
|
||||||
@@ -595,62 +512,42 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void*
|
|||||||
TIM_InitStruct.Prescaler = 64 - 1;
|
TIM_InitStruct.Prescaler = 64 - 1;
|
||||||
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP;
|
||||||
TIM_InitStruct.Autoreload = 0x7FFFFFFE;
|
TIM_InitStruct.Autoreload = 0x7FFFFFFE;
|
||||||
// Clock division for capture filter (for internal radio)
|
// Clock division for capture filter
|
||||||
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV4;
|
TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV4;
|
||||||
LL_TIM_Init(TIM2, &TIM_InitStruct);
|
LL_TIM_Init(TIM2, &TIM_InitStruct);
|
||||||
|
|
||||||
// Timer: advanced
|
// Timer: advanced
|
||||||
LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL);
|
LL_TIM_SetClockSource(TIM2, LL_TIM_CLOCKSOURCE_INTERNAL);
|
||||||
LL_TIM_DisableARRPreload(TIM2);
|
LL_TIM_DisableARRPreload(TIM2);
|
||||||
|
LL_TIM_SetTriggerInput(TIM2, LL_TIM_TS_TI2FP2);
|
||||||
|
LL_TIM_SetSlaveMode(TIM2, LL_TIM_SLAVEMODE_RESET);
|
||||||
|
LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET);
|
||||||
|
LL_TIM_EnableMasterSlaveMode(TIM2);
|
||||||
LL_TIM_DisableDMAReq_TRIG(TIM2);
|
LL_TIM_DisableDMAReq_TRIG(TIM2);
|
||||||
LL_TIM_DisableIT_TRIG(TIM2);
|
LL_TIM_DisableIT_TRIG(TIM2);
|
||||||
|
|
||||||
if(furi_hal_subghz.radio_type == SubGhzRadioInternal) {
|
// Timer: channel 1 indirect
|
||||||
LL_TIM_SetTriggerInput(TIM2, LL_TIM_TS_TI2FP2);
|
LL_TIM_IC_SetActiveInput(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ACTIVEINPUT_INDIRECTTI);
|
||||||
LL_TIM_SetSlaveMode(TIM2, LL_TIM_SLAVEMODE_RESET);
|
LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
|
||||||
LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_RESET);
|
LL_TIM_IC_SetPolarity(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_IC_POLARITY_FALLING);
|
||||||
LL_TIM_EnableMasterSlaveMode(TIM2);
|
|
||||||
|
|
||||||
// Timer: channel 1 indirect
|
// Timer: channel 2 direct
|
||||||
LL_TIM_IC_SetActiveInput(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ACTIVEINPUT_INDIRECTTI);
|
LL_TIM_IC_SetActiveInput(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ACTIVEINPUT_DIRECTTI);
|
||||||
LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_ICPSC_DIV1);
|
LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ICPSC_DIV1);
|
||||||
LL_TIM_IC_SetPolarity(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_IC_POLARITY_FALLING);
|
LL_TIM_IC_SetPolarity(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_IC_POLARITY_RISING);
|
||||||
LL_TIM_IC_SetFilter(TIM2, LL_TIM_CHANNEL_CH1, LL_TIM_IC_FILTER_FDIV1);
|
LL_TIM_IC_SetFilter(
|
||||||
|
TIM2,
|
||||||
|
LL_TIM_CHANNEL_CH2,
|
||||||
|
LL_TIM_IC_FILTER_FDIV32_N8); // Capture filter: 1/(64000000/64/4/32*8) = 16us
|
||||||
|
|
||||||
// Timer: channel 2 direct
|
// ISR setup
|
||||||
LL_TIM_IC_SetActiveInput(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ACTIVEINPUT_DIRECTTI);
|
furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, furi_hal_subghz_capture_ISR, NULL);
|
||||||
LL_TIM_IC_SetPrescaler(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_ICPSC_DIV1);
|
|
||||||
LL_TIM_IC_SetPolarity(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_IC_POLARITY_RISING);
|
|
||||||
LL_TIM_IC_SetFilter(TIM2, LL_TIM_CHANNEL_CH2, LL_TIM_IC_FILTER_FDIV32_N8);
|
|
||||||
|
|
||||||
// ISR setup
|
// Interrupts and channels
|
||||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, furi_hal_subghz_capture_int_ISR, NULL);
|
LL_TIM_EnableIT_CC1(TIM2);
|
||||||
|
LL_TIM_EnableIT_CC2(TIM2);
|
||||||
// Interrupts and channels
|
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH1);
|
||||||
LL_TIM_EnableIT_CC1(TIM2);
|
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH2);
|
||||||
LL_TIM_EnableIT_CC2(TIM2);
|
|
||||||
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH1);
|
|
||||||
LL_TIM_CC_EnableChannel(TIM2, LL_TIM_CHANNEL_CH2);
|
|
||||||
|
|
||||||
furi_hal_gpio_init_ex(
|
|
||||||
furi_hal_subghz.cc1101_g0_pin,
|
|
||||||
GpioModeAltFunctionPushPull,
|
|
||||||
GpioPullNo,
|
|
||||||
GpioSpeedLow,
|
|
||||||
GpioAltFn1TIM2);
|
|
||||||
} else {
|
|
||||||
furi_hal_gpio_init(
|
|
||||||
furi_hal_subghz.cc1101_g0_pin,
|
|
||||||
GpioModeInterruptRiseFall,
|
|
||||||
GpioPullUp,
|
|
||||||
GpioSpeedVeryHigh);
|
|
||||||
furi_hal_gpio_disable_int_callback(furi_hal_subghz.cc1101_g0_pin);
|
|
||||||
furi_hal_gpio_remove_int_callback(furi_hal_subghz.cc1101_g0_pin);
|
|
||||||
furi_hal_gpio_add_int_callback(
|
|
||||||
furi_hal_subghz.cc1101_g0_pin,
|
|
||||||
furi_hal_subghz_capture_ext_ISR,
|
|
||||||
furi_hal_subghz_capture_callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start timer
|
// Start timer
|
||||||
LL_TIM_SetCounter(TIM2, 0);
|
LL_TIM_SetCounter(TIM2, 0);
|
||||||
@@ -680,14 +577,9 @@ void furi_hal_subghz_stop_async_rx() {
|
|||||||
furi_hal_subghz_stop_debug();
|
furi_hal_subghz_stop_debug();
|
||||||
|
|
||||||
FURI_CRITICAL_EXIT();
|
FURI_CRITICAL_EXIT();
|
||||||
if(furi_hal_subghz.radio_type == SubGhzRadioInternal) {
|
furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL);
|
||||||
furi_hal_interrupt_set_isr(FuriHalInterruptIdTIM2, NULL, NULL);
|
|
||||||
} else {
|
|
||||||
furi_hal_gpio_disable_int_callback(furi_hal_subghz.cc1101_g0_pin);
|
|
||||||
furi_hal_gpio_remove_int_callback(furi_hal_subghz.cc1101_g0_pin);
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -791,8 +683,7 @@ static void furi_hal_subghz_async_tx_timer_isr() {
|
|||||||
} else if(furi_hal_subghz.state == SubGhzStateAsyncTxLast) {
|
} else if(furi_hal_subghz.state == SubGhzStateAsyncTxLast) {
|
||||||
furi_hal_subghz.state = SubGhzStateAsyncTxEnd;
|
furi_hal_subghz.state = SubGhzStateAsyncTxEnd;
|
||||||
//forcibly pulls the pin to the ground so that there is no carrier
|
//forcibly pulls the pin to the ground so that there is no carrier
|
||||||
furi_hal_gpio_init(
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullDown, GpioSpeedLow);
|
||||||
furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullDown, GpioSpeedLow);
|
|
||||||
LL_TIM_DisableCounter(TIM2);
|
LL_TIM_DisableCounter(TIM2);
|
||||||
} else {
|
} else {
|
||||||
furi_crash(NULL);
|
furi_crash(NULL);
|
||||||
@@ -819,20 +710,9 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void*
|
|||||||
furi_hal_subghz_async_tx.buffer =
|
furi_hal_subghz_async_tx.buffer =
|
||||||
malloc(API_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL * sizeof(uint32_t));
|
malloc(API_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL * sizeof(uint32_t));
|
||||||
|
|
||||||
if(furi_hal_subghz.radio_type == SubGhzRadioInternal) {
|
// Connect CC1101_GD0 to TIM2 as output
|
||||||
// Connect CC1101_GD0 to TIM2 as output
|
furi_hal_gpio_init_ex(
|
||||||
furi_hal_gpio_init_ex(
|
&gpio_cc1101_g0, GpioModeAltFunctionPushPull, GpioPullDown, GpioSpeedLow, GpioAltFn1TIM2);
|
||||||
furi_hal_subghz.cc1101_g0_pin,
|
|
||||||
GpioModeAltFunctionPushPull,
|
|
||||||
GpioPullDown,
|
|
||||||
GpioSpeedLow,
|
|
||||||
GpioAltFn1TIM2);
|
|
||||||
} else {
|
|
||||||
//Signal generation with mem-to-mem DMA
|
|
||||||
furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, true);
|
|
||||||
furi_hal_gpio_init(
|
|
||||||
furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure DMA
|
// Configure DMA
|
||||||
LL_DMA_InitTypeDef dma_config = {0};
|
LL_DMA_InitTypeDef dma_config = {0};
|
||||||
@@ -895,27 +775,15 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void*
|
|||||||
LL_TIM_EnableCounter(TIM2);
|
LL_TIM_EnableCounter(TIM2);
|
||||||
|
|
||||||
// Start debug
|
// Start debug
|
||||||
if(furi_hal_subghz_start_debug() || furi_hal_subghz.radio_type == SubGhzRadioExternal) {
|
if(furi_hal_subghz_start_debug()) {
|
||||||
const GpioPin* gpio = furi_hal_subghz.cc1101_g0_pin;
|
const GpioPin* gpio = furi_hal_subghz.async_mirror_pin;
|
||||||
//Preparing bit mask
|
// //Preparing bit mask
|
||||||
//Debug pin is may be only PORTB! (PB0, PB1, .., PB15)
|
// //Debug pin is may be only PORTB! (PB0, PB1, .., PB15)
|
||||||
furi_hal_subghz_debug_gpio_buff[0] = 0;
|
// furi_hal_subghz_debug_gpio_buff[0] = 0;
|
||||||
furi_hal_subghz_debug_gpio_buff[1] = 0;
|
// furi_hal_subghz_debug_gpio_buff[1] = 0;
|
||||||
|
|
||||||
//Mirror pin (for example, speaker)
|
furi_hal_subghz_debug_gpio_buff[0] = (uint32_t)gpio->pin << GPIO_NUMBER;
|
||||||
if(furi_hal_subghz.async_mirror_pin != NULL) {
|
furi_hal_subghz_debug_gpio_buff[1] = gpio->pin;
|
||||||
furi_hal_subghz_debug_gpio_buff[0] |= (uint32_t)furi_hal_subghz.async_mirror_pin->pin
|
|
||||||
<< GPIO_NUMBER;
|
|
||||||
furi_hal_subghz_debug_gpio_buff[1] |= furi_hal_subghz.async_mirror_pin->pin;
|
|
||||||
gpio = furi_hal_subghz.async_mirror_pin;
|
|
||||||
}
|
|
||||||
|
|
||||||
//G0 singnal generation for external radio
|
|
||||||
if(furi_hal_subghz.radio_type == SubGhzRadioExternal) {
|
|
||||||
furi_hal_subghz_debug_gpio_buff[0] |= (uint32_t)furi_hal_subghz.cc1101_g0_pin->pin
|
|
||||||
<< GPIO_NUMBER;
|
|
||||||
furi_hal_subghz_debug_gpio_buff[1] |= furi_hal_subghz.cc1101_g0_pin->pin;
|
|
||||||
}
|
|
||||||
|
|
||||||
dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_debug_gpio_buff;
|
dma_config.MemoryOrM2MDstAddress = (uint32_t)furi_hal_subghz_debug_gpio_buff;
|
||||||
dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (gpio->port->BSRR);
|
dma_config.PeriphOrM2MSrcAddress = (uint32_t) & (gpio->port->BSRR);
|
||||||
@@ -948,9 +816,9 @@ void furi_hal_subghz_stop_async_tx() {
|
|||||||
|
|
||||||
// Shutdown radio
|
// Shutdown radio
|
||||||
furi_hal_subghz_idle();
|
furi_hal_subghz_idle();
|
||||||
if(furi_hal_subghz.radio_type == SubGhzRadioExternal) {
|
#ifdef FURI_HAL_SUBGHZ_TX_GPIO
|
||||||
furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false);
|
furi_hal_gpio_write(&FURI_HAL_SUBGHZ_TX_GPIO, false);
|
||||||
}
|
#endif
|
||||||
|
|
||||||
// Deinitialize Timer
|
// Deinitialize Timer
|
||||||
FURI_CRITICAL_ENTER();
|
FURI_CRITICAL_ENTER();
|
||||||
@@ -963,14 +831,10 @@ void furi_hal_subghz_stop_async_tx() {
|
|||||||
furi_hal_interrupt_set_isr(SUBGHZ_DMA_CH1_IRQ, NULL, NULL);
|
furi_hal_interrupt_set_isr(SUBGHZ_DMA_CH1_IRQ, NULL, NULL);
|
||||||
|
|
||||||
// Deinitialize GPIO
|
// Deinitialize GPIO
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
|
||||||
|
|
||||||
// Stop debug
|
// Stop debug
|
||||||
furi_hal_subghz_stop_debug();
|
if(furi_hal_subghz_stop_debug()) {
|
||||||
|
|
||||||
if(((furi_hal_subghz.async_mirror_pin != NULL) &&
|
|
||||||
(furi_hal_subghz.radio_type == SubGhzRadioInternal)) ||
|
|
||||||
(furi_hal_subghz.radio_type == SubGhzRadioExternal)) {
|
|
||||||
LL_DMA_DisableChannel(SUBGHZ_DMA_CH2_DEF);
|
LL_DMA_DisableChannel(SUBGHZ_DMA_CH2_DEF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <lib/subghz/devices/preset.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <toolbox/level_duration.h>
|
#include <toolbox/level_duration.h>
|
||||||
#include <furi_hal_gpio.h>
|
#include <furi_hal_gpio.h>
|
||||||
#include <furi_hal_spi_types.h>
|
// #include <furi_hal_spi_types.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -21,18 +23,6 @@ extern "C" {
|
|||||||
#define API_HAL_SUBGHZ_ASYNC_TX_BUFFER_HALF (API_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL / 2)
|
#define API_HAL_SUBGHZ_ASYNC_TX_BUFFER_HALF (API_HAL_SUBGHZ_ASYNC_TX_BUFFER_FULL / 2)
|
||||||
#define API_HAL_SUBGHZ_ASYNC_TX_GUARD_TIME 999
|
#define API_HAL_SUBGHZ_ASYNC_TX_GUARD_TIME 999
|
||||||
|
|
||||||
/** Radio Presets */
|
|
||||||
typedef enum {
|
|
||||||
FuriHalSubGhzPresetIDLE, /**< default configuration */
|
|
||||||
FuriHalSubGhzPresetOok270Async, /**< OOK, bandwidth 270kHz, asynchronous */
|
|
||||||
FuriHalSubGhzPresetOok650Async, /**< OOK, bandwidth 650kHz, asynchronous */
|
|
||||||
FuriHalSubGhzPreset2FSKDev238Async, /**< FM, deviation 2.380371 kHz, asynchronous */
|
|
||||||
FuriHalSubGhzPreset2FSKDev476Async, /**< FM, deviation 47.60742 kHz, asynchronous */
|
|
||||||
FuriHalSubGhzPresetMSK99_97KbAsync, /**< MSK, deviation 47.60742 kHz, 99.97Kb/s, asynchronous */
|
|
||||||
FuriHalSubGhzPresetGFSK9_99KbAsync, /**< GFSK, deviation 19.042969 kHz, 9.996Kb/s, asynchronous */
|
|
||||||
FuriHalSubGhzPresetCustom, /**Custom Preset*/
|
|
||||||
} FuriHalSubGhzPreset;
|
|
||||||
|
|
||||||
/** Switchable Radio Paths */
|
/** Switchable Radio Paths */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FuriHalSubGhzPathIsolate, /**< Isolate Radio from antenna */
|
FuriHalSubGhzPathIsolate, /**< Isolate Radio from antenna */
|
||||||
@@ -41,50 +31,6 @@ typedef enum {
|
|||||||
FuriHalSubGhzPath868, /**< Center Frequency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
|
FuriHalSubGhzPath868, /**< Center Frequency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
|
||||||
} FuriHalSubGhzPath;
|
} FuriHalSubGhzPath;
|
||||||
|
|
||||||
/** SubGhz state */
|
|
||||||
typedef enum {
|
|
||||||
SubGhzStateInit, /**< Init pending */
|
|
||||||
|
|
||||||
SubGhzStateIdle, /**< Idle, energy save mode */
|
|
||||||
|
|
||||||
SubGhzStateAsyncRx, /**< Async RX started */
|
|
||||||
|
|
||||||
SubGhzStateAsyncTx, /**< Async TX started, DMA and timer is on */
|
|
||||||
SubGhzStateAsyncTxLast, /**< Async TX continue, DMA completed and timer got last value to go */
|
|
||||||
SubGhzStateAsyncTxEnd, /**< Async TX complete, cleanup needed */
|
|
||||||
|
|
||||||
} SubGhzState;
|
|
||||||
|
|
||||||
/** SubGhz regulation, receive transmission on the current frequency for the
|
|
||||||
* region */
|
|
||||||
typedef enum {
|
|
||||||
SubGhzRegulationOnlyRx, /**only Rx*/
|
|
||||||
SubGhzRegulationTxRx, /**TxRx*/
|
|
||||||
} SubGhzRegulation;
|
|
||||||
|
|
||||||
/** SubGhz radio types */
|
|
||||||
typedef enum {
|
|
||||||
SubGhzRadioInternal,
|
|
||||||
SubGhzRadioExternal,
|
|
||||||
} SubGhzRadioType;
|
|
||||||
|
|
||||||
/** Structure for accessing SubGhz settings*/
|
|
||||||
typedef struct {
|
|
||||||
volatile SubGhzState state;
|
|
||||||
volatile SubGhzRegulation regulation;
|
|
||||||
volatile FuriHalSubGhzPreset preset;
|
|
||||||
const GpioPin* async_mirror_pin;
|
|
||||||
SubGhzRadioType radio_type;
|
|
||||||
FuriHalSpiBusHandle* spi_bus_handle;
|
|
||||||
const GpioPin* cc1101_g0_pin;
|
|
||||||
uint8_t rolling_counter_mult;
|
|
||||||
bool ext_module_power_disabled : 1;
|
|
||||||
bool timestamp_file_names : 1;
|
|
||||||
bool dangerous_frequency_i : 1;
|
|
||||||
} FuriHalSubGhz;
|
|
||||||
|
|
||||||
extern volatile FuriHalSubGhz furi_hal_subghz;
|
|
||||||
|
|
||||||
/* Mirror RX/TX async modulation signal to specified pin
|
/* Mirror RX/TX async modulation signal to specified pin
|
||||||
*
|
*
|
||||||
* @warning Configures pin to output mode. Make sure it is not connected
|
* @warning Configures pin to output mode. Make sure it is not connected
|
||||||
@@ -94,19 +40,18 @@ extern volatile FuriHalSubGhz furi_hal_subghz;
|
|||||||
*/
|
*/
|
||||||
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin);
|
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin);
|
||||||
|
|
||||||
|
/** Get data GPIO
|
||||||
|
*
|
||||||
|
* @return pointer to the gpio pin structure
|
||||||
|
*/
|
||||||
|
const GpioPin* furi_hal_subghz_get_data_gpio();
|
||||||
|
|
||||||
/** Initialize and switch to power save mode Used by internal API-HAL
|
/** Initialize and switch to power save mode Used by internal API-HAL
|
||||||
* initialization routine Can be used to reinitialize device to safe state and
|
* initialization routine Can be used to reinitialize device to safe state and
|
||||||
* send it to sleep
|
* send it to sleep
|
||||||
*/
|
*/
|
||||||
void furi_hal_subghz_init();
|
void furi_hal_subghz_init();
|
||||||
|
|
||||||
/** Initialize and switch to power save mode Used by internal API-HAL
|
|
||||||
* initialization routine Can be used to reinitialize device to safe state and
|
|
||||||
* send it to sleep
|
|
||||||
* @return true if initialisation is successfully
|
|
||||||
*/
|
|
||||||
bool furi_hal_subghz_init_check(void);
|
|
||||||
|
|
||||||
/** Send device to sleep mode
|
/** Send device to sleep mode
|
||||||
*/
|
*/
|
||||||
void furi_hal_subghz_sleep();
|
void furi_hal_subghz_sleep();
|
||||||
@@ -234,6 +179,16 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
|||||||
*/
|
*/
|
||||||
bool furi_hal_subghz_is_tx_allowed(uint32_t value);
|
bool furi_hal_subghz_is_tx_allowed(uint32_t value);
|
||||||
|
|
||||||
|
/** Get the current rolling protocols counter ++ value
|
||||||
|
* @return uint8_t current value
|
||||||
|
*/
|
||||||
|
uint8_t furi_hal_subghz_get_rolling_counter_mult(void);
|
||||||
|
|
||||||
|
/** Set the current rolling protocols counter ++ value
|
||||||
|
* @param mult uint8_t = 1, 2, 4, 8
|
||||||
|
*/
|
||||||
|
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
||||||
|
|
||||||
/** Set frequency
|
/** Set frequency
|
||||||
*
|
*
|
||||||
* @param value frequency in Hz
|
* @param value frequency in Hz
|
||||||
@@ -289,52 +244,49 @@ bool furi_hal_subghz_is_async_tx_complete();
|
|||||||
*/
|
*/
|
||||||
void furi_hal_subghz_stop_async_tx();
|
void furi_hal_subghz_stop_async_tx();
|
||||||
|
|
||||||
/** Switching between internal and external radio
|
// /** Initialize and switch to power save mode Used by internal API-HAL
|
||||||
* @param state SubGhzRadioInternal or SubGhzRadioExternal
|
// * initialization routine Can be used to reinitialize device to safe state and
|
||||||
* @return true if switching is successful
|
// * send it to sleep
|
||||||
*/
|
// * @return true if initialisation is successfully
|
||||||
bool furi_hal_subghz_init_radio_type(SubGhzRadioType state);
|
// */
|
||||||
|
// bool furi_hal_subghz_init_check(void);
|
||||||
|
|
||||||
/** Get current radio
|
// /** Switching between internal and external radio
|
||||||
* @return SubGhzRadioInternal or SubGhzRadioExternal
|
// * @param state SubGhzRadioInternal or SubGhzRadioExternal
|
||||||
*/
|
// * @return true if switching is successful
|
||||||
SubGhzRadioType furi_hal_subghz_get_radio_type(void);
|
// */
|
||||||
|
// bool furi_hal_subghz_init_radio_type(SubGhzRadioType state);
|
||||||
|
|
||||||
/** Check for a radio module
|
// /** Get current radio
|
||||||
* @return true if check is successful
|
// * @return SubGhzRadioInternal or SubGhzRadioExternal
|
||||||
*/
|
// */
|
||||||
bool furi_hal_subghz_check_radio(void);
|
// SubGhzRadioType furi_hal_subghz_get_radio_type(void);
|
||||||
|
|
||||||
/** Turn on the power of the external radio module
|
// /** Check for a radio module
|
||||||
* @return true if power-up is successful
|
// * @return true if check is successful
|
||||||
*/
|
// */
|
||||||
bool furi_hal_subghz_enable_ext_power(void);
|
// bool furi_hal_subghz_check_radio(void);
|
||||||
|
|
||||||
/** Turn off the power of the external radio module
|
// /** Turn on the power of the external radio module
|
||||||
*/
|
// * @return true if power-up is successful
|
||||||
void furi_hal_subghz_disable_ext_power(void);
|
// */
|
||||||
|
// bool furi_hal_subghz_enable_ext_power(void);
|
||||||
|
|
||||||
/** Get the current rolling protocols counter ++ value
|
// /** Turn off the power of the external radio module
|
||||||
* @return uint8_t current value
|
// */
|
||||||
*/
|
// void furi_hal_subghz_disable_ext_power(void);
|
||||||
uint8_t furi_hal_subghz_get_rolling_counter_mult(void);
|
|
||||||
|
|
||||||
/** Set the current rolling protocols counter ++ value
|
// /** If true - disable 5v power of the external radio module
|
||||||
* @param mult uint8_t = 1, 2, 4, 8
|
// */
|
||||||
*/
|
// void furi_hal_subghz_set_external_power_disable(bool state);
|
||||||
void furi_hal_subghz_set_rolling_counter_mult(uint8_t mult);
|
|
||||||
|
|
||||||
/** If true - disable 5v power of the external radio module
|
// /** Get the current state of the external power disable flag
|
||||||
*/
|
// */
|
||||||
void furi_hal_subghz_set_external_power_disable(bool state);
|
// bool furi_hal_subghz_get_external_power_disable(void);
|
||||||
|
|
||||||
/** Get the current state of the external power disable flag
|
// /** Set what radio module we will be using
|
||||||
*/
|
// */
|
||||||
bool furi_hal_subghz_get_external_power_disable(void);
|
// void furi_hal_subghz_select_radio_type(SubGhzRadioType state);
|
||||||
|
|
||||||
/** Set what radio module we will be using
|
|
||||||
*/
|
|
||||||
void furi_hal_subghz_select_radio_type(SubGhzRadioType state);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,304 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <cc1101.h>
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_ook_270khz_async_regs[][2] = {
|
|
||||||
// https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/382066/cc1101---don-t-know-the-correct-registers-configuration
|
|
||||||
|
|
||||||
/* GPIO GD0 */
|
|
||||||
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
|
|
||||||
|
|
||||||
/* FIFO and internals */
|
|
||||||
{CC1101_FIFOTHR, 0x47}, // The only important bit is ADC_RETENTION, FIFO Tx=33 Rx=32
|
|
||||||
|
|
||||||
/* Packet engine */
|
|
||||||
{CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
|
|
||||||
|
|
||||||
/* Frequency Synthesizer Control */
|
|
||||||
{CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz
|
|
||||||
|
|
||||||
// Modem Configuration
|
|
||||||
{CC1101_MDMCFG0, 0x00}, // Channel spacing is 25kHz
|
|
||||||
{CC1101_MDMCFG1, 0x00}, // Channel spacing is 25kHz
|
|
||||||
{CC1101_MDMCFG2, 0x30}, // Format ASK/OOK, No preamble/sync
|
|
||||||
{CC1101_MDMCFG3, 0x32}, // Data rate is 3.79372 kBaud
|
|
||||||
{CC1101_MDMCFG4, 0x67}, // Rx BW filter is 270.833333kHz
|
|
||||||
|
|
||||||
/* Main Radio Control State Machine */
|
|
||||||
{CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
|
|
||||||
|
|
||||||
/* Frequency Offset Compensation Configuration */
|
|
||||||
{CC1101_FOCCFG,
|
|
||||||
0x18}, // no frequency offset compensation, POST_K same as PRE_K, PRE_K is 4K, GATE is off
|
|
||||||
|
|
||||||
/* Automatic Gain Control */
|
|
||||||
{CC1101_AGCCTRL0,
|
|
||||||
0x40}, // 01 - Low hysteresis, small asymmetric dead zone, medium gain; 00 - 8 samples agc; 00 - Normal AGC, 00 - 4dB boundary
|
|
||||||
{CC1101_AGCCTRL1,
|
|
||||||
0x00}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
|
|
||||||
{CC1101_AGCCTRL2, 0x03}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 011 - MAIN_TARGET 24 dB
|
|
||||||
|
|
||||||
/* Wake on radio and timeouts control */
|
|
||||||
{CC1101_WORCTRL, 0xFB}, // WOR_RES is 2^15 periods (0.91 - 0.94 s) 16.5 - 17.2 hours
|
|
||||||
|
|
||||||
/* Frontend configuration */
|
|
||||||
{CC1101_FREND0, 0x11}, // Adjusts current TX LO buffer + high is PATABLE[1]
|
|
||||||
{CC1101_FREND1, 0xB6}, //
|
|
||||||
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_ook_650khz_async_regs[][2] = {
|
|
||||||
// https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/382066/cc1101---don-t-know-the-correct-registers-configuration
|
|
||||||
|
|
||||||
/* GPIO GD0 */
|
|
||||||
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
|
|
||||||
|
|
||||||
/* FIFO and internals */
|
|
||||||
{CC1101_FIFOTHR, 0x07}, // The only important bit is ADC_RETENTION
|
|
||||||
|
|
||||||
/* Packet engine */
|
|
||||||
{CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
|
|
||||||
|
|
||||||
/* Frequency Synthesizer Control */
|
|
||||||
{CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz
|
|
||||||
|
|
||||||
// Modem Configuration
|
|
||||||
{CC1101_MDMCFG0, 0x00}, // Channel spacing is 25kHz
|
|
||||||
{CC1101_MDMCFG1, 0x00}, // Channel spacing is 25kHz
|
|
||||||
{CC1101_MDMCFG2, 0x30}, // Format ASK/OOK, No preamble/sync
|
|
||||||
{CC1101_MDMCFG3, 0x32}, // Data rate is 3.79372 kBaud
|
|
||||||
{CC1101_MDMCFG4, 0x17}, // Rx BW filter is 650.000kHz
|
|
||||||
|
|
||||||
/* Main Radio Control State Machine */
|
|
||||||
{CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
|
|
||||||
|
|
||||||
/* Frequency Offset Compensation Configuration */
|
|
||||||
{CC1101_FOCCFG,
|
|
||||||
0x18}, // no frequency offset compensation, POST_K same as PRE_K, PRE_K is 4K, GATE is off
|
|
||||||
|
|
||||||
/* Automatic Gain Control */
|
|
||||||
// {CC1101_AGCTRL0,0x40}, // 01 - Low hysteresis, small asymmetric dead zone, medium gain; 00 - 8 samples agc; 00 - Normal AGC, 00 - 4dB boundary
|
|
||||||
// {CC1101_AGCTRL1,0x00}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
|
|
||||||
// {CC1101_AGCCTRL2, 0x03}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 011 - MAIN_TARGET 24 dB
|
|
||||||
//MAGN_TARGET for RX filter BW =< 100 kHz is 0x3. For higher RX filter BW's MAGN_TARGET is 0x7.
|
|
||||||
{CC1101_AGCCTRL0,
|
|
||||||
0x91}, // 10 - Medium hysteresis, medium asymmetric dead zone, medium gain ; 01 - 16 samples agc; 00 - Normal AGC, 01 - 8dB boundary
|
|
||||||
{CC1101_AGCCTRL1,
|
|
||||||
0x0}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
|
|
||||||
{CC1101_AGCCTRL2, 0x07}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAIN_TARGET 42 dB
|
|
||||||
|
|
||||||
/* Wake on radio and timeouts control */
|
|
||||||
{CC1101_WORCTRL, 0xFB}, // WOR_RES is 2^15 periods (0.91 - 0.94 s) 16.5 - 17.2 hours
|
|
||||||
|
|
||||||
/* Frontend configuration */
|
|
||||||
{CC1101_FREND0, 0x11}, // Adjusts current TX LO buffer + high is PATABLE[1]
|
|
||||||
{CC1101_FREND1, 0xB6}, //
|
|
||||||
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_2fsk_dev2_38khz_async_regs[][2] = {
|
|
||||||
|
|
||||||
/* GPIO GD0 */
|
|
||||||
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
|
|
||||||
|
|
||||||
/* Frequency Synthesizer Control */
|
|
||||||
{CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz
|
|
||||||
|
|
||||||
/* Packet engine */
|
|
||||||
{CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
|
|
||||||
{CC1101_PKTCTRL1, 0x04},
|
|
||||||
|
|
||||||
// // Modem Configuration
|
|
||||||
{CC1101_MDMCFG0, 0x00},
|
|
||||||
{CC1101_MDMCFG1, 0x02},
|
|
||||||
{CC1101_MDMCFG2, 0x04}, // Format 2-FSK/FM, No preamble/sync, Disable (current optimized)
|
|
||||||
{CC1101_MDMCFG3, 0x83}, // Data rate is 4.79794 kBaud
|
|
||||||
{CC1101_MDMCFG4, 0x67}, //Rx BW filter is 270.833333 kHz
|
|
||||||
{CC1101_DEVIATN, 0x04}, //Deviation 2.380371 kHz
|
|
||||||
|
|
||||||
/* Main Radio Control State Machine */
|
|
||||||
{CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
|
|
||||||
|
|
||||||
/* Frequency Offset Compensation Configuration */
|
|
||||||
{CC1101_FOCCFG,
|
|
||||||
0x16}, // no frequency offset compensation, POST_K same as PRE_K, PRE_K is 4K, GATE is off
|
|
||||||
|
|
||||||
/* Automatic Gain Control */
|
|
||||||
{CC1101_AGCCTRL0,
|
|
||||||
0x91}, //10 - Medium hysteresis, medium asymmetric dead zone, medium gain ; 01 - 16 samples agc; 00 - Normal AGC, 01 - 8dB boundary
|
|
||||||
{CC1101_AGCCTRL1,
|
|
||||||
0x00}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
|
|
||||||
{CC1101_AGCCTRL2, 0x07}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAIN_TARGET 42 dB
|
|
||||||
|
|
||||||
/* Wake on radio and timeouts control */
|
|
||||||
{CC1101_WORCTRL, 0xFB}, // WOR_RES is 2^15 periods (0.91 - 0.94 s) 16.5 - 17.2 hours
|
|
||||||
|
|
||||||
/* Frontend configuration */
|
|
||||||
{CC1101_FREND0, 0x10}, // Adjusts current TX LO buffer
|
|
||||||
{CC1101_FREND1, 0x56},
|
|
||||||
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_2fsk_dev47_6khz_async_regs[][2] = {
|
|
||||||
|
|
||||||
/* GPIO GD0 */
|
|
||||||
{CC1101_IOCFG0, 0x0D}, // GD0 as async serial data output/input
|
|
||||||
|
|
||||||
/* Frequency Synthesizer Control */
|
|
||||||
{CC1101_FSCTRL1, 0x06}, // IF = (26*10^6) / (2^10) * 0x06 = 152343.75Hz
|
|
||||||
|
|
||||||
/* Packet engine */
|
|
||||||
{CC1101_PKTCTRL0, 0x32}, // Async, continious, no whitening
|
|
||||||
{CC1101_PKTCTRL1, 0x04},
|
|
||||||
|
|
||||||
// // Modem Configuration
|
|
||||||
{CC1101_MDMCFG0, 0x00},
|
|
||||||
{CC1101_MDMCFG1, 0x02},
|
|
||||||
{CC1101_MDMCFG2, 0x04}, // Format 2-FSK/FM, No preamble/sync, Disable (current optimized)
|
|
||||||
{CC1101_MDMCFG3, 0x83}, // Data rate is 4.79794 kBaud
|
|
||||||
{CC1101_MDMCFG4, 0x67}, //Rx BW filter is 270.833333 kHz
|
|
||||||
{CC1101_DEVIATN, 0x47}, //Deviation 47.60742 kHz
|
|
||||||
|
|
||||||
/* Main Radio Control State Machine */
|
|
||||||
{CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
|
|
||||||
|
|
||||||
/* Frequency Offset Compensation Configuration */
|
|
||||||
{CC1101_FOCCFG,
|
|
||||||
0x16}, // no frequency offset compensation, POST_K same as PRE_K, PRE_K is 4K, GATE is off
|
|
||||||
|
|
||||||
/* Automatic Gain Control */
|
|
||||||
{CC1101_AGCCTRL0,
|
|
||||||
0x91}, //10 - Medium hysteresis, medium asymmetric dead zone, medium gain ; 01 - 16 samples agc; 00 - Normal AGC, 01 - 8dB boundary
|
|
||||||
{CC1101_AGCCTRL1,
|
|
||||||
0x00}, // 0; 0 - LNA 2 gain is decreased to minimum before decreasing LNA gain; 00 - Relative carrier sense threshold disabled; 0000 - RSSI to MAIN_TARGET
|
|
||||||
{CC1101_AGCCTRL2, 0x07}, // 00 - DVGA all; 000 - MAX LNA+LNA2; 111 - MAIN_TARGET 42 dB
|
|
||||||
|
|
||||||
/* Wake on radio and timeouts control */
|
|
||||||
{CC1101_WORCTRL, 0xFB}, // WOR_RES is 2^15 periods (0.91 - 0.94 s) 16.5 - 17.2 hours
|
|
||||||
|
|
||||||
/* Frontend configuration */
|
|
||||||
{CC1101_FREND0, 0x10}, // Adjusts current TX LO buffer
|
|
||||||
{CC1101_FREND1, 0x56},
|
|
||||||
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_msk_99_97kb_async_regs[][2] = {
|
|
||||||
/* GPIO GD0 */
|
|
||||||
{CC1101_IOCFG0, 0x06},
|
|
||||||
|
|
||||||
{CC1101_FIFOTHR, 0x07}, // The only important bit is ADC_RETENTION
|
|
||||||
{CC1101_SYNC1, 0x46},
|
|
||||||
{CC1101_SYNC0, 0x4C},
|
|
||||||
{CC1101_ADDR, 0x00},
|
|
||||||
{CC1101_PKTLEN, 0x00},
|
|
||||||
{CC1101_CHANNR, 0x00},
|
|
||||||
|
|
||||||
{CC1101_PKTCTRL0, 0x05},
|
|
||||||
|
|
||||||
{CC1101_FSCTRL0, 0x23},
|
|
||||||
{CC1101_FSCTRL1, 0x06},
|
|
||||||
|
|
||||||
{CC1101_MDMCFG0, 0xF8},
|
|
||||||
{CC1101_MDMCFG1, 0x22},
|
|
||||||
{CC1101_MDMCFG2, 0x72},
|
|
||||||
{CC1101_MDMCFG3, 0xF8},
|
|
||||||
{CC1101_MDMCFG4, 0x5B},
|
|
||||||
{CC1101_DEVIATN, 0x47},
|
|
||||||
|
|
||||||
{CC1101_MCSM0, 0x18},
|
|
||||||
{CC1101_FOCCFG, 0x16},
|
|
||||||
|
|
||||||
{CC1101_AGCCTRL0, 0xB2},
|
|
||||||
{CC1101_AGCCTRL1, 0x00},
|
|
||||||
{CC1101_AGCCTRL2, 0xC7},
|
|
||||||
|
|
||||||
{CC1101_FREND0, 0x10},
|
|
||||||
{CC1101_FREND1, 0x56},
|
|
||||||
|
|
||||||
{CC1101_BSCFG, 0x1C},
|
|
||||||
{CC1101_FSTEST, 0x59},
|
|
||||||
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_gfsk_9_99kb_async_regs[][2] = {
|
|
||||||
|
|
||||||
{CC1101_IOCFG0, 0x06}, //GDO0 Output Pin Configuration
|
|
||||||
{CC1101_FIFOTHR, 0x47}, //RX FIFO and TX FIFO Thresholds
|
|
||||||
|
|
||||||
//1 : CRC calculation in TX and CRC check in RX enabled,
|
|
||||||
//1 : Variable packet length mode. Packet length configured by the first byte after sync word
|
|
||||||
{CC1101_PKTCTRL0, 0x05},
|
|
||||||
|
|
||||||
{CC1101_FSCTRL1, 0x06}, //Frequency Synthesizer Control
|
|
||||||
|
|
||||||
{CC1101_SYNC1, 0x46},
|
|
||||||
{CC1101_SYNC0, 0x4C},
|
|
||||||
{CC1101_ADDR, 0x00},
|
|
||||||
{CC1101_PKTLEN, 0x00},
|
|
||||||
|
|
||||||
{CC1101_MDMCFG4, 0xC8}, //Modem Configuration 9.99
|
|
||||||
{CC1101_MDMCFG3, 0x93}, //Modem Configuration
|
|
||||||
{CC1101_MDMCFG2, 0x12}, // 2: 16/16 sync word bits detected
|
|
||||||
|
|
||||||
{CC1101_DEVIATN, 0x34}, //Deviation = 19.042969
|
|
||||||
{CC1101_MCSM0, 0x18}, //Main Radio Control State Machine Configuration
|
|
||||||
{CC1101_FOCCFG, 0x16}, //Frequency Offset Compensation Configuration
|
|
||||||
|
|
||||||
{CC1101_AGCCTRL2, 0x43}, //AGC Control
|
|
||||||
{CC1101_AGCCTRL1, 0x40},
|
|
||||||
{CC1101_AGCCTRL0, 0x91},
|
|
||||||
|
|
||||||
{CC1101_WORCTRL, 0xFB}, //Wake On Radio Control
|
|
||||||
/* End */
|
|
||||||
{0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_ook_async_patable[8] = {
|
|
||||||
0x00,
|
|
||||||
0xC0, // 12dBm 0xC0, 10dBm 0xC5, 7dBm 0xCD, 5dBm 0x86, 0dBm 0x50, -6dBm 0x37, -10dBm 0x26, -15dBm 0x1D, -20dBm 0x17, -30dBm 0x03
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_2fsk_async_patable[8] = {
|
|
||||||
0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_msk_async_patable[8] = {
|
|
||||||
0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00};
|
|
||||||
|
|
||||||
static const uint8_t furi_hal_subghz_preset_gfsk_async_patable[8] = {
|
|
||||||
0xC0, // 10dBm 0xC0, 7dBm 0xC8, 5dBm 0x84, 0dBm 0x60, -10dBm 0x34, -15dBm 0x1D, -20dBm 0x0E, -30dBm 0x12
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00};
|
|
||||||
@@ -40,6 +40,7 @@ struct SubGhzProtocolEncoderRAW {
|
|||||||
|
|
||||||
bool is_running;
|
bool is_running;
|
||||||
FuriString* file_name;
|
FuriString* file_name;
|
||||||
|
FuriString* radio_device_name;
|
||||||
SubGhzFileEncoderWorker* file_worker_encoder;
|
SubGhzFileEncoderWorker* file_worker_encoder;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -282,6 +283,7 @@ void* subghz_protocol_encoder_raw_alloc(SubGhzEnvironment* environment) {
|
|||||||
|
|
||||||
instance->base.protocol = &subghz_protocol_raw;
|
instance->base.protocol = &subghz_protocol_raw;
|
||||||
instance->file_name = furi_string_alloc();
|
instance->file_name = furi_string_alloc();
|
||||||
|
instance->radio_device_name = furi_string_alloc();
|
||||||
instance->is_running = false;
|
instance->is_running = false;
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
@@ -300,6 +302,7 @@ void subghz_protocol_encoder_raw_free(void* context) {
|
|||||||
SubGhzProtocolEncoderRAW* instance = context;
|
SubGhzProtocolEncoderRAW* instance = context;
|
||||||
subghz_protocol_encoder_raw_stop(instance);
|
subghz_protocol_encoder_raw_stop(instance);
|
||||||
furi_string_free(instance->file_name);
|
furi_string_free(instance->file_name);
|
||||||
|
furi_string_free(instance->radio_device_name);
|
||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +321,9 @@ static bool subghz_protocol_encoder_raw_worker_init(SubGhzProtocolEncoderRAW* in
|
|||||||
|
|
||||||
instance->file_worker_encoder = subghz_file_encoder_worker_alloc();
|
instance->file_worker_encoder = subghz_file_encoder_worker_alloc();
|
||||||
if(subghz_file_encoder_worker_start(
|
if(subghz_file_encoder_worker_start(
|
||||||
instance->file_worker_encoder, furi_string_get_cstr(instance->file_name))) {
|
instance->file_worker_encoder,
|
||||||
|
furi_string_get_cstr(instance->file_name),
|
||||||
|
furi_string_get_cstr(instance->radio_device_name))) {
|
||||||
//the worker needs a file in order to open and read part of the file
|
//the worker needs a file in order to open and read part of the file
|
||||||
furi_delay_ms(100);
|
furi_delay_ms(100);
|
||||||
instance->is_running = true;
|
instance->is_running = true;
|
||||||
@@ -328,7 +333,10 @@ static bool subghz_protocol_encoder_raw_worker_init(SubGhzProtocolEncoderRAW* in
|
|||||||
return instance->is_running;
|
return instance->is_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_path) {
|
void subghz_protocol_raw_gen_fff_data(
|
||||||
|
FlipperFormat* flipper_format,
|
||||||
|
const char* file_path,
|
||||||
|
const char* radio_device_name) {
|
||||||
do {
|
do {
|
||||||
stream_clean(flipper_format_get_raw_stream(flipper_format));
|
stream_clean(flipper_format_get_raw_stream(flipper_format));
|
||||||
if(!flipper_format_write_string_cstr(flipper_format, "Protocol", "RAW")) {
|
if(!flipper_format_write_string_cstr(flipper_format, "Protocol", "RAW")) {
|
||||||
@@ -340,6 +348,12 @@ void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char*
|
|||||||
FURI_LOG_E(TAG, "Unable to add File_name");
|
FURI_LOG_E(TAG, "Unable to add File_name");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!flipper_format_write_string_cstr(
|
||||||
|
flipper_format, "Radio_device_name", radio_device_name)) {
|
||||||
|
FURI_LOG_E(TAG, "Unable to add Radio_device_name");
|
||||||
|
break;
|
||||||
|
}
|
||||||
} while(false);
|
} while(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +378,13 @@ SubGhzProtocolStatus
|
|||||||
}
|
}
|
||||||
furi_string_set(instance->file_name, temp_str);
|
furi_string_set(instance->file_name, temp_str);
|
||||||
|
|
||||||
|
if(!flipper_format_read_string(flipper_format, "Radio_device_name", temp_str)) {
|
||||||
|
FURI_LOG_E(TAG, "Missing Radio_device_name");
|
||||||
|
res = SubGhzProtocolStatusErrorParserOthers;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
furi_string_set(instance->radio_device_name, temp_str);
|
||||||
|
|
||||||
if(!subghz_protocol_encoder_raw_worker_init(instance)) {
|
if(!subghz_protocol_encoder_raw_worker_init(instance)) {
|
||||||
res = SubGhzProtocolStatusErrorEncoderGetUpload;
|
res = SubGhzProtocolStatusErrorEncoderGetUpload;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -126,8 +126,12 @@ void subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
|||||||
* File generation for RAW work.
|
* File generation for RAW work.
|
||||||
* @param flipper_format Pointer to a FlipperFormat instance
|
* @param flipper_format Pointer to a FlipperFormat instance
|
||||||
* @param file_path File path
|
* @param file_path File path
|
||||||
|
* @param radio_dev_name Radio device name
|
||||||
*/
|
*/
|
||||||
void subghz_protocol_raw_gen_fff_data(FlipperFormat* flipper_format, const char* file_path);
|
void subghz_protocol_raw_gen_fff_data(
|
||||||
|
FlipperFormat* flipper_format,
|
||||||
|
const char* file_path,
|
||||||
|
const char* radio_dev_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deserialize and generating an upload to send.
|
* Deserialize and generating an upload to send.
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <toolbox/stream/stream.h>
|
#include <toolbox/stream/stream.h>
|
||||||
#include <flipper_format/flipper_format.h>
|
#include <flipper_format/flipper_format.h>
|
||||||
#include <flipper_format/flipper_format_i.h>
|
#include <flipper_format/flipper_format_i.h>
|
||||||
|
#include <lib/subghz/devices/devices.h>
|
||||||
|
|
||||||
#define TAG "SubGhzFileEncoderWorker"
|
#define TAG "SubGhzFileEncoderWorker"
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ struct SubGhzFileEncoderWorker {
|
|||||||
bool is_storage_slow;
|
bool is_storage_slow;
|
||||||
FuriString* str_data;
|
FuriString* str_data;
|
||||||
FuriString* file_path;
|
FuriString* file_path;
|
||||||
|
const SubGhzDevice* device;
|
||||||
|
|
||||||
SubGhzFileEncoderWorkerCallbackEnd callback_end;
|
SubGhzFileEncoderWorkerCallbackEnd callback_end;
|
||||||
void* context_end;
|
void* context_end;
|
||||||
@@ -180,10 +182,13 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
|||||||
if(instance->is_storage_slow) {
|
if(instance->is_storage_slow) {
|
||||||
FURI_LOG_E(TAG, "Storage is slow");
|
FURI_LOG_E(TAG, "Storage is slow");
|
||||||
}
|
}
|
||||||
|
|
||||||
FURI_LOG_I(TAG, "End read file");
|
FURI_LOG_I(TAG, "End read file");
|
||||||
while(!furi_hal_subghz_is_async_tx_complete() && instance->worker_running) {
|
while(instance->device && !subghz_devices_is_async_complete_tx(instance->device) &&
|
||||||
|
instance->worker_running) {
|
||||||
furi_delay_ms(5);
|
furi_delay_ms(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
FURI_LOG_I(TAG, "End transmission");
|
FURI_LOG_I(TAG, "End transmission");
|
||||||
while(instance->worker_running) {
|
while(instance->worker_running) {
|
||||||
if(instance->worker_stopping) {
|
if(instance->worker_stopping) {
|
||||||
@@ -230,12 +235,16 @@ void subghz_file_encoder_worker_free(SubGhzFileEncoderWorker* instance) {
|
|||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_file_encoder_worker_start(SubGhzFileEncoderWorker* instance, const char* file_path) {
|
bool subghz_file_encoder_worker_start(
|
||||||
|
SubGhzFileEncoderWorker* instance,
|
||||||
|
const char* file_path,
|
||||||
|
const char* radio_device_name) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(!instance->worker_running);
|
furi_assert(!instance->worker_running);
|
||||||
|
|
||||||
furi_stream_buffer_reset(instance->stream);
|
furi_stream_buffer_reset(instance->stream);
|
||||||
furi_string_set(instance->file_path, file_path);
|
furi_string_set(instance->file_path, file_path);
|
||||||
|
instance->device = subghz_devices_get_by_name(radio_device_name);
|
||||||
instance->worker_running = true;
|
instance->worker_running = true;
|
||||||
furi_thread_start(instance->thread);
|
furi_thread_start(instance->thread);
|
||||||
|
|
||||||
|
|||||||
@@ -47,9 +47,14 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context);
|
|||||||
/**
|
/**
|
||||||
* Start SubGhzFileEncoderWorker.
|
* Start SubGhzFileEncoderWorker.
|
||||||
* @param instance Pointer to a SubGhzFileEncoderWorker instance
|
* @param instance Pointer to a SubGhzFileEncoderWorker instance
|
||||||
|
* @param file_path File path
|
||||||
|
* @param radio_device_name Radio device name
|
||||||
* @return bool - true if ok
|
* @return bool - true if ok
|
||||||
*/
|
*/
|
||||||
bool subghz_file_encoder_worker_start(SubGhzFileEncoderWorker* instance, const char* file_path);
|
bool subghz_file_encoder_worker_start(
|
||||||
|
SubGhzFileEncoderWorker* instance,
|
||||||
|
const char* file_path,
|
||||||
|
const char* radio_device_name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop SubGhzFileEncoderWorker
|
* Stop SubGhzFileEncoderWorker
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <furi.h>
|
#include <furi.h>
|
||||||
#include <m-list.h>
|
#include <m-list.h>
|
||||||
#include <furi_hal_subghz_configs.h>
|
#include <lib/subghz/devices/cc1101_configs.h>
|
||||||
|
|
||||||
#define TAG "SubGhzSetting"
|
#define TAG "SubGhzSetting"
|
||||||
|
|
||||||
@@ -195,23 +195,23 @@ static void subghz_setting_load_default_region(
|
|||||||
subghz_setting_load_default_preset(
|
subghz_setting_load_default_preset(
|
||||||
instance,
|
instance,
|
||||||
"AM270",
|
"AM270",
|
||||||
(uint8_t*)furi_hal_subghz_preset_ook_270khz_async_regs,
|
(uint8_t*)subghz_device_cc1101_preset_ook_270khz_async_regs,
|
||||||
furi_hal_subghz_preset_ook_async_patable);
|
subghz_device_cc1101_preset_ook_async_patable);
|
||||||
subghz_setting_load_default_preset(
|
subghz_setting_load_default_preset(
|
||||||
instance,
|
instance,
|
||||||
"AM650",
|
"AM650",
|
||||||
(uint8_t*)furi_hal_subghz_preset_ook_650khz_async_regs,
|
(uint8_t*)subghz_device_cc1101_preset_ook_650khz_async_regs,
|
||||||
furi_hal_subghz_preset_ook_async_patable);
|
subghz_device_cc1101_preset_ook_async_patable);
|
||||||
subghz_setting_load_default_preset(
|
subghz_setting_load_default_preset(
|
||||||
instance,
|
instance,
|
||||||
"FM238",
|
"FM238",
|
||||||
(uint8_t*)furi_hal_subghz_preset_2fsk_dev2_38khz_async_regs,
|
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev2_38khz_async_regs,
|
||||||
furi_hal_subghz_preset_2fsk_async_patable);
|
subghz_device_cc1101_preset_2fsk_async_patable);
|
||||||
subghz_setting_load_default_preset(
|
subghz_setting_load_default_preset(
|
||||||
instance,
|
instance,
|
||||||
"FM476",
|
"FM476",
|
||||||
(uint8_t*)furi_hal_subghz_preset_2fsk_dev47_6khz_async_regs,
|
(uint8_t*)subghz_device_cc1101_preset_2fsk_dev47_6khz_async_regs,
|
||||||
furi_hal_subghz_preset_2fsk_async_patable);
|
subghz_device_cc1101_preset_2fsk_async_patable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Region check removed
|
// Region check removed
|
||||||
@@ -270,6 +270,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
|||||||
}
|
}
|
||||||
while(flipper_format_read_uint32(
|
while(flipper_format_read_uint32(
|
||||||
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
|
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
|
||||||
|
//Todo: add a frequency support check depending on the selected radio device
|
||||||
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
|
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
|
||||||
FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
|
FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
|
||||||
FrequencyList_push_back(instance->frequencies, temp_data32);
|
FrequencyList_push_back(instance->frequencies, temp_data32);
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ struct SubGhzTxRxWorker {
|
|||||||
SubGhzTxRxWorkerStatus status;
|
SubGhzTxRxWorkerStatus status;
|
||||||
|
|
||||||
uint32_t frequency;
|
uint32_t frequency;
|
||||||
|
const SubGhzDevice* device;
|
||||||
|
const GpioPin* device_data_gpio;
|
||||||
|
|
||||||
SubGhzTxRxWorkerCallbackHaveRead callback_have_read;
|
SubGhzTxRxWorkerCallbackHaveRead callback_have_read;
|
||||||
void* context_have_read;
|
void* context_have_read;
|
||||||
@@ -65,33 +67,33 @@ bool subghz_tx_rx_worker_rx(SubGhzTxRxWorker* instance, uint8_t* data, uint8_t*
|
|||||||
uint8_t timeout = 100;
|
uint8_t timeout = 100;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if(instance->status != SubGhzTxRxWorkerStatusRx) {
|
if(instance->status != SubGhzTxRxWorkerStatusRx) {
|
||||||
furi_hal_subghz_rx();
|
subghz_devices_set_rx(instance->device);
|
||||||
instance->status = SubGhzTxRxWorkerStatusRx;
|
instance->status = SubGhzTxRxWorkerStatusRx;
|
||||||
furi_delay_tick(1);
|
furi_delay_tick(1);
|
||||||
}
|
}
|
||||||
//waiting for reception to complete
|
//waiting for reception to complete
|
||||||
while(furi_hal_gpio_read(furi_hal_subghz.cc1101_g0_pin)) {
|
while(furi_hal_gpio_read(instance->device_data_gpio)) {
|
||||||
furi_delay_tick(1);
|
furi_delay_tick(1);
|
||||||
if(!--timeout) {
|
if(!--timeout) {
|
||||||
FURI_LOG_W(TAG, "RX cc1101_g0 timeout");
|
FURI_LOG_W(TAG, "RX cc1101_g0 timeout");
|
||||||
furi_hal_subghz_flush_rx();
|
subghz_devices_flush_rx(instance->device);
|
||||||
furi_hal_subghz_rx();
|
subghz_devices_set_rx(instance->device);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(furi_hal_subghz_rx_pipe_not_empty()) {
|
if(subghz_devices_rx_pipe_not_empty(instance->device)) {
|
||||||
FURI_LOG_I(
|
FURI_LOG_I(
|
||||||
TAG,
|
TAG,
|
||||||
"RSSI: %03.1fdbm LQI: %d",
|
"RSSI: %03.1fdbm LQI: %d",
|
||||||
(double)furi_hal_subghz_get_rssi(),
|
(double)subghz_devices_get_rssi(instance->device),
|
||||||
furi_hal_subghz_get_lqi());
|
subghz_devices_get_lqi(instance->device));
|
||||||
if(furi_hal_subghz_is_rx_data_crc_valid()) {
|
if(subghz_devices_is_rx_data_crc_valid(instance->device)) {
|
||||||
furi_hal_subghz_read_packet(data, size);
|
subghz_devices_read_packet(instance->device, data, size);
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
furi_hal_subghz_flush_rx();
|
subghz_devices_flush_rx(instance->device);
|
||||||
furi_hal_subghz_rx();
|
subghz_devices_set_rx(instance->device);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -99,13 +101,13 @@ bool subghz_tx_rx_worker_rx(SubGhzTxRxWorker* instance, uint8_t* data, uint8_t*
|
|||||||
void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t size) {
|
void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t size) {
|
||||||
uint8_t timeout = 200;
|
uint8_t timeout = 200;
|
||||||
if(instance->status != SubGhzTxRxWorkerStatusIDLE) {
|
if(instance->status != SubGhzTxRxWorkerStatusIDLE) {
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->device);
|
||||||
}
|
}
|
||||||
furi_hal_subghz_write_packet(data, size);
|
subghz_devices_write_packet(instance->device, data, size);
|
||||||
furi_hal_subghz_tx(); //start send
|
subghz_devices_set_tx(instance->device); //start send
|
||||||
instance->status = SubGhzTxRxWorkerStatusTx;
|
instance->status = SubGhzTxRxWorkerStatusTx;
|
||||||
while(!furi_hal_gpio_read(
|
while(!furi_hal_gpio_read(
|
||||||
furi_hal_subghz.cc1101_g0_pin)) { // Wait for GDO0 to be set -> sync transmitted
|
instance->device_data_gpio)) { // Wait for GDO0 to be set -> sync transmitted
|
||||||
furi_delay_tick(1);
|
furi_delay_tick(1);
|
||||||
if(!--timeout) {
|
if(!--timeout) {
|
||||||
FURI_LOG_W(TAG, "TX !cc1101_g0 timeout");
|
FURI_LOG_W(TAG, "TX !cc1101_g0 timeout");
|
||||||
@@ -113,14 +115,14 @@ void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t si
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(furi_hal_gpio_read(
|
while(furi_hal_gpio_read(
|
||||||
furi_hal_subghz.cc1101_g0_pin)) { // Wait for GDO0 to be cleared -> end of packet
|
instance->device_data_gpio)) { // Wait for GDO0 to be cleared -> end of packet
|
||||||
furi_delay_tick(1);
|
furi_delay_tick(1);
|
||||||
if(!--timeout) {
|
if(!--timeout) {
|
||||||
FURI_LOG_W(TAG, "TX cc1101_g0 timeout");
|
FURI_LOG_W(TAG, "TX cc1101_g0 timeout");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
furi_hal_subghz_idle();
|
subghz_devices_idle(instance->device);
|
||||||
instance->status = SubGhzTxRxWorkerStatusIDLE;
|
instance->status = SubGhzTxRxWorkerStatusIDLE;
|
||||||
}
|
}
|
||||||
/** Worker thread
|
/** Worker thread
|
||||||
@@ -130,16 +132,19 @@ void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t si
|
|||||||
*/
|
*/
|
||||||
static int32_t subghz_tx_rx_worker_thread(void* context) {
|
static int32_t subghz_tx_rx_worker_thread(void* context) {
|
||||||
SubGhzTxRxWorker* instance = context;
|
SubGhzTxRxWorker* instance = context;
|
||||||
|
furi_assert(instance->device);
|
||||||
FURI_LOG_I(TAG, "Worker start");
|
FURI_LOG_I(TAG, "Worker start");
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
subghz_devices_begin(instance->device);
|
||||||
furi_hal_subghz_idle();
|
instance->device_data_gpio = subghz_devices_get_data_gpio(instance->device);
|
||||||
furi_hal_subghz_load_preset(FuriHalSubGhzPresetGFSK9_99KbAsync);
|
subghz_devices_reset(instance->device);
|
||||||
//furi_hal_subghz_load_preset(FuriHalSubGhzPresetMSK99_97KbAsync);
|
subghz_devices_idle(instance->device);
|
||||||
furi_hal_gpio_init(furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
subghz_devices_load_preset(instance->device, FuriHalSubGhzPresetGFSK9_99KbAsync, NULL);
|
||||||
|
|
||||||
furi_hal_subghz_set_frequency_and_path(instance->frequency);
|
furi_hal_gpio_init(instance->device_data_gpio, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
||||||
furi_hal_subghz_flush_rx();
|
|
||||||
|
subghz_devices_set_frequency(instance->device, instance->frequency);
|
||||||
|
subghz_devices_flush_rx(instance->device);
|
||||||
|
|
||||||
uint8_t data[SUBGHZ_TXRX_WORKER_MAX_TXRX_SIZE + 1] = {0};
|
uint8_t data[SUBGHZ_TXRX_WORKER_MAX_TXRX_SIZE + 1] = {0};
|
||||||
size_t size_tx = 0;
|
size_t size_tx = 0;
|
||||||
@@ -193,8 +198,8 @@ static int32_t subghz_tx_rx_worker_thread(void* context) {
|
|||||||
furi_delay_tick(1);
|
furi_delay_tick(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
subghz_devices_sleep(instance->device);
|
||||||
furi_hal_subghz_sleep();
|
subghz_devices_end(instance->device);
|
||||||
|
|
||||||
FURI_LOG_I(TAG, "Worker stop");
|
FURI_LOG_I(TAG, "Worker stop");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -226,7 +231,10 @@ void subghz_tx_rx_worker_free(SubGhzTxRxWorker* instance) {
|
|||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool subghz_tx_rx_worker_start(SubGhzTxRxWorker* instance, uint32_t frequency) {
|
bool subghz_tx_rx_worker_start(
|
||||||
|
SubGhzTxRxWorker* instance,
|
||||||
|
const SubGhzDevice* device,
|
||||||
|
uint32_t frequency) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
furi_assert(!instance->worker_running);
|
furi_assert(!instance->worker_running);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
@@ -237,6 +245,7 @@ bool subghz_tx_rx_worker_start(SubGhzTxRxWorker* instance, uint32_t frequency) {
|
|||||||
|
|
||||||
if(furi_hal_subghz_is_tx_allowed(frequency)) {
|
if(furi_hal_subghz_is_tx_allowed(frequency)) {
|
||||||
instance->frequency = frequency;
|
instance->frequency = frequency;
|
||||||
|
instance->device = device;
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
|
#include <devices/devices.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -67,9 +68,13 @@ void subghz_tx_rx_worker_free(SubGhzTxRxWorker* instance);
|
|||||||
/**
|
/**
|
||||||
* Start SubGhzTxRxWorker
|
* Start SubGhzTxRxWorker
|
||||||
* @param instance Pointer to a SubGhzTxRxWorker instance
|
* @param instance Pointer to a SubGhzTxRxWorker instance
|
||||||
|
* @param device Pointer to a SubGhzDevice instance
|
||||||
* @return bool - true if ok
|
* @return bool - true if ok
|
||||||
*/
|
*/
|
||||||
bool subghz_tx_rx_worker_start(SubGhzTxRxWorker* instance, uint32_t frequency);
|
bool subghz_tx_rx_worker_start(
|
||||||
|
SubGhzTxRxWorker* instance,
|
||||||
|
const SubGhzDevice* device,
|
||||||
|
uint32_t frequency);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop SubGhzTxRxWorker
|
* Stop SubGhzTxRxWorker
|
||||||
|
|||||||
Reference in New Issue
Block a user