dac_hal.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 ADC (esp32s2 specific part)
  15. #include "hal/dac_hal.h"
  16. #include "hal/adc_hal.h"
  17. #include "hal/dac_types.h"
  18. /*---------------------------------------------------------------
  19. Digital controller setting
  20. ---------------------------------------------------------------*/
  21. void dac_hal_digi_init(void)
  22. {
  23. dac_ll_digi_clk_inv(true);
  24. }
  25. void dac_hal_digi_deinit(void)
  26. {
  27. dac_ll_digi_trigger_output(false);
  28. dac_ll_digi_enable_dma(false);
  29. dac_ll_digi_fifo_reset();
  30. dac_ll_digi_reset();
  31. }
  32. void dac_hal_digi_controller_config(const dac_digi_config_t *cfg)
  33. {
  34. dac_ll_digi_set_convert_mode(cfg->mode);
  35. dac_ll_digi_set_trigger_interval(cfg->interval);
  36. adc_hal_digi_clk_config(&cfg->dig_clk);
  37. }
  38. void dac_hal_digi_start(void)
  39. {
  40. dac_ll_digi_enable_dma(true);
  41. dac_ll_digi_trigger_output(true);
  42. }
  43. void dac_hal_digi_stop(void)
  44. {
  45. dac_ll_digi_trigger_output(false);
  46. dac_ll_digi_enable_dma(false);
  47. }