1 /* 2 * Copyright (c) 2020 Sven Herrmann 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef ZEPHYR_DRIVERS_SENSOR_MPR_H_ 8 #define ZEPHYR_DRIVERS_SENSOR_MPR_H_ 9 10 #include <zephyr/drivers/i2c.h> 11 12 /* MPR output measurement command */ 13 #define MPR_OUTPUT_MEASUREMENT_COMMAND (0xAA) 14 15 /* MPR status byte masks */ 16 #define MPR_STATUS_MASK_MATH_SATURATION (0x01) 17 #define MPR_STATUS_MASK_INTEGRITY_TEST_FAILED (0x04) 18 #define MPR_STATUS_MASK_BUSY (0x20) 19 #define MPR_STATUS_MASK_POWER_ON (0x40) 20 21 /* MPR register read maximum retries */ 22 #ifndef MPR_REG_READ_MAX_RETRIES 23 #define MPR_REG_READ_MAX_RETRIES (3) 24 #endif 25 26 /* MPR register read data conversion delay [ms] */ 27 #ifndef MPR_REG_READ_DATA_CONV_DELAY_MS 28 #define MPR_REG_READ_DATA_CONV_DELAY_MS (5) 29 #endif 30 31 struct mpr_data { 32 uint32_t reg_val; 33 }; 34 35 struct mpr_config { 36 struct i2c_dt_spec i2c; 37 }; 38 39 int mpr_reg_read(const struct device *dev, uint8_t reg, uint16_t *val); 40 41 #endif /* ZEPHYR_DRIVERS_SENSOR_MPR_H_ */ 42