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
15 #include "hal/i2c_hal.h"
16
i2c_hal_master_handle_tx_event(i2c_hal_context_t * hal,i2c_intr_event_t * event)17 void i2c_hal_master_handle_tx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
18 {
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
i2c_hal_master_handle_rx_event(i2c_hal_context_t * hal,i2c_intr_event_t * event)29 void i2c_hal_master_handle_rx_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
30 {
31 i2c_ll_master_get_event(hal->dev, event);
32 if ((*event < I2C_INTR_EVENT_END_DET) ||
33 (*event == I2C_INTR_EVENT_TRANS_DONE)) {
34 i2c_ll_master_disable_rx_it(hal->dev);
35 i2c_ll_master_clr_rx_it(hal->dev);
36 } else if (*event == I2C_INTR_EVENT_END_DET) {
37 i2c_ll_master_clr_rx_it(hal->dev);
38 }
39 }
40
i2c_hal_slave_handle_event(i2c_hal_context_t * hal,i2c_intr_event_t * event)41 void i2c_hal_slave_handle_event(i2c_hal_context_t *hal, i2c_intr_event_t *event)
42 {
43 i2c_ll_slave_get_event(hal->dev, event);
44 }
45