Formatting & New updated IR

This commit is contained in:
VerstreuteSeele
2023-01-14 08:44:32 +01:00
parent 7385a28ddd
commit 905bb23fdf
216 changed files with 6455 additions and 5877 deletions

View File

@@ -9,8 +9,8 @@
#include <furi_hal_spi.h>
#include <furi_hal_interrupt.h>
void raw_sampling_worker_start(ProtoViewApp *app);
void raw_sampling_worker_stop(ProtoViewApp *app);
void raw_sampling_worker_start(ProtoViewApp* app);
void raw_sampling_worker_stop(ProtoViewApp* app);
ProtoViewModulation ProtoViewModulations[] = {
{"OOK 650Khz", FuriHalSubGhzPresetOok650Async, NULL},
@@ -37,7 +37,7 @@ void radio_begin(ProtoViewApp* app) {
/* The CC1101 preset can be either one of the standard presets, if
* the modulation "custom" field is NULL, or a custom preset we
* defined in custom_presets.h. */
if (ProtoViewModulations[app->modulation].custom == NULL)
if(ProtoViewModulations[app->modulation].custom == NULL)
furi_hal_subghz_load_preset(ProtoViewModulations[app->modulation].preset);
else
furi_hal_subghz_load_custom_preset(ProtoViewModulations[app->modulation].custom);
@@ -49,10 +49,10 @@ void radio_begin(ProtoViewApp* app) {
uint32_t radio_rx(ProtoViewApp* app) {
furi_assert(app);
if(!furi_hal_subghz_is_frequency_valid(app->frequency)) {
furi_crash(TAG" Incorrect RX frequency.");
furi_crash(TAG " Incorrect RX frequency.");
}
if (app->txrx->txrx_state == TxRxStateRx) return app->frequency;
if(app->txrx->txrx_state == TxRxStateRx) return app->frequency;
furi_hal_subghz_idle(); /* Put it into idle state in case it is sleeping. */
uint32_t value = furi_hal_subghz_set_frequency_and_path(app->frequency);
@@ -60,10 +60,8 @@ uint32_t radio_rx(ProtoViewApp* app) {
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
furi_hal_subghz_flush_rx();
furi_hal_subghz_rx();
if (!app->txrx->debug_timer_sampling) {
furi_hal_subghz_start_async_rx(subghz_worker_rx_callback,
app->txrx->worker);
if(!app->txrx->debug_timer_sampling) {
furi_hal_subghz_start_async_rx(subghz_worker_rx_callback, app->txrx->worker);
subghz_worker_start(app->txrx->worker);
} else {
raw_sampling_worker_start(app);
@@ -75,8 +73,8 @@ uint32_t radio_rx(ProtoViewApp* app) {
/* Stop subghz worker (if active), put radio on idle state. */
void radio_rx_end(ProtoViewApp* app) {
furi_assert(app);
if (app->txrx->txrx_state == TxRxStateRx) {
if (!app->txrx->debug_timer_sampling) {
if(app->txrx->txrx_state == TxRxStateRx) {
if(!app->txrx->debug_timer_sampling) {
if(subghz_worker_is_running(app->txrx->worker)) {
subghz_worker_stop(app->txrx->worker);
furi_hal_subghz_stop_async_rx();
@@ -92,7 +90,7 @@ void radio_rx_end(ProtoViewApp* app) {
/* Put radio on sleep. */
void radio_sleep(ProtoViewApp* app) {
furi_assert(app);
if (app->txrx->txrx_state == TxRxStateRx) {
if(app->txrx->txrx_state == TxRxStateRx) {
/* We can't go from having an active RX worker to sleeping.
* Stop the RX subsystems first. */
radio_rx_end(app);
@@ -108,15 +106,15 @@ void radio_sleep(ProtoViewApp* app) {
* Flipper system.
* ===========================================================================*/
void protoview_timer_isr(void *ctx) {
ProtoViewApp *app = ctx;
void protoview_timer_isr(void* ctx) {
ProtoViewApp* app = ctx;
bool level = furi_hal_gpio_read(&gpio_cc1101_g0);
if (app->txrx->last_g0_value != level) {
if(app->txrx->last_g0_value != level) {
uint32_t now = DWT->CYCCNT;
uint32_t dur = now - app->txrx->last_g0_change_time;
dur /= furi_hal_cortex_instructions_per_microsecond();
if (dur > 15000) dur = 15000;
if(dur > 15000) dur = 15000;
raw_samples_add(RawSamples, app->txrx->last_g0_value, dur);
app->txrx->last_g0_value = level;
app->txrx->last_g0_change_time = now;
@@ -124,13 +122,13 @@ void protoview_timer_isr(void *ctx) {
LL_TIM_ClearFlag_UPDATE(TIM2);
}
void raw_sampling_worker_start(ProtoViewApp *app) {
void raw_sampling_worker_start(ProtoViewApp* app) {
UNUSED(app);
LL_TIM_InitTypeDef tim_init = {
.Prescaler = 63, /* CPU frequency is ~64Mhz. */
.Prescaler = 63, /* CPU frequency is ~64Mhz. */
.CounterMode = LL_TIM_COUNTERMODE_UP,
.Autoreload = 5, /* Sample every 5 us */
.Autoreload = 5, /* Sample every 5 us */
};
LL_TIM_Init(TIM2, &tim_init);
@@ -143,7 +141,7 @@ void raw_sampling_worker_start(ProtoViewApp *app) {
FURI_LOG_E(TAG, "Timer enabled");
}
void raw_sampling_worker_stop(ProtoViewApp *app) {
void raw_sampling_worker_stop(ProtoViewApp* app) {
UNUSED(app);
FURI_CRITICAL_ENTER();
LL_TIM_DisableCounter(TIM2);