fix: PXX1 external module timings (#3941)

This commit is contained in:
3djc
2023-09-01 08:27:48 +02:00
committed by GitHub
parent 06712d9b97
commit 1f44053705
3 changed files with 12 additions and 2 deletions
@@ -520,6 +520,10 @@ const etx_module_t _sport_module = {
#endif // SPORT_UPDATE_PWR_GPIO
#if !defined(RADIO_X10E)
uint32_t __pxx1_get_inverter_comp() { return 1; }
#endif
void boardInitModulePorts()
{
_sport_direction_init();
@@ -313,6 +313,8 @@ static void _conv_byte_8n1(stm32_softserial_tx_state* st, uint8_t b)
#define PXX1_BIT_ZERO 16 /* 0 = 16us */
#define PXX1_BIT_ONE 24 /* 1 = 24us */
__attribute__ ((weak)) uint32_t __pxx1_get_inverter_comp() { return 0; }
static void _conv_byte_pxx1(stm32_softserial_tx_state* st, uint8_t b)
{
uint32_t bits = st->serial_size < 8 ? st->serial_size : 8;
@@ -360,7 +362,7 @@ static void* stm32_softserial_tx_init(void* hw_def, const etx_serial_init* param
freq = PXX1_FREQ;
polarity = false;
ocmode = LL_TIM_OCMODE_FORCED_INACTIVE;
cmp_val = PXX1_PWM_ON;
cmp_val = PXX1_PWM_ON + __pxx1_get_inverter_comp();
break;
default:
@@ -483,7 +485,7 @@ static void stm32_softserial_tx_send_buffer(void* ctx, const uint8_t* data, uint
// dirty hack...
if (st->conv_byte == _conv_byte_pxx1) {
ocmode = LL_TIM_OCMODE_PWM1;
cmp_val = PXX1_PWM_ON;
cmp_val = PXX1_PWM_ON + __pxx1_get_inverter_comp();
}
stm32_pulse_start_dma_req(timer, pulses, length, ocmode, cmp_val);
@@ -105,3 +105,7 @@ struct stm32_softserial_tx_port {
#define REF_STM32_SOFTSERIAL_PORT(p) ((void*)& p ## _STM32Softserial)
extern const etx_serial_driver_t STM32SoftSerialTxDriver;
// This is defined as a weak symbol to allow stretching the prelude part
// of PXX1 pulses to an acceptable length
uint32_t __pxx1_get_inverter_comp();