pmw3325.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2021 Colin Lam (Ploopy Corporation)
  2. // Copyright 2026 HorrorTroll <https://github.com/HorrorTroll>
  3. // SPDX-License-Identifier: GPL-2.0-or-later
  4. #pragma once
  5. #include <stdbool.h>
  6. #include <stdint.h>
  7. #include "pointing_device.h"
  8. #ifndef PMW3325_CS_PIN
  9. # ifdef POINTING_DEVICE_CS_PIN
  10. # define PMW3325_CS_PIN POINTING_DEVICE_CS_PIN
  11. # else
  12. # error "No chip select pin defined -- missing POINTING_DEVICE_CS_PIN or PMW3325_CS_PIN define"
  13. # endif
  14. #endif
  15. #ifndef PMW3325_SPI_DIVISOR
  16. # error "No PMW3325 SPI divisor defined -- missing PMW3325_SPI_DIVISOR"
  17. #endif
  18. typedef struct {
  19. int16_t dx;
  20. int16_t dy;
  21. } report_pmw3325_t;
  22. extern const pointing_device_driver_t pmw3325_pointing_device_driver;
  23. bool pmw3325_init(void);
  24. report_pmw3325_t pmw3325_read_burst(void);
  25. void pmw3325_set_cpi(uint16_t cpi);
  26. uint16_t pmw3325_get_cpi(void);
  27. report_mouse_t pmw3325_get_report(report_mouse_t mouse_report);
  28. bool pmw3325_check_signature(void);
  29. #if !defined(PMW3325_CPI)
  30. # define PMW3325_CPI 2000
  31. #endif
  32. #define PMW3325_CPI_MIN 100
  33. #define PMW3325_CPI_MAX 5000
  34. #define PMW3325_CPI_STEP 100
  35. #define CONSTRAIN(amt, low, high) ((amt) < (low) ? (low) : ((amt) > (high) ? (high) : (amt)))