Lines Matching +full:touch +full:- +full:sensor

4  * SPDX-License-Identifier: Apache-2.0
80 const struct esp32_touch_sensor_config *dev_cfg = dev->config;
82 const int num_channels = dev_cfg->num_channels;
97 channel_cfg = &dev_cfg->channel_cfg[i];
102 touch_hal_read_benchmark(channel_cfg->channel_num,
104 touch_hal_set_threshold(channel_cfg->channel_num,
105 channel_cfg->channel_sens * benchmark_value / 100);
119 channel_cfg = &dev_cfg->channel_cfg[i];
120 channel_status = (pad_status >> channel_cfg->channel_num) & 0x01;
127 if (channel_cfg->channel_num == channel_num) {
130 *channel_data = &dev_cfg->channel_data[i];
132 channel_data->status = channel_status;
133 (void)k_work_reschedule(&channel_data->work,
134 K_MSEC(dev_cfg->debounce_interval_ms));
153 * Handle debounced touch sensor touch state.
160 const struct device *dev = channel_data->dev;
161 const struct esp32_touch_sensor_config *dev_cfg = dev->config;
162 int key_index = channel_data - &dev_cfg->channel_data[0];
164 *channel_cfg = &dev_cfg->channel_cfg[key_index];
167 if (channel_data->last_status != channel_data->status) {
169 input_report_key(dev, channel_cfg->zephyr_code,
170 channel_data->status, true, K_FOREVER);
172 channel_data->last_status = channel_data->status;
181 const struct esp32_touch_sensor_config *dev_cfg = dev->config;
182 const int num_channels = dev_cfg->num_channels;
188 .refh = dev_cfg->href_microvolt_enum_idx,
189 .refh = dev_cfg->href_microvolt_enum_idx,
190 .atten = dev_cfg->href_atten_microvolt_enum_idx
198 struct esp32_touch_sensor_channel_data *channel_data = &dev_cfg->channel_data[i];
200 &dev_cfg->channel_cfg[i];
202 if (!(channel_cfg->channel_num > 0 &&
203 channel_cfg->channel_num < SOC_TOUCH_SENSOR_NUM)) {
204 LOG_ERR("Touch %d configuration failed: "
205 "Touch channel error", i);
206 return -EINVAL;
210 if (channel_cfg->channel_num == SOC_TOUCH_DENOISE_CHANNEL) {
211 LOG_ERR("Touch %d configuration failed: "
213 return -EINVAL;
217 gpio_num_t gpio_num = touch_sensor_channel_io_map[channel_cfg->channel_num];
224 touch_hal_config(channel_cfg->channel_num);
226 touch_hal_set_threshold(channel_cfg->channel_num, 0);
227 touch_hal_set_group_mask(BIT(channel_cfg->channel_num),
228 BIT(channel_cfg->channel_num));
230 touch_hal_set_channel_mask(BIT(channel_cfg->channel_num));
232 channel_data->status = 0;
234 channel_data->last_status = 0;
236 channel_data->dev = dev;
238 k_work_init_delayable(&channel_data->work, esp32_touch_sensor_change_deferred);
244 &dev_cfg->channel_cfg[i];
249 if (k_uptime_get_32() - ref_time > 500) {
250 return -ETIMEDOUT;
254 uint16_t touch_value = touch_hal_read_raw_data(channel_cfg->channel_num);
256 touch_hal_set_threshold(channel_cfg->channel_num,
257 touch_value * (100 - channel_cfg->channel_num) / 100);
262 .mode = dev_cfg->filter_mode,
263 .debounce_cnt = dev_cfg->filter_debounce_cnt,
264 .noise_thr = dev_cfg->filter_noise_thr,
265 .jitter_step = dev_cfg->filter_jitter_step,
266 .smh_lvl = dev_cfg->filter_smooth_level,
275 flags = ESP_PRIO_TO_FLAGS(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, priority)) |
276 ESP_INT_FLAGS_CHECK(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, flags)) |
278 err = esp_intr_alloc(DT_IRQ_BY_IDX(DT_NODELABEL(touch), 0, irq), flags, esp32_touch_rtc_isr,
282 return -EFAULT;