input: pmw3610: run the whole init with spi clock on
Move the pmw3610_spi_clk_on and pmw3610_spi_clk_off calls so that the "on" call is before the first write. The datasheet calls for doing this before any write operations, though some writes seems to work without this in place, other seems to behave erroneously. The non static functions do it on their own as they can be called separately. Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
This commit is contained in:
parent
2c5b992209
commit
c82b38c7be
|
@ -376,6 +376,10 @@ static int pmw3610_configure(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Power-up init sequence */
|
/* Power-up init sequence */
|
||||||
|
ret = pmw3610_spi_clk_on(dev);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
ret = pmw3610_write_reg(dev, PMW3610_OBSERVATION1, 0);
|
ret = pmw3610_write_reg(dev, PMW3610_OBSERVATION1, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -424,11 +428,6 @@ static int pmw3610_configure(const struct device *dev)
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
|
|
||||||
if (cfg->invert_x || cfg->invert_y) {
|
if (cfg->invert_x || cfg->invert_y) {
|
||||||
ret = pmw3610_spi_clk_on(dev);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = pmw3610_write_reg(dev, PWM3610_SPI_PAGE0, SPI_PAGE0_1);
|
ret = pmw3610_write_reg(dev, PWM3610_SPI_PAGE0, SPI_PAGE0_1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -452,12 +451,15 @@ static int pmw3610_configure(const struct device *dev)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = pmw3610_spi_clk_off(dev);
|
|
||||||
if (ret < 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = pmw3610_spi_clk_off(dev);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The remaining functions call spi_clk_on/off independently. */
|
||||||
|
|
||||||
if (cfg->res_cpi > 0) {
|
if (cfg->res_cpi > 0) {
|
||||||
pmw3610_set_resolution(dev, cfg->res_cpi);
|
pmw3610_set_resolution(dev, cfg->res_cpi);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue