Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion drivers/potentiometer/ad514x/ad5141.c
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,41 @@ int ad5141_dpot_chn_read(struct dpot_dev *desc,
return 0;
}

/**
* @brief Enter/Exit the top scale or bottom scale .
* @param desc - digipot descriptor.
* @param chn - digipot channel.
* @param is_top_scale - boolean flag to indicate top scale or bottom scale.
* @param enable - Enter or exit the TS.
* @return 0 in case of success, negative error code otherwise.
*/
int ad5141_dpot_top_bottom_scale_enable(struct dpot_dev *desc,
enum dpot_chn_type chn,
bool is_top_scale,
uint8_t enable)
{
int ret;
struct dpot_command cmd;

if (!desc)
return -EINVAL;

ret = ad5141_validate_chn(desc->extra, chn);
if (ret)
return ret;

/* Enter/Exit the top scale or bottom scale (command #12 or command #13) */
cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT);
cmd.address = ad5141_dpot_cmd_addr[chn];
cmd.data = enable;
if (is_top_scale == true)
cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT);

cmd.is_readback = false;

return ad5141_dpot_send_cmd(desc, &cmd);
}

/**
* @brief Write to the digital potentiometer channel.
* @param desc - digipot descriptor.
Expand Down Expand Up @@ -923,6 +958,7 @@ const struct dpot_ops ad5141_dpot_ops = {
.dpot_copy_nvm_to_rdac = &ad5141_dpot_copy_nvm_to_rdac,
.dpot_rdac_linear_update = &ad5141_dpot_rdac_linear_update,
.dpot_rdac_6db_update = &ad5141_dpot_rdac_6db_update,
// .dpot_send_cmd = &ad5141_dpot_send_cmd,
.dpot_send_cmd = &ad5141_dpot_send_cmd,
.dpot_remove = &ad5141_dpot_remove,
.dpot_enable_top_bottom_scale = &ad5141_dpot_top_bottom_scale_enable
};
38 changes: 37 additions & 1 deletion drivers/potentiometer/ad514x/ad5142.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,41 @@ int ad5142_dpot_chn_read(struct dpot_dev *desc,
return 0;
}

/**
* @brief Enter/Exit the top scale or bottom scale .
* @param desc - digipot descriptor.
* @param chn - digipot channel.
* @param is_top_scale - boolean flag to indicate top scale or bottom scale.
* @param enable - Enter or exit the TS.
* @return 0 in case of success, negative error code otherwise.
*/
int ad5142_dpot_top_bottom_scale_enable(struct dpot_dev *desc,
enum dpot_chn_type chn,
bool is_top_scale,
uint8_t enable)
{
int ret;
struct dpot_command cmd;

if (!desc)
return -EINVAL;

ret = ad5142_validate_chn(desc->extra, chn);
if (ret)
return ret;

/* Enter/Exit the top scale or bottom scale (command #12 or command #13) */
cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT);
cmd.address = ad5142_dpot_cmd_addr[chn];
cmd.data = enable;
if (is_top_scale == true)
cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT);

cmd.is_readback = false;

return ad5142_dpot_send_cmd(desc, &cmd);
}

/**
* @brief Write to the digital potentiometer channel.
* @param desc - digipot descriptor.
Expand Down Expand Up @@ -875,6 +910,7 @@ const struct dpot_ops ad5142_dpot_ops = {
.dpot_copy_nvm_to_rdac = &ad5142_dpot_copy_nvm_to_rdac,
.dpot_rdac_linear_update = &ad5142_dpot_rdac_linear_update,
.dpot_rdac_6db_update = &ad5142_dpot_rdac_6db_update,
//.dpot_send_cmd = &ad5142_dpot_send_cmd,
.dpot_send_cmd = &ad5142_dpot_send_cmd,
.dpot_remove = &ad5142_dpot_remove,
.dpot_enable_top_bottom_scale = &ad5142_dpot_top_bottom_scale_enable
};
36 changes: 36 additions & 0 deletions drivers/potentiometer/ad514x/ad5143.c
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,41 @@ int ad5143_dpot_chn_read(struct dpot_dev *desc,
return 0;
}

/**
* @brief Enter/Exit the top scale or bottom scale .
* @param desc - digipot descriptor.
* @param chn - digipot channel.
* @param is_top_scale - boolean flag to indicate top scale or bottom scale.
* @param enable - Enter or exit the TS.
* @return 0 in case of success, negative error code otherwise.
*/
int ad5143_dpot_top_bottom_scale_enable(struct dpot_dev *desc,
enum dpot_chn_type chn,
bool is_top_scale,
uint8_t enable)
{
int ret;
struct dpot_command cmd;

if (!desc)
return -EINVAL;

ret = ad5143_validate_chn(desc->extra, chn);
if (ret)
return ret;

/* Enter/Exit the top scale or bottom scale (command #12 or command #13) */
cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT);
cmd.address = ad5143_dpot_cmd_addr[chn];
cmd.data = enable;
if (is_top_scale == true)
cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT);

cmd.is_readback = false;

return ad5143_dpot_send_cmd(desc, &cmd);
}

/**
* @brief Write to the digital potentiometer channel.
* @param desc - digipot descriptor.
Expand Down Expand Up @@ -726,4 +761,5 @@ const struct dpot_ops ad5143_dpot_ops = {
.dpot_rdac_6db_update = &ad5143_dpot_rdac_6db_update,
.dpot_send_cmd = &ad5143_dpot_send_cmd,
.dpot_remove = &ad5143_dpot_remove,
.dpot_enable_top_bottom_scale = &ad5143_dpot_top_bottom_scale_enable
};
30 changes: 13 additions & 17 deletions drivers/potentiometer/ad514x/ad5144.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,18 +615,19 @@ int ad5144_dpot_chn_read(struct dpot_dev *desc,

return 0;
}

/**
* @brief Enter/Exit the top scale or Bottom scale .
* @brief Enter/Exit the top scale or Bottom scale .
* @param desc - digipot descriptor.
* @param chn - digipot channel.
* @param IsTopScale - boolean flag to indicat top scale or bottom scale.
* @param nEnable - Enter or exit the TS.
* @param is_top_scale - boolean flag to indicate top scale or bottom scale.
* @param enable - Enter or exit the TS.
* @return 0 in case of success, negative error code otherwise.
*/
int ad5144_dpot_top_bottom_scale_enable(struct dpot_dev *desc,
enum dpot_chn_type chn,
bool IsTopScale,
uint8_t nEnable)
bool is_top_scale,
uint8_t enable)
{
int ret;
struct dpot_command cmd;
Expand All @@ -638,21 +639,16 @@ int ad5144_dpot_top_bottom_scale_enable(struct dpot_dev *desc,
if (ret)
return ret;

/* Write contents of serial register data to RDAC (command #1) */
cmd.control = 0x9;
/* Enter/Exit the top scale or Bottom scale (command #12 or command #13) */
cmd.control = EXTRACT_CMD_BITS(AD51XX_CMD_TOP_SCALE_EXIT);
cmd.address = ad5144_dpot_cmd_addr[chn];
cmd.data = nEnable;
if (IsTopScale == true) {
cmd.data |= 0x80;
}
cmd.data = enable;
if (is_top_scale == true)
cmd.data |= EXTRACT_DATA_BITS(AD51XX_CMD_TOP_SCALE_EXIT);

cmd.is_readback = false;

ret = ad5144_dpot_send_cmd(desc, &cmd);
if (ret)
return ret;

return 0;
return ad5144_dpot_send_cmd(desc, &cmd);
}

/**
Expand Down Expand Up @@ -972,7 +968,7 @@ const struct dpot_ops ad5144_dpot_ops = {
.dpot_copy_nvm_to_rdac = &ad5144_dpot_copy_nvm_to_rdac,
.dpot_rdac_linear_update = &ad5144_dpot_rdac_linear_update,
.dpot_rdac_6db_update = &ad5144_dpot_rdac_6db_update,
//.dpot_send_cmd = &ad5144_dpot_send_cmd,
.dpot_send_cmd = &ad5144_dpot_send_cmd,
.dpot_remove = &ad5144_dpot_remove,
.dpot_enable_top_bottom_scale = &ad5144_dpot_top_bottom_scale_enable
};
Loading