Fix polarity

This commit is contained in:
Raphael Coeffic
2022-03-20 16:30:59 +01:00
parent cee942a834
commit d2685aeadf
3 changed files with 5 additions and 7 deletions
+1 -1
View File
@@ -689,7 +689,7 @@ void extmoduleSendNextFrame()
extmoduleSendNextFrameSoftSerial100kbit(
extmodulePulsesData.dsm2.pulses,
extmodulePulsesData.dsm2.ptr - extmodulePulsesData.dsm2.pulses,
!GET_SBUS_POLARITY(EXTERNAL_MODULE));
GET_SBUS_POLARITY(EXTERNAL_MODULE));
break;
case PROTOCOL_CHANNELS_DSM2_LP45:
-3
View File
@@ -107,19 +107,16 @@ class SerialPxxBitTransport: public DataBuffer<uint8_t, 64> {
class PwmPxxBitTransport: public PulsesBuffer<pulse_duration_t, 200> {
protected:
uint16_t rest;
void initFrame(uint32_t period)
{
initBuffer();
rest = period * 2000; // 0.5uS (2Mhz)
}
void addPart(uint8_t value)
{
pulse_duration_t duration = value ? 47 : 31;
*ptr++ = duration;
rest -= duration + 1;
}
void addTail()
@@ -65,6 +65,7 @@ void extmodulePpmStart(uint16_t ppm_delay, bool polarity)
ocInit.OCMode = LL_TIM_OCMODE_PWM1;
ocInit.OCState = LL_TIM_OCSTATE_ENABLE;
ocInit.OCNState = LL_TIM_OCSTATE_ENABLE;
if (polarity) {
ocInit.OCPolarity = LL_TIM_OCPOLARITY_LOW;
@@ -105,7 +106,7 @@ void extmoduleSerialStart()
ocInit.OCMode = LL_TIM_OCMODE_TOGGLE;
ocInit.OCState = LL_TIM_OCSTATE_ENABLE;
ocInit.OCPolarity = LL_TIM_OCPOLARITY_LOW;
ocInit.OCPolarity = LL_TIM_OCPOLARITY_HIGH;
ocInit.CompareValue = 0;
stm32_pulse_config_output(&extmoduleTimer, &ocInit);
@@ -168,9 +169,9 @@ void extmoduleSendNextFrameSoftSerial100kbit(const void* pulses, uint16_t length
uint32_t ll_polarity;
if (polarity) {
ll_polarity = LL_TIM_OCPOLARITY_LOW;
} else {
ll_polarity = LL_TIM_OCPOLARITY_HIGH;
} else {
ll_polarity = LL_TIM_OCPOLARITY_LOW;
}
LL_TIM_OC_SetPolarity(EXTMODULE_TIMER, EXTMODULE_TIMER_Channel, ll_polarity);