i2c_hal_iram.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "hal/i2c_hal.h"
  7. void i2c_hal_master_trans_start(i2c_hal_context_t *hal)
  8. {
  9. i2c_ll_update(hal->dev);
  10. i2c_ll_master_trans_start(hal->dev);
  11. }
  12. //////////////////////////////////////////Deprecated Functions//////////////////////////////////////////////////////////
  13. /////////////////////////////The following functions are only used by the legacy driver/////////////////////////////////
  14. /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)//////////////////////////////
  15. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  16. void i2c_hal_master_handle_tx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  17. {
  18. uint32_t intr_status = 0;
  19. i2c_ll_get_intr_mask(hal->dev, &intr_status);
  20. if (intr_status != 0) {
  21. // If intr status is 0, no need to handle it.
  22. i2c_ll_master_get_event(hal->dev, event);
  23. if ((*event < I2C_INTR_EVENT_END_DET) ||
  24. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  25. i2c_ll_master_disable_tx_it(hal->dev);
  26. i2c_ll_clear_intr_mask(hal->dev, intr_status);
  27. } else if (*event == I2C_INTR_EVENT_END_DET) {
  28. i2c_ll_clear_intr_mask(hal->dev, intr_status);
  29. }
  30. }
  31. }
  32. void i2c_hal_master_handle_rx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  33. {
  34. uint32_t intr_status = 0;
  35. i2c_ll_get_intr_mask(hal->dev, &intr_status);
  36. if (intr_status != 0) {
  37. i2c_ll_master_get_event(hal->dev, event);
  38. if ((*event < I2C_INTR_EVENT_END_DET) ||
  39. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  40. i2c_ll_master_disable_rx_it(hal->dev);
  41. i2c_ll_clear_intr_mask(hal->dev, intr_status);
  42. } else if (*event == I2C_INTR_EVENT_END_DET) {
  43. i2c_ll_clear_intr_mask(hal->dev, intr_status);
  44. }
  45. }
  46. }