touch_sensor_hal.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. void touch_hal_config(touch_pad_t touch_num)
  18. {
  19. touch_ll_set_threshold(touch_num, SOC_TOUCH_PAD_THRESHOLD_MAX);
  20. touch_ll_set_slope(touch_num, TOUCH_PAD_SLOPE_DEFAULT);
  21. touch_ll_set_tie_option(touch_num, TOUCH_PAD_TIE_OPT_DEFAULT);
  22. }
  23. void touch_hal_set_voltage(const touch_hal_volt_t *volt)
  24. {
  25. touch_ll_set_voltage_high(volt->refh);
  26. touch_ll_set_voltage_low(volt->refl);
  27. touch_ll_set_voltage_attenuation(volt->atten);
  28. }
  29. void touch_hal_get_voltage(touch_hal_volt_t *volt)
  30. {
  31. touch_ll_get_voltage_high(&volt->refh);
  32. touch_ll_get_voltage_low(&volt->refl);
  33. touch_ll_get_voltage_attenuation(&volt->atten);
  34. }
  35. void touch_hal_set_meas_mode(touch_pad_t touch_num, const touch_hal_meas_mode_t *meas)
  36. {
  37. touch_ll_set_slope(touch_num, meas->slope);
  38. touch_ll_set_tie_option(touch_num, meas->tie_opt);
  39. }
  40. void touch_hal_get_meas_mode(touch_pad_t touch_num, touch_hal_meas_mode_t *meas)
  41. {
  42. touch_ll_get_slope(touch_num, &meas->slope);
  43. touch_ll_get_tie_option(touch_num, &meas->tie_opt);
  44. }