From 21c19b78242e4ac08c2df8f11926fe260cf12bad Mon Sep 17 00:00:00 2001 From: Lars Kruse Date: Wed, 21 Jan 2026 12:16:15 +0100 Subject: [PATCH] drivers/analog/mcp47x6: fix configuration command Previously the ioctl-based configuration was not encoded properly. It lacked the three command bits selecting the "set volatile configuration" mode. Thus, configuration the reference, power-down or gain resulted in no change. Now the configuration is properly applied. The DAC value to be send is now combined with the proper command prefix bits, too. But this operation was already working, since the command prefix is zero. Signed-off-by: Lars Kruse --- drivers/analog/mcp47x6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/analog/mcp47x6.c b/drivers/analog/mcp47x6.c index 3c9bbee54d2..1aad4da6273 100644 --- a/drivers/analog/mcp47x6.c +++ b/drivers/analog/mcp47x6.c @@ -305,7 +305,7 @@ static int mcp47x6_send(FAR struct dac_dev_s *dev, FAR struct dac_msg_s *msg) uint32_t data; data = msg->am_data & MCP47X6_DATA_MASK; data <<= MCP47X6_DATA_SHIFT; - buffer[0] = (uint8_t)(data >> 8); + buffer[0] = (uint8_t)(data >> 8) | MCP47X6_COMMAND_WRITE_DAC; buffer[1] = (uint8_t)(data); ret = mcp47x6_i2c_write(priv, buffer, sizeof(buffer)); @@ -396,7 +396,8 @@ static int mcp47x6_ioctl(FAR struct dac_dev_s *dev, int cmd, if (command_prepared) { - ret = mcp47x6_i2c_write(priv, &priv->cmd, sizeof(priv->cmd)); + uint8_t raw_cmd = MCP47X6_COMMAND_WRITE_CONFIG | priv->cmd; + ret = mcp47x6_i2c_write(priv, &raw_cmd, sizeof(raw_cmd)); } return ret;