touch_sensor_hal.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // The HAL layer for Touch Sensor (common part)
  15. #include "hal/touch_sensor_hal.h"
  16. #include "hal/touch_sensor_types.h"
  17. #include "soc/soc_caps.h"
  18. void touch_hal_config(touch_pad_t touch_num)
  19. {
  20. touch_ll_set_threshold(touch_num, SOC_TOUCH_PAD_THRESHOLD_MAX);
  21. touch_ll_set_slope(touch_num, TOUCH_PAD_SLOPE_DEFAULT);
  22. touch_ll_set_tie_option(touch_num, TOUCH_PAD_TIE_OPT_DEFAULT);
  23. }
  24. void touch_hal_set_voltage(const touch_hal_volt_t *volt)
  25. {
  26. touch_ll_set_voltage_high(volt->refh);
  27. touch_ll_set_voltage_low(volt->refl);
  28. touch_ll_set_voltage_attenuation(volt->atten);
  29. }
  30. void touch_hal_get_voltage(touch_hal_volt_t *volt)
  31. {
  32. touch_ll_get_voltage_high(&volt->refh);
  33. touch_ll_get_voltage_low(&volt->refl);
  34. touch_ll_get_voltage_attenuation(&volt->atten);
  35. }
  36. void touch_hal_set_meas_mode(touch_pad_t touch_num, const touch_hal_meas_mode_t *meas)
  37. {
  38. touch_ll_set_slope(touch_num, meas->slope);
  39. touch_ll_set_tie_option(touch_num, meas->tie_opt);
  40. }
  41. void touch_hal_get_meas_mode(touch_pad_t touch_num, touch_hal_meas_mode_t *meas)
  42. {
  43. touch_ll_get_slope(touch_num, &meas->slope);
  44. touch_ll_get_tie_option(touch_num, &meas->tie_opt);
  45. }