logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

adns9800.h (2105B)


  1. /* Copyright 2020 Alexander Tulloh
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include "pointing_device.h"
  19. #ifndef ADNS9800_CPI
  20. # define ADNS9800_CPI 1600
  21. #endif
  22. #ifndef ADNS9800_CLOCK_SPEED
  23. # define ADNS9800_CLOCK_SPEED 2000000
  24. #endif
  25. #ifndef ADNS9800_SPI_LSBFIRST
  26. # define ADNS9800_SPI_LSBFIRST false
  27. #endif
  28. #ifndef ADNS9800_SPI_MODE
  29. # define ADNS9800_SPI_MODE 3
  30. #endif
  31. #ifndef ADNS9800_SPI_DIVISOR
  32. # ifdef __AVR__
  33. # define ADNS9800_SPI_DIVISOR (F_CPU / ADNS9800_CLOCK_SPEED)
  34. # else
  35. # define ADNS9800_SPI_DIVISOR 64
  36. # endif
  37. #endif
  38. #ifndef ADNS9800_CS_PIN
  39. # ifdef POINTING_DEVICE_CS_PIN
  40. # define ADNS9800_CS_PIN POINTING_DEVICE_CS_PIN
  41. # else
  42. # error "No chip select pin defined -- missing POINTING_DEVICE_CS_PIN or ADNS9800_CS_PIN"
  43. # endif
  44. #endif
  45. typedef struct {
  46. /* 200 - 8200 CPI supported */
  47. uint16_t cpi;
  48. } config_adns9800_t;
  49. typedef struct {
  50. int16_t x;
  51. int16_t y;
  52. } report_adns9800_t;
  53. const pointing_device_driver_t adns9800_pointing_device_driver;
  54. void adns9800_init(void);
  55. config_adns9800_t adns9800_get_config(void);
  56. void adns9800_set_config(config_adns9800_t);
  57. uint16_t adns9800_get_cpi(void);
  58. void adns9800_set_cpi(uint16_t cpi);
  59. /* Reads and clears the current delta values on the ADNS sensor */
  60. report_adns9800_t adns9800_get_report(void);
  61. report_mouse_t adns9800_get_report_driver(report_mouse_t mouse_report);