Skip to content

Commit 8cfc85f

Browse files
committed
drivers: dtr_uart: Change RI from pulse to level
Previously RI lasted for 100ms or until DTR was activated, now RI lasts until DTR is activated. Signed-off-by: Markus Lassila <markus.lassila@nordicsemi.no>
1 parent e0cc2ac commit 8cfc85f

5 files changed

Lines changed: 49 additions & 45 deletions

File tree

doc/app/sm_configuration.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,4 @@ The following configuration files are provided:
323323
See the :ref:`SM_AT_FOTA` for more information.
324324

325325
The board-specific devicetree overlays (:file:`boards/*.overlay`) set up configurations that are specific to each supported development kit.
326-
All of them configure the DTR to be deasserted from a button and RI to blink an LED.
326+
All of them configure the DTR to be deasserted from a button and RI to drive an LED.

doc/images/cmux-wakeup-timing.svg

Lines changed: 27 additions & 22 deletions
Loading

doc/migration_notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The |SM| application uses DTR (Data Terminal Ready) and RI (Ring Indicator) pins
6666
* Added:
6767

6868
* DTR pin, which is a level-based input that is configured in the devicetree with the ``dtr-gpios`` property.
69-
* RI pin, which is a pulse-based output that is configured in the devicetree with the ``ri-gpios`` property.
69+
* RI pin, which is a level-based output that is configured in the devicetree with the ``ri-gpios`` property.
7070

7171
See :ref:`uart_configuration` for more information on how DTR and RI pins work in the |SM| application.
7272
See :ref:`sm_cellular_modem` for information on how to configure DTR and RI pins when using the |SM| application as a Zephyr modem.

doc/uart_configuration.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,19 @@ No other GPIO control is required to utilize the PSM or eDRX modes.
263263
Incoming data wake-up
264264
=====================
265265

266-
When the UART is powered down and there is incoming data, the |SM| application issues a pulse signal on the **RI** pin to notify the host.
266+
When the UART is powered down and there is incoming data, the |SM| application asserts the **RI** pin to notify the host.
267267
The RI signal is handled by the modem driver on the host, which powers up the UART device and asserts the DTR line, signaling the |SM| that the UART is powered on and ready to receive data.
268+
The RI signal remains asserted until the nRF91 UART is activated and ready to transmit data.
268269

269270
.. figure:: images/cmux-wakeup-timing.svg
270271
:alt: Modem waking up the host timing diagram
271272

272273
Sequence diagram showing the wake-up sequence when the UART is powered down
273274

274275
This sequence diagram illustrates the wake-up sequence when the UART is powered down.
275-
The RI signal pulse triggers the host to power up its UART and assert DTR, which in turn signals the modem that the UART interface is ready.
276+
The RI signal triggers the host to power up its UART and assert DTR.
277+
Once the host UART is ready and DTR is asserted, the nRF91 enables its UART interface.
278+
The RI signal remains active throughout this process and only returns to inactive once the nRF91 UART is active.
276279
This coordinated wake-up ensures both ends of the communication link are ready before data transmission begins.
277280

278281
Host-initiated wake-up

drivers/dtr_uart/dtr_uart.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct dtr_uart_data {
5050
struct k_work_delayable dtr_work;
5151

5252
/* --- RI (Ring Indicator) --- */
53-
struct k_work_delayable ri_work;
53+
bool ri_active; /* RI signal currently active */
5454

5555
/* --- Power Management --- */
5656
bool pm_suspended; /* 0 = UART && DTR active, 1 = UART && DTR inactive */
@@ -206,26 +206,24 @@ static void activate_rx(struct dtr_uart_data *data)
206206
user_callback(data->dev, &evt);
207207
}
208208

209-
/* --- RI handling --- */
210-
static void ri_work_fn(struct k_work *work)
209+
static void ri_start(struct dtr_uart_data *data)
211210
{
212-
const struct k_work_delayable *delayed_work =
213-
CONTAINER_OF(work, struct k_work_delayable, work);
214-
const struct dtr_uart_data *data =
215-
CONTAINER_OF(delayed_work, struct dtr_uart_data, ri_work);
216211
const struct dtr_uart_config *config = data->dev->config;
217212

218-
LOG_INF("RI: Stop");
219-
gpio_pin_set_dt(&config->ri_gpio, 0);
213+
LOG_INF("RI: Start");
214+
gpio_pin_set_dt(&config->ri_gpio, 1);
215+
data->ri_active = true;
220216
}
221217

222-
static void ri_start(struct dtr_uart_data *data)
218+
static void ri_stop(struct dtr_uart_data *data)
223219
{
224220
const struct dtr_uart_config *config = data->dev->config;
225221

226-
LOG_INF("RI: Start");
227-
gpio_pin_set_dt(&config->ri_gpio, 1);
228-
k_work_schedule(&data->ri_work, K_MSEC(100));
222+
if (data->ri_active) {
223+
LOG_INF("RI: Stop");
224+
gpio_pin_set_dt(&config->ri_gpio, 0);
225+
data->ri_active = false;
226+
}
229227
}
230228

231229
/* --- DTR handling --- */
@@ -256,14 +254,13 @@ static void dtr_work_handler(struct k_work *work)
256254
data->dtr_state = asserted;
257255

258256
if (asserted) {
259-
/* Stop RI signal. */
260-
k_work_cancel_delayable(&data->ri_work);
261-
gpio_pin_set_dt(&config->ri_gpio, 0);
262-
263257
/* Enable UART and RX/TX. */
264258
power_on_uart(data);
265259
activate_rx(data);
266260
activate_tx(data);
261+
262+
/* Stop RI signal. */
263+
ri_stop(data);
267264
} else {
268265
/* Disable TX. */
269266
deactivate_tx(data);
@@ -382,7 +379,7 @@ static int api_tx(const struct device *dev, const uint8_t *buf, size_t len, int3
382379
data->tx_buf = buf;
383380
data->tx_len = len;
384381

385-
/* Start RI pulse. */
382+
/* Start RI signal. */
386383
ri_start(data);
387384

388385
/* Buffer the data until DTR is down. */
@@ -580,7 +577,6 @@ static int dtr_uart_init(const struct device *dev)
580577
k_mutex_init(&data->dtr_mutex);
581578
k_sem_init(&data->rx_disable_sync, 0, 1);
582579
k_work_init_delayable(&data->dtr_work, dtr_work_handler);
583-
k_work_init_delayable(&data->ri_work, ri_work_fn);
584580

585581
/* Set UART callback. */
586582
err = uart_callback_set(config->uart, uart_callback, (void *)dev);

0 commit comments

Comments
 (0)