i2c_hal_iram.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. i2c_ll_master_get_event(hal->dev, event);
  18. if ((*event < I2C_INTR_EVENT_END_DET) ||
  19. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  20. i2c_ll_master_disable_tx_it(hal->dev);
  21. i2c_ll_master_clr_tx_it(hal->dev);
  22. } else if (*event == I2C_INTR_EVENT_END_DET) {
  23. i2c_ll_master_clr_tx_it(hal->dev);
  24. }
  25. }
  26. void i2c_hal_master_handle_rx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  27. {
  28. i2c_ll_master_get_event(hal->dev, event);
  29. if ((*event < I2C_INTR_EVENT_END_DET) ||
  30. (*event == I2C_INTR_EVENT_TRANS_DONE)) {
  31. i2c_ll_master_disable_rx_it(hal->dev);
  32. i2c_ll_master_clr_rx_it(hal->dev);
  33. } else if (*event == I2C_INTR_EVENT_END_DET) {
  34. i2c_ll_master_clr_rx_it(hal->dev);
  35. }
  36. }
  37. void i2c_hal_slave_handle_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
  38. {
  39. i2c_ll_slave_get_event(hal->dev, event);
  40. }