drivers/soft_uart: implement inverted TX & RX
In the current implementation, RX is flank based, so it's entirely level agnostic. I still chose to include a SOFT_UART_FLAG_INVERT_RX flag for symmetry and to allow for a possible future, sampling based implementation.
This commit is contained in:
parent
5d1dddb3fc
commit
b080d3da7a
@ -37,6 +37,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief invert the level of the TX signal
|
||||||
|
*/
|
||||||
|
#define SOFT_UART_FLAG_INVERT_TX 0x1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief invert the level of the RX signal
|
||||||
|
*/
|
||||||
|
#define SOFT_UART_FLAG_INVERT_RX 0x2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Software UART port descriptor
|
* @brief Software UART port descriptor
|
||||||
*/
|
*/
|
||||||
@ -47,6 +57,7 @@ typedef struct {
|
|||||||
tim_t tx_timer; /**< Hardware timer used for TX */
|
tim_t tx_timer; /**< Hardware timer used for TX */
|
||||||
uint32_t timer_freq; /**< Operating frequency of the timer.
|
uint32_t timer_freq; /**< Operating frequency of the timer.
|
||||||
Should be a multiple of baudrate */
|
Should be a multiple of baudrate */
|
||||||
|
uint8_t flags; /**< Soft UART flags */
|
||||||
} soft_uart_conf_t;
|
} soft_uart_conf_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -41,13 +41,18 @@ extern "C" {
|
|||||||
#ifndef SOFT_UART_PARAM_FREQ
|
#ifndef SOFT_UART_PARAM_FREQ
|
||||||
#define SOFT_UART_PARAM_FREQ MHZ(1)
|
#define SOFT_UART_PARAM_FREQ MHZ(1)
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef SOFT_UART_PARAM_FLAGS
|
||||||
|
#define SOFT_UART_PARAM_FLAGS (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef SOFT_UART_PARAMS
|
#ifndef SOFT_UART_PARAMS
|
||||||
#define SOFT_UART_PARAMS { .rx_pin = SOFT_UART_PARAM_RX, \
|
#define SOFT_UART_PARAMS { .rx_pin = SOFT_UART_PARAM_RX, \
|
||||||
.tx_pin = SOFT_UART_PARAM_TX, \
|
.tx_pin = SOFT_UART_PARAM_TX, \
|
||||||
.rx_timer = SOFT_UART_PARAM_TIMER_RX, \
|
.rx_timer = SOFT_UART_PARAM_TIMER_RX, \
|
||||||
.tx_timer = SOFT_UART_PARAM_TIMER_TX, \
|
.tx_timer = SOFT_UART_PARAM_TIMER_TX, \
|
||||||
.timer_freq = SOFT_UART_PARAM_FREQ }
|
.timer_freq = SOFT_UART_PARAM_FREQ, \
|
||||||
|
.flags = SOFT_UART_PARAM_FLAGS, \
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user