mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
work to home
This commit is contained in:
@@ -98,6 +98,8 @@ typedef struct {
|
||||
|
||||
static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL;
|
||||
|
||||
bool subghz_device_cc1101_ext_is_async_tx_complete(void);
|
||||
|
||||
static bool subghz_device_cc1101_ext_check_init(void) {
|
||||
furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit);
|
||||
subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle;
|
||||
@@ -794,15 +796,20 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
subghz_device_cc1101_ext->async_tx.buffer =
|
||||
malloc(SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL * sizeof(uint32_t));
|
||||
|
||||
// here we do the same things as in /unleashed-firmware/targets/f7/furi_hal/furi_hal_subghz.c
|
||||
// use first DMA to update timer TIM17 durations, but TIM17 have not output chanel
|
||||
// so we use second DMA to transfer data from gpio_tx_buff directly to gpio pin using BSSR.
|
||||
// BSSR allow us tranfer data directly to pin in gpio port.
|
||||
|
||||
//Signal generation with mem-to-mem DMA
|
||||
furi_hal_gpio_write(subghz_device_cc1101_ext->g0_pin, false);
|
||||
furi_hal_gpio_init(
|
||||
subghz_device_cc1101_ext->g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
|
||||
|
||||
// Configure DMA update timer
|
||||
// Configure DMA to update timer TIM17 ARR by durations from buffer
|
||||
LL_DMA_SetMemoryAddress(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)subghz_device_cc1101_ext->async_tx.buffer);
|
||||
LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t) & (TIM17->ARR));
|
||||
LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF, (uint32_t)&(TIM17->ARR));
|
||||
LL_DMA_ConfigTransfer(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH3_DEF,
|
||||
LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT |
|
||||
@@ -821,7 +828,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
|
||||
furi_hal_bus_enable(FuriHalBusTIM17);
|
||||
|
||||
// Configure TIM
|
||||
// Configure TIM 17
|
||||
// Set the timer resolution to 2 us
|
||||
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
|
||||
LL_TIM_SetClockDivision(TIM17, LL_TIM_CLOCKDIVISION_DIV1);
|
||||
@@ -835,7 +842,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
subghz_device_cc1101_ext_async_tx_refill(
|
||||
subghz_device_cc1101_ext->async_tx.buffer, SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL);
|
||||
|
||||
// Configure tx gpio dma
|
||||
// Configure DMA to transfer data from gpio_tx_buff directly to gpio pin using BSSR
|
||||
const GpioPin* gpio = subghz_device_cc1101_ext->g0_pin;
|
||||
|
||||
subghz_device_cc1101_ext->async_tx.gpio_tx_buff[0] = (uint32_t)gpio->pin << GPIO_NUMBER;
|
||||
@@ -844,7 +851,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
LL_DMA_SetMemoryAddress(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF,
|
||||
(uint32_t)subghz_device_cc1101_ext->async_tx.gpio_tx_buff);
|
||||
LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t) & (gpio->port->BSRR));
|
||||
LL_DMA_SetPeriphAddress(SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF, (uint32_t)&(gpio->port->BSRR));
|
||||
LL_DMA_ConfigTransfer(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH4_DEF,
|
||||
LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT |
|
||||
@@ -864,7 +871,7 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF,
|
||||
(uint32_t)subghz_device_cc1101_ext->async_tx.debug_gpio_buff);
|
||||
LL_DMA_SetPeriphAddress(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t) & (gpio->port->BSRR));
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF, (uint32_t)&(gpio->port->BSRR));
|
||||
LL_DMA_ConfigTransfer(
|
||||
SUBGHZ_DEVICE_CC1101_EXT_DMA_CH5_DEF,
|
||||
LL_DMA_DIRECTION_MEMORY_TO_PERIPH | LL_DMA_MODE_CIRCULAR | LL_DMA_PERIPH_NOINCREMENT |
|
||||
|
||||
@@ -234,7 +234,6 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat*
|
||||
|
||||
SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers;
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
uint32_t repeat = 200;
|
||||
do {
|
||||
if(!flipper_format_rewind(flipper_format)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
@@ -244,10 +243,6 @@ SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat*
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) {
|
||||
FURI_LOG_E(TAG, "Unable Repeat");
|
||||
break;
|
||||
}
|
||||
ret = SubGhzTxRxStartTxStateOk;
|
||||
|
||||
SubGhzRadioPreset* preset = instance->preset;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
#include <lib/subghz/blocks/custom_btn.h>
|
||||
|
||||
#include <lib/subghz/devices/devices.c>
|
||||
#define TAG "SubGhzSceneTransmitter"
|
||||
|
||||
void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
|
||||
@@ -72,25 +72,56 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
subghz_scene_transmitter_update_data_show(subghz);
|
||||
dolphin_deed(DolphinDeedSubGhzSend);
|
||||
|
||||
// #subghz_one_press_send# - keyword to search changes
|
||||
// #start insert#
|
||||
|
||||
// TODO change while condition to subghz_devices_is_async_complete_tx(subghz->txrx->radio_device);
|
||||
// while(
|
||||
// !(furi_hal_subghz_is_async_tx_complete() &&
|
||||
// subghz_device_cc1101_ext_is_async_tx_complete())) {
|
||||
// notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
// }
|
||||
|
||||
while(!furi_hal_subghz_is_async_tx_complete()) {
|
||||
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
}
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
|
||||
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||
int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||
furi_hal_subghz_set_rolling_counter_mult(0);
|
||||
// Calling restore!
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
// Calling restore 2nd time special for FAAC SLH!
|
||||
// TODO: Find better way to restore after custom button is used!!!
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
||||
}
|
||||
// #end insert#
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
|
||||
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||
int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||
furi_hal_subghz_set_rolling_counter_mult(0);
|
||||
// Calling restore!
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
// Calling restore 2nd time special for FAAC SLH!
|
||||
// TODO: Find better way to restore after custom button is used!!!
|
||||
subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
||||
}
|
||||
return true;
|
||||
// #subghz_one_press_send# - keyword to search changes
|
||||
// } else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
||||
// subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
// subghz_txrx_stop(subghz->txrx);
|
||||
// if(subghz_custom_btn_get() != SUBGHZ_CUSTOM_BTN_OK) {
|
||||
// subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||
// int32_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult();
|
||||
// furi_hal_subghz_set_rolling_counter_mult(0);
|
||||
// // Calling restore!
|
||||
// subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
// subghz_txrx_stop(subghz->txrx);
|
||||
// // Calling restore 2nd time special for FAAC SLH!
|
||||
// // TODO: Find better way to restore after custom button is used!!!
|
||||
// subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
// subghz_txrx_stop(subghz->txrx);
|
||||
// furi_hal_subghz_set_rolling_counter_mult(tmp_counter);
|
||||
// }
|
||||
// return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#include <lib/subghz/blocks/custom_btn.h>
|
||||
|
||||
#include <applications/drivers/subghz/cc1101_ext/cc1101_ext.h>
|
||||
#include <targets/f7/furi_hal/furi_hal_subghz.h>
|
||||
|
||||
struct SubGhzViewTransmitter {
|
||||
View* view;
|
||||
SubGhzViewTransmitterCallback callback;
|
||||
@@ -155,7 +158,10 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
||||
true);
|
||||
|
||||
if(can_be_sent) {
|
||||
if(event->key == InputKeyOk && event->type == InputTypePress) {
|
||||
// #subghz_one_press_send# - keyword to search changes
|
||||
bool allow_events = furi_hal_subghz_is_async_tx_complete() && subghz_device_cc1101_ext_is_async_tx_complete ();
|
||||
// #
|
||||
if(event->key == InputKeyOk && event->type == InputTypePress && allow_events) {
|
||||
subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK);
|
||||
with_view_model(
|
||||
subghz_transmitter->view,
|
||||
@@ -168,10 +174,11 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
|
||||
return true;
|
||||
} else if(event->key == InputKeyOk && event->type == InputTypeRelease) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
return true;
|
||||
// #subghz_one_press_send# - keyword to search changes
|
||||
// } else if(event->key == InputKeyOk && event->type == InputTypeRelease) {
|
||||
// subghz_transmitter->callback(
|
||||
// SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
// return true;
|
||||
} // Finish "OK" key processing
|
||||
|
||||
if(subghz_custom_btn_is_allowed()) {
|
||||
@@ -189,7 +196,7 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(event->type == InputTypePress) {
|
||||
if(event->type == InputTypePress && allow_events) {
|
||||
with_view_model(
|
||||
subghz_transmitter->view,
|
||||
SubGhzViewTransmitterModel * model,
|
||||
@@ -209,10 +216,11 @@ bool subghz_view_transmitter_input(InputEvent* event, void* context) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStart, subghz_transmitter->context);
|
||||
return true;
|
||||
} else if(event->type == InputTypeRelease) {
|
||||
subghz_transmitter->callback(
|
||||
SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
return true;
|
||||
// #subghz_one_press_send# - keyword to search changes
|
||||
// } else if(event->type == InputTypeRelease) {
|
||||
// subghz_transmitter->callback(
|
||||
// SubGhzCustomEventViewTransmitterSendStop, subghz_transmitter->context);
|
||||
// return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user