PMW3360 device doesn't configure properly with SDK version greater than NRF-Connect SDK 2.0.2

I have encountered an issue with the configuration of the Pixart PMW3360 device when using SDK versions higher than NRF-Connect SDK 2.0.2. After researching the development progress on GitHub, I noticed significant changes to the SPI handling mechanism, which seems to be causing the problem.

When attempting to configure the PMW3360 device using SDK versions above NRF-Connect SDK 2.0.2, the configuration process fails to complete successfully. The device does not respond as expected when uploading firmware to the device, leading to the device not being initialized. This issue arises specifically with SDK versions beyond 2.0.2.
This is the debug output of the sensor with the 2.0.2 SDK:

00> *** Booting Zephyr OS build v3.0.99-ncs1-1 ***
00>
00> [00:00:00.000,122] <dbg> main: main: Starting mouse
00> [00:00:00.000,213] <dbg> buttons: configure_callback: Set up button at GPIO_0 pin 30
00> [00:00:00.000,305] <dbg> buttons: configure_callback: Set up button at GPIO_0 pin 8
00> [00:00:00.000,366] <dbg> buttons: configure_callback: Set up button at GPIO_0 pin 29
00> [00:00:00.000,396] <dbg> buttons: configure_callback: Set up button at GPIO_0 pin 3
00> [00:00:00.000,427] <dbg> buttons: configure_callback: Set up button at GPIO_0 pin 28
00> [00:00:00.000,457] <dbg> pmw3360: pmw3360_attr_set: Device is not initialized yet
00> [00:00:00.001,129] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 0
00> [00:00:00.001,647] <inf> usb_hid: Device connected
00> [00:00:00.004,760] <inf> usb_hid: Device suspended
00> [00:00:00.051,483] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 1
00> [00:00:00.063,568] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 2
00> [00:00:00.063,598] <inf> pmw3360: Uploading optical sensor firmware...
00> [00:00:00.363,555] <inf> usb_hid: Device resumed
00> [00:00:00.363,555] <inf> usb_hid: from suspend
00> [00:00:00.363,616] <inf> usb_hid: Device reset detected
00> [00:00:00.363,952] <inf> usb_hid: Device reset detected
00> [00:00:00.364,562] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 3
00> [00:00:00.364,898] <dbg> pmw3360: pmw3360_async_init_fw_load_verify: Optical chip firmware ID: 0x4
00> [00:00:00.365,478] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 4
00> [00:00:00.365,478] <inf> pmw3360: Setting CPI to 400 (reg value 0x3)
00> [00:00:00.365,753] <inf> pmw3360: Set downshift time to 500 ms (reg value 0x32)
00> [00:00:00.366,027] <inf> pmw3360: Set downshift time to 9220 ms (reg value 0x1c)
00> [00:00:00.366,271] <inf> pmw3360: Set downshift time to 150000 ms (reg value 0x2e)
00> [00:00:00.366,546] <inf> pmw3360: PMW3360 initialized
00> [00:00:00.549,652] <inf> usb_hid: Device configured

This is the output of version 2.3 SDK:

00> *** Booting Zephyr OS build v3.2.99-ncs2 ***
00> [00:00:00.000,152] <dbg> main: main: Starting mouse
00> [00:00:00.000,305] <dbg> buttons: configure_callback: Set up button at gpio@50000000 pin 30
00> [00:00:00.000,366] <dbg> buttons: configure_callback: Set up button at gpio@50000000 pin 8
00> [00:00:00.000,427] <dbg> buttons: configure_callback: Set up button at gpio@50000000 pin 29
00> [00:00:00.000,488] <dbg> buttons: configure_callback: Set up button at gpio@50000000 pin 3
00> [00:00:00.000,579] <dbg> buttons: configure_callback: Set up button at gpio@50000000 pin 28
00> [00:00:00.000,579] <dbg> pmw3360: pmw3360_attr_set: Device is not initialized yet
00> [00:00:00.001,129] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 0
00> [00:00:00.001,739] <inf> usb_hid: Device connected
00> [00:00:00.004,852] <inf> usb_hid: Device suspended
00> [00:00:00.051,483] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 1
00> [00:00:00.063,568] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 2
00> [00:00:00.063,598] <inf> pmw3360: Uploading optical sensor firmware...
00> [00:00:00.361,633] <inf> usb_hid: Device reset detected
00> [00:00:00.361,663] <inf> usb_hid: Device resumed
00> [00:00:00.361,968] <inf> usb_hid: Device reset detected
00> [00:00:00.362,609] <dbg> pmw3360: pmw3360_async_init: PMW3360 async init step 3
00> [00:00:00.362,945] <dbg> pmw3360: pmw3360_async_init_fw_load_verify: Optical chip firmware ID: 0xff
00> [00:00:00.362,945] <err> pmw3360: Chip is not running from SROM!
00> [00:00:00.362,976] <err> pmw3360: PMW3360 initialization failed
00> [00:00:00.567,749] <inf> usb_hid: Device configured

While exploring the development changes on GitHub, I noticed modifications related to the handling of SPI. These changes seem to have an impact on the NRF PMW3360 device's configuration process. It appears that the alteration to the SPI handling mechanism in SDK versions after 2.0.2 is causing compatibility issues.

Hopefully, this issue can be resolved,

Related