SubGhz: change CC1101_ext TIM17 resolution to 2µs (#2909)

* SubGhz: change the operation of the TIM17 timer in CC1101_ext to 2µs
* SubGhz: remove special characters

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Skorpionm 2023-08-02 08:45:39 +04:00 committed by GitHub
parent 313e9c3d89
commit 9fd9dd85e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,7 +37,7 @@
#define SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL (256)
#define SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_HALF \
(SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_BUFFER_FULL / 2)
#define SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_GUARD_TIME 999
#define SUBGHZ_DEVICE_CC1101_EXT_ASYNC_TX_GUARD_TIME 999 << 1
/** SubGhz state */
typedef enum {
@ -483,7 +483,7 @@ static void subghz_device_cc1101_ext_capture_ISR() {
subghz_device_cc1101_ext->async_rx.capture_callback(
true,
LL_TIM_GetCounter(TIM17),
LL_TIM_GetCounter(TIM17) << 1,
(void*)subghz_device_cc1101_ext->async_rx.capture_callback_context);
}
} else {
@ -493,11 +493,11 @@ static void subghz_device_cc1101_ext_capture_ISR() {
subghz_device_cc1101_ext->async_rx.capture_callback(
false,
LL_TIM_GetCounter(TIM17),
LL_TIM_GetCounter(TIM17) << 1,
(void*)subghz_device_cc1101_ext->async_rx.capture_callback_context);
}
}
LL_TIM_SetCounter(TIM17, 6);
LL_TIM_SetCounter(TIM17, 4); //8>>1
}
void subghz_device_cc1101_ext_start_async_rx(
@ -512,7 +512,8 @@ void subghz_device_cc1101_ext_start_async_rx(
furi_hal_bus_enable(FuriHalBusTIM17);
// Configure TIM
LL_TIM_SetPrescaler(TIM17, 64 - 1);
//Set the timer resolution to 2 us
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetAutoReload(TIM17, 0xFFFF);
LL_TIM_SetClockDivision(TIM17, LL_TIM_CLOCKDIVISION_DIV1);
@ -606,7 +607,7 @@ static void subghz_device_cc1101_ext_async_tx_refill(uint32_t* buffer, size_t sa
uint32_t duration = level_duration_get_duration(ld);
furi_assert(duration > 0);
*buffer = duration - 1;
*buffer = duration >> 1;
buffer++;
samples--;
}
@ -692,7 +693,8 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb
furi_hal_bus_enable(FuriHalBusTIM17);
// Configure TIM
LL_TIM_SetPrescaler(TIM17, 64 - 1);
// Set the timer resolution to 2 us
LL_TIM_SetPrescaler(TIM17, (64 << 1) - 1);
LL_TIM_SetCounterMode(TIM17, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetAutoReload(TIM17, 0xFFFF);
LL_TIM_SetClockDivision(TIM17, LL_TIM_CLOCKDIVISION_DIV1);