Skip to content

Commit 4dc71b5

Browse files
committed
modbus: serial: use gpio_pin_set_dt() for de/re pin control
Just simplifies the code by using the `gpio_dt_spec` directly instead. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent 727c15a commit 4dc71b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/modbus/modbus_serial.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void modbus_serial_tx_on(struct modbus_context *ctx)
3434
struct modbus_serial_config *cfg = ctx->cfg;
3535

3636
if (cfg->de != NULL) {
37-
gpio_pin_set(cfg->de->port, cfg->de->pin, 1);
37+
gpio_pin_set_dt(cfg->de, 1);
3838
}
3939

4040
if (IS_ENABLED(CONFIG_MODBUS_SERIAL_ASYNC_API)) {
@@ -58,7 +58,7 @@ static void modbus_serial_tx_off(struct modbus_context *ctx)
5858
}
5959

6060
if (cfg->de != NULL) {
61-
gpio_pin_set(cfg->de->port, cfg->de->pin, 0);
61+
gpio_pin_set_dt(cfg->de, 0);
6262
}
6363
}
6464

@@ -78,7 +78,7 @@ static void modbus_serial_rx_on(struct modbus_context *ctx)
7878
struct modbus_serial_config *cfg = ctx->cfg;
7979

8080
if (cfg->re != NULL) {
81-
gpio_pin_set(cfg->re->port, cfg->re->pin, 1);
81+
gpio_pin_set_dt(cfg->re, 1);
8282
}
8383

8484
atomic_set_bit(&ctx->state, MODBUS_STATE_RX_ENABLED);
@@ -108,7 +108,7 @@ static void modbus_serial_rx_off(struct modbus_context *ctx)
108108
atomic_clear_bit(&ctx->state, MODBUS_STATE_RX_ENABLED);
109109

110110
if (cfg->re != NULL) {
111-
gpio_pin_set(cfg->re->port, cfg->re->pin, 0);
111+
gpio_pin_set_dt(cfg->re, 0);
112112
}
113113
}
114114

0 commit comments

Comments
 (0)