touch_sensor_hal.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. // The HAL layer for Touch Sensor (common part)
  7. #include "hal/touch_sensor_hal.h"
  8. #include "hal/touch_sensor_types.h"
  9. #include "soc/soc_caps.h"
  10. void touch_hal_config(touch_pad_t touch_num)
  11. {
  12. touch_ll_set_threshold(touch_num, TOUCH_PAD_THRESHOLD_MAX);
  13. touch_ll_set_slope(touch_num, TOUCH_PAD_SLOPE_DEFAULT);
  14. touch_ll_set_tie_option(touch_num, TOUCH_PAD_TIE_OPT_DEFAULT);
  15. }
  16. void touch_hal_set_voltage(const touch_hal_volt_t *volt)
  17. {
  18. touch_ll_set_voltage_high(volt->refh);
  19. touch_ll_set_voltage_low(volt->refl);
  20. touch_ll_set_voltage_attenuation(volt->atten);
  21. }
  22. void touch_hal_get_voltage(touch_hal_volt_t *volt)
  23. {
  24. touch_ll_get_voltage_high(&volt->refh);
  25. touch_ll_get_voltage_low(&volt->refl);
  26. touch_ll_get_voltage_attenuation(&volt->atten);
  27. }
  28. void touch_hal_set_meas_mode(touch_pad_t touch_num, const touch_hal_meas_mode_t *meas)
  29. {
  30. touch_ll_set_slope(touch_num, meas->slope);
  31. touch_ll_set_tie_option(touch_num, meas->tie_opt);
  32. }
  33. void touch_hal_get_meas_mode(touch_pad_t touch_num, touch_hal_meas_mode_t *meas)
  34. {
  35. touch_ll_get_slope(touch_num, &meas->slope);
  36. touch_ll_get_tie_option(touch_num, &meas->tie_opt);
  37. }