mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
PWM6+7/TIM3_CH3+4/PB0+PB1 Update software serial to monitor serial pins for signal changes instead of periodically sampling pin signals. When reading the data the timer used is syncronized to the falling edge of the start bit which allows for better syncronisation at higher speeds. The code has been tested OK from 1200 baud to 19200. 38400 baud was tested and partially usable but has been disabled because there are too many transmit and receive errors, especially when transmitting and receiving at the same time. Due to the way a single timer is used for transmitting and receiving, if data comes in while transmitting the system may incorrectly transmit a short or long bit. However at 19200 and below this didn't cause a problem in the limited testing I performed.
22 lines
856 B
C
22 lines
856 B
C
#pragma once
|
|
|
|
typedef void timerCCCallbackPtr(uint8_t port, uint16_t capture);
|
|
|
|
typedef struct {
|
|
TIM_TypeDef *tim;
|
|
GPIO_TypeDef *gpio;
|
|
uint32_t pin;
|
|
uint8_t channel;
|
|
uint8_t irq;
|
|
uint8_t outputEnable;
|
|
} timerHardware_t;
|
|
|
|
extern const timerHardware_t timerHardware[];
|
|
|
|
void configTimeBase(TIM_TypeDef *tim, uint16_t period, uint8_t mhz);
|
|
void timerConfigure(const timerHardware_t *timerHardwarePtr, uint16_t period, uint8_t mhz);
|
|
void timerNVICConfigure(uint8_t irq);
|
|
|
|
void configureTimerInputCaptureCompareChannel(TIM_TypeDef *tim, const uint8_t channel);
|
|
void configureTimerCaptureCompareInterrupt(const timerHardware_t *timerHardwarePtr, uint8_t reference, timerCCCallbackPtr *callback);
|
|
void configureTimerChannelCallback(TIM_TypeDef *tim, uint8_t channel, uint8_t reference, timerCCCallbackPtr *callback);
|