Lines Matching +full:z +full:- +full:threshold

3  * SPDX-License-Identifier: Apache-2.0
62 #define STMPE811_INT_BIT_FIFO_THRESHOLD BIT(1) /* FIFO above threshold interrupt */
83 * - bits [1-3] X, Y only acquisition mode
88 * Analog-to-digital Converter
90 * - bit [3] selects 12 bit ADC
91 * - bits [4-6] select ADC conversion time = 80
98 * - 00 : 1.625 MHz
99 * - 01 : 3.25 MHz
100 * - 10 : 6.5 MHz
101 * - 11 : 6.5 MHz
106 * Range and accuracy of the pressure measurement (Z)
108 * - Fractional part : 7
109 * - Whole part : 1
138 const struct stmpe811_config *config = dev->config; in stmpe811_reset()
141 int ret = i2c_reg_write_byte_dt(&config->bus, STMPE811_SYS_CTRL1_REG, in stmpe811_reset()
150 ret = i2c_reg_write_byte_dt(&config->bus, STMPE811_SYS_CTRL1_REG, in stmpe811_reset()
162 const struct stmpe811_config *config = dev->config; in stmpe811_io_enable_af()
165 return i2c_reg_update_byte_dt(&config->bus, STMPE811_IO_AF_REG, io_pin, 0); in stmpe811_io_enable_af()
170 const struct stmpe811_config *config = dev->config; in stmpe811_tsc_config_bits()
174 * - bits [0-2] : panel driver settling time in stmpe811_tsc_config_bits()
175 * - bits [3-5] : touch detect delay in stmpe811_tsc_config_bits()
176 * - bits [6-7] : touch average control in stmpe811_tsc_config_bits()
179 return config->panel_driver_settling_time_us | config->touch_detect_delay_us << 3 | in stmpe811_tsc_config_bits()
180 config->touch_average_control << 6; in stmpe811_tsc_config_bits()
185 const struct stmpe811_config *config = dev->config; in stmpe811_tsc_control_bits()
190 * - bit [0] enables TSC in stmpe811_tsc_control_bits()
191 * - bits [1-3] X, Y only acquisition mode in stmpe811_tsc_control_bits()
192 * - bits [4-6] window tracking index (set from config) in stmpe811_tsc_control_bits()
193 * - bit [7] TSC status (writing has no effect) in stmpe811_tsc_control_bits()
196 return STMPE811_TSC_CTRL_CONF | config->tracking_index << 4; in stmpe811_tsc_control_bits()
201 const struct stmpe811_config *config = dev->config; in stmpe811_ts_init()
217 * Bits [0-3] disable functionalities if set to 1 (reset value: 0x0f) in stmpe811_ts_init()
221 err = i2c_reg_update_byte_dt(&config->bus, STMPE811_SYS_CTRL2_REG, in stmpe811_ts_init()
229 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_ADC_CTRL1_REG, STMPE811_ADC_CTRL1_CONF); in stmpe811_ts_init()
235 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_ADC_CTRL2_REG, STMPE811_ADC_CLOCK_SPEED); in stmpe811_ts_init()
241 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_TSC_CFG_REG, in stmpe811_ts_init()
247 /* Configure the touch FIFO threshold */ in stmpe811_ts_init()
248 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_FIFO_TH_REG, in stmpe811_ts_init()
255 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_FIFO_STA_REG, STMPE811_FIFO_STA_CLEAR); in stmpe811_ts_init()
260 /* Set the range and accuracy of the pressure measurement (Z) */ in stmpe811_ts_init()
261 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_TSC_FRACT_XYZ_REG, in stmpe811_ts_init()
268 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_TSC_I_DRIVE_REG, in stmpe811_ts_init()
275 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_TSC_CTRL_REG, in stmpe811_ts_init()
284 * This is an 8-bit register, so writing 0xFF clears all. in stmpe811_ts_init()
286 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_INT_STA_REG, STMPE811_INT_ALL); in stmpe811_ts_init()
292 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_FIFO_STA_REG, in stmpe811_ts_init()
299 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_INT_EN_REG, in stmpe811_ts_init()
311 const struct stmpe811_config *config = dev->config; in stmpe811_ts_get_data()
312 struct stmpe811_data *data = dev->data; in stmpe811_ts_get_data()
317 int ret = i2c_burst_read_dt(&config->bus, STMPE811_TSC_DATA_NON_INC_REG, data_xy, in stmpe811_ts_get_data()
325 data->touch_x = (uldata_xy >> 12U) & BIT_MASK(12); in stmpe811_ts_get_data()
326 data->touch_y = uldata_xy & BIT_MASK(12); in stmpe811_ts_get_data()
333 const struct stmpe811_config *config = dev->config; in stmpe811_report_touch()
334 struct stmpe811_data *data = dev->data; in stmpe811_report_touch()
335 int x = data->touch_x; in stmpe811_report_touch()
336 int y = data->touch_y; in stmpe811_report_touch()
338 if (config->screen_width > 0 && config->screen_height > 0) { in stmpe811_report_touch()
339 x = (((int)data->touch_x - config->raw_x_min) * config->screen_width) / in stmpe811_report_touch()
340 (config->raw_x_max - config->raw_x_min); in stmpe811_report_touch()
341 y = (((int)data->touch_y - config->raw_y_min) * config->screen_height) / in stmpe811_report_touch()
342 (config->raw_y_max - config->raw_y_min); in stmpe811_report_touch()
344 x = CLAMP(x, 0, config->screen_width); in stmpe811_report_touch()
345 y = CLAMP(y, 0, config->screen_height); in stmpe811_report_touch()
355 const struct stmpe811_config *config = dev->config; in stmpe811_process()
360 err = i2c_reg_read_byte_dt(&config->bus, STMPE811_INT_STA_REG, &int_sta); in stmpe811_process()
366 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_INT_STA_REG, int_sta); in stmpe811_process()
382 err = i2c_reg_read_byte_dt(&config->bus, STMPE811_FIFO_SIZE_REG, in stmpe811_process()
405 err = i2c_reg_read_byte_dt(&config->bus, STMPE811_TSC_CTRL_REG, &tsc_ctrl); in stmpe811_process()
422 const struct stmpe811_config *config = data->dev->config; in stmpe811_work_handler()
424 stmpe811_process(data->dev); in stmpe811_work_handler()
427 * IRQ is edge-triggered, so otherwise it would never be triggered again. in stmpe811_work_handler()
429 if (gpio_pin_get_dt(&config->int_gpio)) { in stmpe811_work_handler()
430 k_work_submit(&data->processing_work); in stmpe811_work_handler()
439 k_work_submit(&data->processing_work); in stmpe811_interrupt_handler()
444 const struct stmpe811_config *config = dev->config; in stmpe811_verify_chip_id()
447 i2c_burst_read_dt(&config->bus, STMPE811_CHP_ID_LSB_REG, buf, 2); in stmpe811_verify_chip_id()
450 return -EINVAL; in stmpe811_verify_chip_id()
458 const struct stmpe811_config *config = dev->config; in stmpe811_init()
459 struct stmpe811_data *data = dev->data; in stmpe811_init()
462 if (!i2c_is_ready_dt(&config->bus)) { in stmpe811_init()
464 return -ENODEV; in stmpe811_init()
467 data->dev = dev; in stmpe811_init()
469 k_work_init(&data->processing_work, stmpe811_work_handler); in stmpe811_init()
486 if (!gpio_is_ready_dt(&config->int_gpio)) { in stmpe811_init()
488 return -ENODEV; in stmpe811_init()
491 err = gpio_pin_configure_dt(&config->int_gpio, GPIO_INPUT); in stmpe811_init()
497 err = gpio_pin_interrupt_configure_dt(&config->int_gpio, GPIO_INT_EDGE_TO_ACTIVE); in stmpe811_init()
503 gpio_init_callback(&data->int_gpio_cb, stmpe811_interrupt_handler, in stmpe811_init()
504 BIT(config->int_gpio.pin)); in stmpe811_init()
505 err = gpio_add_callback_dt(&config->int_gpio, &data->int_gpio_cb); in stmpe811_init()
512 err = i2c_reg_write_byte_dt(&config->bus, STMPE811_INT_CTRL_REG, in stmpe811_init()
525 "raw-x-max should be larger than raw-x-min"); \
528 "raw-y-max should be larger than raw-y-min"); \