i2c_hal_iram.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #include "hal/i2c_hal.h"
  15. void i2c_hal_master_handle_tx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  16. {
  17. if (i2c_ll_get_intsts_mask(hal->dev) != 0) {
  18. // If intr status is 0, no need to handle it.
  19. i2c_ll_master_get_event(hal->dev, event);
  20. if ((*event < I2C_INTR_EVENT_END_DET) ||
  21. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  22. i2c_ll_master_disable_tx_it(hal->dev);
  23. i2c_ll_master_clr_tx_it(hal->dev);
  24. } else if (*event == I2C_INTR_EVENT_END_DET) {
  25. i2c_ll_master_clr_tx_it(hal->dev);
  26. }
  27. }
  28. }
  29. void i2c_hal_master_handle_rx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  30. {
  31. if (i2c_ll_get_intsts_mask(hal->dev) != 0) {
  32. i2c_ll_master_get_event(hal->dev, event);
  33. if ((*event < I2C_INTR_EVENT_END_DET) ||
  34. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  35. i2c_ll_master_disable_rx_it(hal->dev);
  36. i2c_ll_master_clr_rx_it(hal->dev);
  37. } else if (*event == I2C_INTR_EVENT_END_DET) {
  38. i2c_ll_master_clr_rx_it(hal->dev);
  39. }
  40. }
  41. }
  42. void i2c_hal_slave_handle_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  43. {
  44. i2c_ll_slave_get_event(hal->dev, event);
  45. }