aboutsummaryrefslogtreecommitdiff
path: root/drivers/sensors/adns5050.c
diff options
context:
space:
mode:
authorColin Kinloch <colin.kinloch@collabora.com>2024-08-26 21:06:53 +0100
committerGitHub <noreply@github.com>2024-08-26 14:06:53 -0600
commitcc3bc2af11744fe22e063bfb8ed1b8dcf7562224 (patch)
treedb4e74bb5bed4a00f0008974f70a8db8fd8f8b66 /drivers/sensors/adns5050.c
parentdf5800b6c4e71574f3e7962446311b7c1b3d39ba (diff)
Add ability to poweroff ADNS5050 sensor (#24223)
* Add ability to poweroff ADNS5050 sensor * ploopyco/trackball_nano: Poweroff ADNS5050 on suspend
Diffstat (limited to 'drivers/sensors/adns5050.c')
-rw-r--r--drivers/sensors/adns5050.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/sensors/adns5050.c b/drivers/sensors/adns5050.c
index 97daa8db09..f28a5dcc45 100644
--- a/drivers/sensors/adns5050.c
+++ b/drivers/sensors/adns5050.c
@@ -45,6 +45,8 @@
#define REG_MOTION_BURST 0x63
// clang-format on
+static bool powered_down = false;
+
void adns5050_init(void) {
// Initialize the ADNS serial pins.
gpio_set_pin_output(ADNS5050_SCLK_PIN);
@@ -59,6 +61,8 @@ void adns5050_init(void) {
// this ensures that the adns is actuall ready after reset.
wait_ms(55);
+ powered_down = false;
+
// read a burst from the adns and then discard it.
// gets the adns ready for write commands
// (for example, setting the dpi).
@@ -163,6 +167,10 @@ report_adns5050_t adns5050_read_burst(void) {
data.dx = 0;
data.dy = 0;
+ if (powered_down) {
+ return data;
+ }
+
adns5050_serial_write(REG_MOTION_BURST);
// We don't need a minimum tSRAD here. That's because a 4ms wait time is
@@ -211,3 +219,10 @@ bool adns5050_check_signature(void) {
return (pid == 0x12 && rid == 0x01 && pid2 == 0x26);
}
+
+void adns5050_power_down(void) {
+ if (!powered_down) {
+ powered_down = true;
+ adns5050_write_reg(REG_MOUSE_CONTROL, 0b10);
+ }
+}