drivers: sensor: qdec_mcux: update phase bit in register
Update single phase bit in register when changing data->qdec_config. Otherwise the changed settings has no effect. Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
This commit is contained in:
parent
8084ea55b7
commit
30a2326d0b
1 changed files with 3 additions and 0 deletions
|
@ -42,6 +42,7 @@ static enc_decoder_work_mode_t int_to_work_mode(int32_t val)
|
||||||
static int qdec_mcux_attr_set(const struct device *dev, enum sensor_channel ch,
|
static int qdec_mcux_attr_set(const struct device *dev, enum sensor_channel ch,
|
||||||
enum sensor_attribute attr, const struct sensor_value *val)
|
enum sensor_attribute attr, const struct sensor_value *val)
|
||||||
{
|
{
|
||||||
|
const struct qdec_mcux_config *config = dev->config;
|
||||||
struct qdec_mcux_data *data = dev->data;
|
struct qdec_mcux_data *data = dev->data;
|
||||||
|
|
||||||
if (ch != SENSOR_CHAN_ROTATION) {
|
if (ch != SENSOR_CHAN_ROTATION) {
|
||||||
|
@ -59,6 +60,8 @@ static int qdec_mcux_attr_set(const struct device *dev, enum sensor_channel ch,
|
||||||
case SENSOR_ATTR_QDEC_ENABLE_SINGLE_PHASE:
|
case SENSOR_ATTR_QDEC_ENABLE_SINGLE_PHASE:
|
||||||
data->qdec_config.decoderWorkMode =
|
data->qdec_config.decoderWorkMode =
|
||||||
int_to_work_mode(val->val1);
|
int_to_work_mode(val->val1);
|
||||||
|
|
||||||
|
WRITE_BIT(config->base->CTRL, ENC_CTRL_PH1_SHIFT, val->val1);
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
default:
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue