fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35020?usp=email )
Change subject: soft_uart: split osmo_soft_uart_enable() ...................................................................... soft_uart: split osmo_soft_uart_enable() The problem with a single function controlling both Rx and Tx is that enabling/disabling one of the directions requires knowing state of the other one. In other words, disabling Tx requires knowing the state of Rx, which may be inconvenient. Change-Id: Ieacc7e639304eeb14fdb298c7e14d772c136ca6e Related: OS#4396 --- M include/osmocom/core/soft_uart.h M src/core/libosmocore.map M src/core/soft_uart.c 3 files changed, 35 insertions(+), 10 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/20/35020/1 diff --git a/include/osmocom/core/soft_uart.h b/include/osmocom/core/soft_uart.h index 4f9c1fc..71846ed 100644 --- a/include/osmocom/core/soft_uart.h +++ b/include/osmocom/core/soft_uart.h @@ -77,7 +77,8 @@ struct osmo_soft_uart *osmo_soft_uart_alloc(void *ctx, const char *name); void osmo_soft_uart_free(struct osmo_soft_uart *suart); int osmo_soft_uart_configure(struct osmo_soft_uart *suart, const struct osmo_soft_uart_cfg *cfg); -int osmo_soft_uart_enable(struct osmo_soft_uart *suart, bool rx, bool tx); +int osmo_soft_uart_set_rx(struct osmo_soft_uart *suart, bool enable); +int osmo_soft_uart_set_tx(struct osmo_soft_uart *suart, bool enable); int osmo_soft_uart_rx_ubits(struct osmo_soft_uart *suart, const ubit_t *ubits, size_t n_ubits); int osmo_soft_uart_tx_ubits(struct osmo_soft_uart *suart, ubit_t *ubits, size_t n_ubits); diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map index 142e4c4..e2aef39 100644 --- a/src/core/libosmocore.map +++ b/src/core/libosmocore.map @@ -442,7 +442,8 @@ osmo_soft_uart_alloc; osmo_soft_uart_free; osmo_soft_uart_configure; -osmo_soft_uart_enable; +osmo_soft_uart_set_rx; +osmo_soft_uart_set_tx; osmo_soft_uart_rx_ubits; osmo_soft_uart_tx_ubits; osmo_soft_uart_tx; diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c index a668b21..fcc90b2 100644 --- a/src/core/soft_uart.c +++ b/src/core/soft_uart.c @@ -283,26 +283,34 @@ return 0; } -/*! Enable/disable receiver and/or transmitter of the given soft-UART. +/*! Enable/disable receiver of the given soft-UART. * \param[in] suart soft-UART instance to be re-configured. - * \param[in] rx enable/disable state of the receiver. - * \param[in] tx enable/disable state of the transmitter. + * \param[in] enable enable/disable state of the receiver. * \returns 0 on success; negative on error. */ -int osmo_soft_uart_enable(struct osmo_soft_uart *suart, bool rx, bool tx) +int osmo_soft_uart_set_rx(struct osmo_soft_uart *suart, bool enable) { - if (!rx && suart->rx.running) { + if (!enable && suart->rx.running) { suart_flush_rx(suart); suart->rx.running = false; - } else if (rx && !suart->rx.running) { + } else if (enable && !suart->rx.running) { if (!suart->rx.msg) suart->rx.msg = msgb_alloc_c(suart, suart->cfg.rx_buf_size, "soft_uart rx"); suart->rx.running = true; } - if (!tx && suart->tx.running) { + return 0; +} + +/*! Enable/disable transmitter of the given soft-UART. + * \param[in] suart soft-UART instance to be re-configured. + * \param[in] enable enable/disable state of the transmitter. + * \returns 0 on success; negative on error. */ +int osmo_soft_uart_set_tx(struct osmo_soft_uart *suart, bool enable) +{ + if (!enable && suart->tx.running) { /* FIXME: Tx */ suart->tx.running = false; - } else if (tx && !suart->tx.running) { + } else if (enable && !suart->tx.running) { suart->tx.running = true; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35020?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: Ieacc7e639304eeb14fdb298c7e14d772c136ca6e Gerrit-Change-Number: 35020 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanits...@sysmocom.de> Gerrit-MessageType: newchange