diff options
Diffstat (limited to 'drivers/sensors/adns5050.h')
| -rw-r--r-- | drivers/sensors/adns5050.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/sensors/adns5050.h b/drivers/sensors/adns5050.h new file mode 100644 index 000000000..ff8e8f78e --- /dev/null +++ b/drivers/sensors/adns5050.h | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | /* Copyright 2021 Colin Lam (Ploopy Corporation) | ||
| 2 | * Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
| 3 | * Copyright 2019 Sunjun Kim | ||
| 4 | * Copyright 2019 Hiroyuki Okada | ||
| 5 | * | ||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #pragma once | ||
| 21 | |||
| 22 | #include <stdbool.h> | ||
| 23 | |||
| 24 | // Registers | ||
| 25 | #define REG_PRODUCT_ID 0x00 | ||
| 26 | #define REG_REVISION_ID 0x01 | ||
| 27 | #define REG_MOTION 0x02 | ||
| 28 | #define REG_DELTA_X 0x03 | ||
| 29 | #define REG_DELTA_Y 0x04 | ||
| 30 | #define REG_SQUAL 0x05 | ||
| 31 | #define REG_SHUTTER_UPPER 0x06 | ||
| 32 | #define REG_SHUTTER_LOWER 0x07 | ||
| 33 | #define REG_MAXIMUM_PIXEL 0x08 | ||
| 34 | #define REG_PIXEL_SUM 0x09 | ||
| 35 | #define REG_MINIMUM_PIXEL 0x0a | ||
| 36 | #define REG_PIXEL_GRAB 0x0b | ||
| 37 | #define REG_MOUSE_CONTROL 0x0d | ||
| 38 | #define REG_MOUSE_CONTROL2 0x19 | ||
| 39 | #define REG_LED_DC_MODE 0x22 | ||
| 40 | #define REG_CHIP_RESET 0x3a | ||
| 41 | #define REG_PRODUCT_ID2 0x3e | ||
| 42 | #define REG_INV_REV_ID 0x3f | ||
| 43 | #define REG_MOTION_BURST 0x63 | ||
| 44 | |||
| 45 | // CPI values | ||
| 46 | #define CPI125 0x11 | ||
| 47 | #define CPI250 0x12 | ||
| 48 | #define CPI375 0x13 | ||
| 49 | #define CPI500 0x14 | ||
| 50 | #define CPI625 0x15 | ||
| 51 | #define CPI750 0x16 | ||
| 52 | #define CPI875 0x17 | ||
| 53 | #define CPI1000 0x18 | ||
| 54 | #define CPI1125 0x19 | ||
| 55 | #define CPI1250 0x1a | ||
| 56 | #define CPI1375 0x1b | ||
| 57 | |||
| 58 | #ifdef CONSOLE_ENABLE | ||
| 59 | void print_byte(uint8_t byte); | ||
| 60 | #endif | ||
| 61 | |||
| 62 | typedef struct { | ||
| 63 | int8_t dx; | ||
| 64 | int8_t dy; | ||
| 65 | } report_adns_t; | ||
| 66 | |||
| 67 | // A bunch of functions to implement the ADNS5050-specific serial protocol. | ||
| 68 | // Note that the "serial.h" driver is insufficient, because it does not | ||
| 69 | // manually manipulate a serial clock signal. | ||
| 70 | void adns_init(void); | ||
| 71 | void adns_sync(void); | ||
| 72 | uint8_t adns_serial_read(void); | ||
| 73 | void adns_serial_write(uint8_t data); | ||
| 74 | uint8_t adns_read_reg(uint8_t reg_addr); | ||
| 75 | void adns_write_reg(uint8_t reg_addr, uint8_t data); | ||
| 76 | report_adns_t adns_read_burst(void); | ||
| 77 | int8_t convert_twoscomp(uint8_t data); | ||
| 78 | void adns_set_cpi(uint8_t cpi); | ||
| 79 | bool adns_check_signature(void); | ||
