paw3204.h (2445B)
1 /* Copyright 2021 Gompa (@Gompa) 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 17 #pragma once 18 19 #include <stdint.h> 20 #include <stdbool.h> 21 #include "pointing_device.h" 22 23 #ifndef PAW3204_SCLK_PIN 24 # ifdef POINTING_DEVICE_SCLK_PIN 25 # define PAW3204_SCLK_PIN POINTING_DEVICE_SCLK_PIN 26 # else 27 # error "No clock pin defined -- missing POINTING_DEVICE_SCLK_PIN or PAW3204_SCLK_PIN" 28 # endif 29 #endif 30 #ifndef PAW3204_SDIO_PIN 31 # ifdef POINTING_DEVICE_SDIO_PIN 32 # define PAW3204_SDIO_PIN POINTING_DEVICE_SDIO_PIN 33 # else 34 # error "No data pin defined -- missing POINTING_DEVICE_SDIO_PIN or PAW3204_SDIO_PIN" 35 # endif 36 #endif 37 38 typedef struct { 39 int16_t x; 40 int16_t y; 41 bool isMotion; 42 } report_paw3204_t; 43 44 extern const pointing_device_driver_t paw3204_pointing_device_driver; 45 46 /** 47 * @brief Initializes the sensor so it is in a working state and ready to 48 * be polled for data. 49 * 50 * @return true Initialization was a success 51 * @return false Initialization failed, do not proceed operation 52 */ 53 bool paw3204_init(void); 54 55 /** 56 * @brief Reads and clears the current delta, and motion register values on the 57 * given sensor. 58 * 59 * @return pmw33xx_report_t Current values of the sensor, if errors occurred all 60 * fields are set to zero 61 */ 62 63 report_paw3204_t paw3204_read(void); 64 /** 65 * @brief Sets the given CPI value the sensor. CPI is often refereed to 66 * as the sensors sensitivity. Values outside of the allowed range are 67 * constrained into legal values. 68 * 69 * @param cpi CPI value to set 70 */ 71 void paw3204_set_cpi(uint16_t cpi); 72 73 /** 74 * @brief Gets the currently set CPI value from the sensor. CPI is often 75 * refereed to as the sensors sensitivity. 76 * 77 * @return uint16_t Current CPI value of the sensor 78 */ 79 uint16_t paw3204_get_cpi(void); 80 81 report_mouse_t paw3204_get_report(report_mouse_t mouse_report);