@@ -933,13 +933,13 @@ esp_err_t i2c_del_master_bus(i2c_master_bus_handle_t bus_handle)
933
933
return ESP_OK ;
934
934
}
935
935
936
- esp_err_t i2c_master_bus_reset (i2c_master_bus_handle_t handle )
936
+ esp_err_t i2c_master_bus_reset (i2c_master_bus_handle_t bus_handle )
937
937
{
938
- ESP_RETURN_ON_FALSE ((handle != NULL ), ESP_ERR_INVALID_ARG , TAG , "This bus is not initialized" );
938
+ ESP_RETURN_ON_FALSE ((bus_handle != NULL ), ESP_ERR_INVALID_ARG , TAG , "This bus is not initialized" );
939
939
// Reset I2C master bus
940
- ESP_RETURN_ON_ERROR (s_i2c_hw_fsm_reset (handle ), TAG , "I2C master bus reset failed" );
940
+ ESP_RETURN_ON_ERROR (s_i2c_hw_fsm_reset (bus_handle ), TAG , "I2C master bus reset failed" );
941
941
// Reset I2C status state
942
- atomic_store (& handle -> status , I2C_STATUS_IDLE );
942
+ atomic_store (& bus_handle -> status , I2C_STATUS_IDLE );
943
943
return ESP_OK ;
944
944
}
945
945
@@ -1022,24 +1022,24 @@ esp_err_t i2c_master_receive(i2c_master_dev_handle_t i2c_dev, uint8_t *read_buff
1022
1022
return ESP_OK ;
1023
1023
}
1024
1024
1025
- esp_err_t i2c_master_probe (i2c_master_bus_handle_t i2c_master , uint16_t address , int xfer_timeout_ms )
1025
+ esp_err_t i2c_master_probe (i2c_master_bus_handle_t bus_handle , uint16_t address , int xfer_timeout_ms )
1026
1026
{
1027
- ESP_RETURN_ON_FALSE (i2c_master != NULL , ESP_ERR_INVALID_ARG , TAG , "i2c handle not initialized" );
1027
+ ESP_RETURN_ON_FALSE (bus_handle != NULL , ESP_ERR_INVALID_ARG , TAG , "i2c handle not initialized" );
1028
1028
TickType_t ticks_to_wait = (xfer_timeout_ms == -1 ) ? portMAX_DELAY : pdMS_TO_TICKS (xfer_timeout_ms );
1029
- if (xSemaphoreTake (i2c_master -> bus_lock_mux , ticks_to_wait ) != pdTRUE ) {
1029
+ if (xSemaphoreTake (bus_handle -> bus_lock_mux , ticks_to_wait ) != pdTRUE ) {
1030
1030
return ESP_ERR_TIMEOUT ;
1031
1031
}
1032
1032
1033
- i2c_master -> cmd_idx = 0 ;
1034
- i2c_master -> trans_idx = 0 ;
1035
- i2c_master -> trans_done = false;
1036
- i2c_hal_context_t * hal = & i2c_master -> base -> hal ;
1033
+ bus_handle -> cmd_idx = 0 ;
1034
+ bus_handle -> trans_idx = 0 ;
1035
+ bus_handle -> trans_done = false;
1036
+ i2c_hal_context_t * hal = & bus_handle -> base -> hal ;
1037
1037
i2c_operation_t i2c_ops [] = {
1038
1038
{.hw_cmd = I2C_TRANS_START_COMMAND },
1039
1039
{.hw_cmd = I2C_TRANS_STOP_COMMAND },
1040
1040
};
1041
1041
1042
- i2c_master -> i2c_trans = (i2c_transaction_t ) {
1042
+ bus_handle -> i2c_trans = (i2c_transaction_t ) {
1043
1043
.device_address = address ,
1044
1044
.ops = i2c_ops ,
1045
1045
.cmd_count = DIM (i2c_ops ),
@@ -1048,20 +1048,20 @@ esp_err_t i2c_master_probe(i2c_master_bus_handle_t i2c_master, uint16_t address,
1048
1048
// I2C probe does not have i2c device module. So set the clock parameter independently
1049
1049
// This will not influence device transaction.
1050
1050
I2C_CLOCK_SRC_ATOMIC () {
1051
- i2c_ll_set_source_clk (hal -> dev , i2c_master -> base -> clk_src );
1052
- i2c_hal_set_bus_timing (hal , 100000 , i2c_master -> base -> clk_src , i2c_master -> base -> clk_src_freq_hz );
1051
+ i2c_ll_set_source_clk (hal -> dev , bus_handle -> base -> clk_src );
1052
+ i2c_hal_set_bus_timing (hal , 100000 , bus_handle -> base -> clk_src , bus_handle -> base -> clk_src_freq_hz );
1053
1053
}
1054
1054
i2c_ll_master_set_fractional_divider (hal -> dev , 0 , 0 );
1055
1055
i2c_ll_update (hal -> dev );
1056
1056
1057
- s_i2c_send_commands (i2c_master , ticks_to_wait );
1058
- if (i2c_master -> status == I2C_STATUS_ACK_ERROR ) {
1057
+ s_i2c_send_commands (bus_handle , ticks_to_wait );
1058
+ if (bus_handle -> status == I2C_STATUS_ACK_ERROR ) {
1059
1059
// Reset the status to done, in order not influence next time transaction.
1060
- i2c_master -> status = I2C_STATUS_DONE ;
1061
- xSemaphoreGive (i2c_master -> bus_lock_mux );
1060
+ bus_handle -> status = I2C_STATUS_DONE ;
1061
+ xSemaphoreGive (bus_handle -> bus_lock_mux );
1062
1062
return ESP_ERR_NOT_FOUND ;
1063
1063
}
1064
- xSemaphoreGive (i2c_master -> bus_lock_mux );
1064
+ xSemaphoreGive (bus_handle -> bus_lock_mux );
1065
1065
return ESP_OK ;
1066
1066
}
1067
1067
@@ -1088,19 +1088,19 @@ esp_err_t i2c_master_register_event_callbacks(i2c_master_dev_handle_t i2c_dev, c
1088
1088
return ESP_OK ;
1089
1089
}
1090
1090
1091
- esp_err_t i2c_master_wait_all_done (i2c_master_bus_handle_t i2c_master , int timeout_ms )
1091
+ esp_err_t i2c_master_bus_wait_all_done (i2c_master_bus_handle_t bus_handle , int timeout_ms )
1092
1092
{
1093
- ESP_RETURN_ON_FALSE (i2c_master , ESP_ERR_INVALID_ARG , TAG , "invalid argument" );
1093
+ ESP_RETURN_ON_FALSE (bus_handle , ESP_ERR_INVALID_ARG , TAG , "invalid argument" );
1094
1094
TickType_t wait_ticks = timeout_ms < 0 ? portMAX_DELAY : pdMS_TO_TICKS (timeout_ms );
1095
1095
i2c_transaction_t t ;
1096
1096
1097
- size_t cnt = i2c_master -> num_trans_inflight ;
1097
+ size_t cnt = bus_handle -> num_trans_inflight ;
1098
1098
for (size_t i = 0 ; i < cnt ; i ++ ) {
1099
- ESP_RETURN_ON_FALSE (xQueueReceive (i2c_master -> trans_queues [I2C_TRANS_QUEUE_COMPLETE ], & t , wait_ticks ) == pdTRUE ,
1099
+ ESP_RETURN_ON_FALSE (xQueueReceive (bus_handle -> trans_queues [I2C_TRANS_QUEUE_COMPLETE ], & t , wait_ticks ) == pdTRUE ,
1100
1100
ESP_ERR_TIMEOUT , TAG , "flush timeout" );
1101
- ESP_RETURN_ON_FALSE (xQueueSend (i2c_master -> trans_queues [I2C_TRANS_QUEUE_READY ], & t , 0 ) == pdTRUE ,
1101
+ ESP_RETURN_ON_FALSE (xQueueSend (bus_handle -> trans_queues [I2C_TRANS_QUEUE_READY ], & t , 0 ) == pdTRUE ,
1102
1102
ESP_ERR_INVALID_STATE , TAG , "ready queue full" );
1103
- i2c_master -> num_trans_inflight -- ;
1103
+ bus_handle -> num_trans_inflight -- ;
1104
1104
}
1105
1105
return ESP_OK ;
1106
1106
0 commit comments