Lines Matching refs:i2c_num

140     int i2c_num;                     /*!< I2C port number */  member
210 static void IRAM_ATTR i2c_master_cmd_begin_static(i2c_port_t i2c_num);
211 static esp_err_t IRAM_ATTR i2c_hw_fsm_reset(i2c_port_t i2c_num);
213 static void i2c_hw_disable(i2c_port_t i2c_num) in i2c_hw_disable() argument
215 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_hw_disable()
216 if (i2c_context[i2c_num].hw_enabled != false) { in i2c_hw_disable()
217 periph_module_disable(i2c_periph_signal[i2c_num].module); in i2c_hw_disable()
218 i2c_context[i2c_num].hw_enabled = false; in i2c_hw_disable()
220 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_hw_disable()
223 static void i2c_hw_enable(i2c_port_t i2c_num) in i2c_hw_enable() argument
225 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_hw_enable()
226 if (i2c_context[i2c_num].hw_enabled != true) { in i2c_hw_enable()
227 periph_module_enable(i2c_periph_signal[i2c_num].module); in i2c_hw_enable()
228 i2c_context[i2c_num].hw_enabled = true; in i2c_hw_enable()
230 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_hw_enable()
240 esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_buf_len, size_t slv… in i2c_driver_install() argument
243 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_driver_install()
246 if (p_i2c_obj[i2c_num] == NULL) { in i2c_driver_install()
249 p_i2c_obj[i2c_num] = (i2c_obj_t *) calloc(1, sizeof(i2c_obj_t)); in i2c_driver_install()
252 p_i2c_obj[i2c_num] = (i2c_obj_t *) calloc(1, sizeof(i2c_obj_t)); in i2c_driver_install()
254 …p_i2c_obj[i2c_num] = (i2c_obj_t *) heap_caps_calloc(1, sizeof(i2c_obj_t), MALLOC_CAP_INTERNAL | MA… in i2c_driver_install()
257 if (p_i2c_obj[i2c_num] == NULL) { in i2c_driver_install()
261 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_driver_install()
262 p_i2c->i2c_num = i2c_num; in i2c_driver_install()
344 i2c_hw_enable(i2c_num); in i2c_driver_install()
346 i2c_hal_disable_intr_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_driver_install()
347 i2c_hal_clr_intsts_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_driver_install()
349 …i2c_isr_register(i2c_num, i2c_isr_handler_default, p_i2c_obj[i2c_num], intr_alloc_flags, &p_i2c_ob… in i2c_driver_install()
352 i2c_hal_enable_slave_rx_it(&(i2c_context[i2c_num].hal)); in i2c_driver_install()
358 if (p_i2c_obj[i2c_num]) { in i2c_driver_install()
359 if (p_i2c_obj[i2c_num]->rx_ring_buf) { in i2c_driver_install()
360 vRingbufferDelete(p_i2c_obj[i2c_num]->rx_ring_buf); in i2c_driver_install()
361 p_i2c_obj[i2c_num]->rx_ring_buf = NULL; in i2c_driver_install()
362 p_i2c_obj[i2c_num]->rx_buf_length = 0; in i2c_driver_install()
364 if (p_i2c_obj[i2c_num]->tx_ring_buf) { in i2c_driver_install()
365 vRingbufferDelete(p_i2c_obj[i2c_num]->tx_ring_buf); in i2c_driver_install()
366 p_i2c_obj[i2c_num]->tx_ring_buf = NULL; in i2c_driver_install()
367 p_i2c_obj[i2c_num]->tx_buf_length = 0; in i2c_driver_install()
369 if (p_i2c_obj[i2c_num]->cmd_evt_queue) { in i2c_driver_install()
370 vQueueDelete(p_i2c_obj[i2c_num]->cmd_evt_queue); in i2c_driver_install()
371 p_i2c_obj[i2c_num]->cmd_evt_queue = NULL; in i2c_driver_install()
373 if (p_i2c_obj[i2c_num]->cmd_mux) { in i2c_driver_install()
374 vSemaphoreDelete(p_i2c_obj[i2c_num]->cmd_mux); in i2c_driver_install()
376 if (p_i2c_obj[i2c_num]->slv_rx_mux) { in i2c_driver_install()
377 vSemaphoreDelete(p_i2c_obj[i2c_num]->slv_rx_mux); in i2c_driver_install()
379 if (p_i2c_obj[i2c_num]->slv_tx_mux) { in i2c_driver_install()
380 vSemaphoreDelete(p_i2c_obj[i2c_num]->slv_tx_mux); in i2c_driver_install()
383 if (p_i2c_obj[i2c_num]->pm_lock) { in i2c_driver_install()
384 esp_pm_lock_delete(p_i2c_obj[i2c_num]->pm_lock); in i2c_driver_install()
385 p_i2c_obj[i2c_num]->pm_lock = NULL; in i2c_driver_install()
389 if (p_i2c_obj[i2c_num]->evt_queue_storage) { in i2c_driver_install()
390 free(p_i2c_obj[i2c_num]->evt_queue_storage); in i2c_driver_install()
391 p_i2c_obj[i2c_num]->evt_queue_storage = NULL; in i2c_driver_install()
395 free(p_i2c_obj[i2c_num]); in i2c_driver_install()
396 p_i2c_obj[i2c_num] = NULL; in i2c_driver_install()
400 esp_err_t i2c_driver_delete(i2c_port_t i2c_num) in i2c_driver_delete() argument
402 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_driver_delete()
403 ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num] != NULL, ESP_FAIL, I2C_TAG, I2C_DRIVER_ERR_STR); in i2c_driver_delete()
405 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_driver_delete()
406 i2c_hal_disable_intr_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_driver_delete()
416 if (p_i2c_obj[i2c_num]->cmd_evt_queue) { in i2c_driver_delete()
417 vQueueDelete(p_i2c_obj[i2c_num]->cmd_evt_queue); in i2c_driver_delete()
418 p_i2c_obj[i2c_num]->cmd_evt_queue = NULL; in i2c_driver_delete()
444 if (p_i2c_obj[i2c_num]->evt_queue_storage) { in i2c_driver_delete()
445 free(p_i2c_obj[i2c_num]->evt_queue_storage); in i2c_driver_delete()
446 p_i2c_obj[i2c_num]->evt_queue_storage = NULL; in i2c_driver_delete()
450 free(p_i2c_obj[i2c_num]); in i2c_driver_delete()
451 p_i2c_obj[i2c_num] = NULL; in i2c_driver_delete()
453 i2c_hw_disable(i2c_num); in i2c_driver_delete()
457 esp_err_t i2c_reset_tx_fifo(i2c_port_t i2c_num) in i2c_reset_tx_fifo() argument
459 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_reset_tx_fifo()
460 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_reset_tx_fifo()
461 i2c_hal_txfifo_rst(&(i2c_context[i2c_num].hal)); in i2c_reset_tx_fifo()
462 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_reset_tx_fifo()
466 esp_err_t i2c_reset_rx_fifo(i2c_port_t i2c_num) in i2c_reset_rx_fifo() argument
468 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_reset_rx_fifo()
469 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_reset_rx_fifo()
470 i2c_hal_rxfifo_rst(&(i2c_context[i2c_num].hal)); in i2c_reset_rx_fifo()
471 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_reset_rx_fifo()
478 int i2c_num = p_i2c->i2c_num; in i2c_isr_handler_default() local
483 i2c_hal_master_handle_tx_event(&(i2c_context[i2c_num].hal), &evt_type); in i2c_isr_handler_default()
485 i2c_hal_master_handle_rx_event(&(i2c_context[i2c_num].hal), &evt_type); in i2c_isr_handler_default()
488 p_i2c_obj[i2c_num]->status = I2C_STATUS_ACK_ERROR; in i2c_isr_handler_default()
489 i2c_master_cmd_begin_static(i2c_num); in i2c_isr_handler_default()
491 p_i2c_obj[i2c_num]->status = I2C_STATUS_TIMEOUT; in i2c_isr_handler_default()
492 i2c_master_cmd_begin_static(i2c_num); in i2c_isr_handler_default()
494 p_i2c_obj[i2c_num]->status = I2C_STATUS_TIMEOUT; in i2c_isr_handler_default()
495 i2c_master_cmd_begin_static(i2c_num); in i2c_isr_handler_default()
497 i2c_master_cmd_begin_static(i2c_num); in i2c_isr_handler_default()
500 i2c_master_cmd_begin_static(i2c_num); in i2c_isr_handler_default()
508 i2c_hal_slave_handle_event(&(i2c_context[i2c_num].hal), &evt_type); in i2c_isr_handler_default()
511 i2c_hal_get_rxfifo_cnt(&(i2c_context[i2c_num].hal), &rx_fifo_cnt); in i2c_isr_handler_default()
512 i2c_hal_read_rxfifo(&(i2c_context[i2c_num].hal), p_i2c->data_buf, rx_fifo_cnt); in i2c_isr_handler_default()
514 i2c_hal_slave_clr_rx_it(&(i2c_context[i2c_num].hal)); in i2c_isr_handler_default()
517 i2c_hal_get_txfifo_cnt(&(i2c_context[i2c_num].hal), &tx_fifo_rem); in i2c_isr_handler_default()
521 i2c_hal_write_txfifo(&(i2c_context[i2c_num].hal), data, size); in i2c_isr_handler_default()
524 i2c_hal_disable_slave_tx_it(&(i2c_context[i2c_num].hal)); in i2c_isr_handler_default()
526 i2c_hal_slave_clr_tx_it(&(i2c_context[i2c_num].hal)); in i2c_isr_handler_default()
535 esp_err_t i2c_set_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t tx_trans_mode, i2c_trans_mode_t rx… in i2c_set_data_mode() argument
537 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_data_mode()
540 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_data_mode()
541 i2c_hal_set_data_mode(&(i2c_context[i2c_num].hal), tx_trans_mode, rx_trans_mode); in i2c_set_data_mode()
542 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_set_data_mode()
543 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_data_mode()
547 esp_err_t i2c_get_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t *tx_trans_mode, i2c_trans_mode_t *… in i2c_get_data_mode() argument
549 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_get_data_mode()
550 i2c_hal_get_data_mode(&(i2c_context[i2c_num].hal), tx_trans_mode, rx_trans_mode); in i2c_get_data_mode()
559 static esp_err_t i2c_master_clear_bus(i2c_port_t i2c_num) in i2c_master_clear_bus() argument
564 int scl_io = i2c_context[i2c_num].scl_io_num; in i2c_master_clear_bus()
565 int sda_io = i2c_context[i2c_num].sda_io_num; in i2c_master_clear_bus()
586 i2c_set_pin(i2c_num, sda_io, scl_io, 1, 1, I2C_MODE_MASTER); in i2c_master_clear_bus()
588 i2c_hal_master_clr_bus(&(i2c_context[i2c_num].hal)); in i2c_master_clear_bus()
597 static esp_err_t i2c_hw_fsm_reset(i2c_port_t i2c_num) in i2c_hw_fsm_reset() argument
607 i2c_hal_get_scl_timing(&(i2c_context[i2c_num].hal), &scl_high_period, &scl_low_period); in i2c_hw_fsm_reset()
608 i2c_hal_get_start_timing(&(i2c_context[i2c_num].hal), &scl_rstart_setup, &scl_start_hold); in i2c_hw_fsm_reset()
609 i2c_hal_get_stop_timing(&(i2c_context[i2c_num].hal), &scl_stop_setup, &scl_stop_hold); in i2c_hw_fsm_reset()
610 i2c_hal_get_sda_timing(&(i2c_context[i2c_num].hal), &sda_sample, &sda_hold); in i2c_hw_fsm_reset()
611 i2c_hal_get_tout(&(i2c_context[i2c_num].hal), &timeout); in i2c_hw_fsm_reset()
612 i2c_hal_get_filter(&(i2c_context[i2c_num].hal), &filter_cfg); in i2c_hw_fsm_reset()
615 i2c_hw_disable(i2c_num); in i2c_hw_fsm_reset()
616 i2c_master_clear_bus(i2c_num); in i2c_hw_fsm_reset()
617 i2c_hw_enable(i2c_num); in i2c_hw_fsm_reset()
619 i2c_hal_master_init(&(i2c_context[i2c_num].hal), i2c_num); in i2c_hw_fsm_reset()
620 i2c_hal_disable_intr_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_hw_fsm_reset()
621 i2c_hal_clr_intsts_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_hw_fsm_reset()
622 i2c_hal_set_scl_timing(&(i2c_context[i2c_num].hal), scl_high_period, scl_low_period); in i2c_hw_fsm_reset()
623 i2c_hal_set_start_timing(&(i2c_context[i2c_num].hal), scl_rstart_setup, scl_start_hold); in i2c_hw_fsm_reset()
624 i2c_hal_set_stop_timing(&(i2c_context[i2c_num].hal), scl_stop_setup, scl_stop_hold); in i2c_hw_fsm_reset()
625 i2c_hal_set_sda_timing(&(i2c_context[i2c_num].hal), sda_sample, sda_hold); in i2c_hw_fsm_reset()
626 i2c_hal_set_tout(&(i2c_context[i2c_num].hal), timeout); in i2c_hw_fsm_reset()
627 i2c_hal_set_filter(&(i2c_context[i2c_num].hal), filter_cfg); in i2c_hw_fsm_reset()
629 i2c_hal_master_fsm_rst(&(i2c_context[i2c_num].hal)); in i2c_hw_fsm_reset()
630 i2c_master_clear_bus(i2c_num); in i2c_hw_fsm_reset()
651 esp_err_t i2c_param_config(i2c_port_t i2c_num, const i2c_config_t *i2c_conf) in i2c_param_config() argument
656 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_param_config()
675 ret = i2c_set_pin(i2c_num, i2c_conf->sda_io_num, i2c_conf->scl_io_num, in i2c_param_config()
680 i2c_hw_enable(i2c_num); in i2c_param_config()
681 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_param_config()
682 i2c_hal_disable_intr_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_param_config()
683 i2c_hal_clr_intsts_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_param_config()
685 i2c_hal_slave_init(&(i2c_context[i2c_num].hal), i2c_num); in i2c_param_config()
686 i2c_hal_set_source_clk(&(i2c_context[i2c_num].hal), src_clk); in i2c_param_config()
687 …i2c_hal_set_slave_addr(&(i2c_context[i2c_num].hal), i2c_conf->slave.slave_addr, i2c_conf->slave.ad… in i2c_param_config()
688 i2c_hal_set_rxfifo_full_thr(&(i2c_context[i2c_num].hal), I2C_FIFO_FULL_THRESH_VAL); in i2c_param_config()
689 i2c_hal_set_txfifo_empty_thr(&(i2c_context[i2c_num].hal), I2C_FIFO_EMPTY_THRESH_VAL); in i2c_param_config()
691 …i2c_hal_set_sda_timing(&(i2c_context[i2c_num].hal), I2C_SLAVE_SDA_SAMPLE_DEFAULT, I2C_SLAVE_SDA_HO… in i2c_param_config()
692 i2c_hal_set_tout(&(i2c_context[i2c_num].hal), I2C_SLAVE_TIMEOUT_DEFAULT); in i2c_param_config()
693 i2c_hal_enable_slave_rx_it(&(i2c_context[i2c_num].hal)); in i2c_param_config()
695 i2c_hal_master_init(&(i2c_context[i2c_num].hal), i2c_num); in i2c_param_config()
697 i2c_hal_set_filter(&(i2c_context[i2c_num].hal), I2C_FILTER_CYC_NUM_DEF); in i2c_param_config()
698 i2c_hal_set_bus_timing(&(i2c_context[i2c_num].hal), i2c_conf->master.clk_speed, src_clk); in i2c_param_config()
700 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_param_config()
701 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_param_config()
705 esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period) in i2c_set_period() argument
707 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_period()
711 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_period()
712 i2c_hal_set_scl_timing(&(i2c_context[i2c_num].hal), high_period, low_period); in i2c_set_period()
713 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_set_period()
714 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_period()
718 esp_err_t i2c_get_period(i2c_port_t i2c_num, int *high_period, int *low_period) in i2c_get_period() argument
720 …ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX && high_period != NULL && low_period != NULL, ESP_ERR_IN… in i2c_get_period()
721 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_period()
722 i2c_hal_get_scl_timing(&(i2c_context[i2c_num].hal), high_period, low_period); in i2c_get_period()
723 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_period()
727 esp_err_t i2c_filter_enable(i2c_port_t i2c_num, uint8_t cyc_num) in i2c_filter_enable() argument
729 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_filter_enable()
730 ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num] != NULL, ESP_FAIL, I2C_TAG, I2C_DRIVER_ERR_STR); in i2c_filter_enable()
731 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_filter_enable()
732 i2c_hal_set_filter(&(i2c_context[i2c_num].hal), cyc_num); in i2c_filter_enable()
733 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_filter_enable()
734 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_filter_enable()
738 esp_err_t i2c_filter_disable(i2c_port_t i2c_num) in i2c_filter_disable() argument
740 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_filter_disable()
741 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_filter_disable()
742 i2c_hal_set_filter(&(i2c_context[i2c_num].hal), 0); in i2c_filter_disable()
743 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_filter_disable()
744 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_filter_disable()
748 esp_err_t i2c_set_start_timing(i2c_port_t i2c_num, int setup_time, int hold_time) in i2c_set_start_timing() argument
750 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_start_timing()
754 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_start_timing()
755 i2c_hal_set_start_timing(&(i2c_context[i2c_num].hal), setup_time, hold_time); in i2c_set_start_timing()
756 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_set_start_timing()
757 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_start_timing()
761 esp_err_t i2c_get_start_timing(i2c_port_t i2c_num, int *setup_time, int *hold_time) in i2c_get_start_timing() argument
763 …ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX && setup_time != NULL && hold_time != NULL, ESP_ERR_INVA… in i2c_get_start_timing()
764 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_start_timing()
765 i2c_hal_get_start_timing(&(i2c_context[i2c_num].hal), setup_time, hold_time); in i2c_get_start_timing()
766 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_start_timing()
770 esp_err_t i2c_set_stop_timing(i2c_port_t i2c_num, int setup_time, int hold_time) in i2c_set_stop_timing() argument
772 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_stop_timing()
776 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_stop_timing()
777 i2c_hal_set_stop_timing(&(i2c_context[i2c_num].hal), setup_time, hold_time); in i2c_set_stop_timing()
778 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_set_stop_timing()
779 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_stop_timing()
783 esp_err_t i2c_get_stop_timing(i2c_port_t i2c_num, int *setup_time, int *hold_time) in i2c_get_stop_timing() argument
785 …ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX && setup_time != NULL && hold_time != NULL, ESP_ERR_INVA… in i2c_get_stop_timing()
786 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_stop_timing()
787 i2c_hal_get_stop_timing(&(i2c_context[i2c_num].hal), setup_time, hold_time); in i2c_get_stop_timing()
788 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_stop_timing()
792 esp_err_t i2c_set_data_timing(i2c_port_t i2c_num, int sample_time, int hold_time) in i2c_set_data_timing() argument
794 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_data_timing()
798 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_data_timing()
799 i2c_hal_set_sda_timing(&(i2c_context[i2c_num].hal), sample_time, hold_time); in i2c_set_data_timing()
800 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_set_data_timing()
801 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_data_timing()
805 esp_err_t i2c_get_data_timing(i2c_port_t i2c_num, int *sample_time, int *hold_time) in i2c_get_data_timing() argument
807 …ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX && sample_time != NULL && hold_time != NULL, ESP_ERR_INV… in i2c_get_data_timing()
808 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_data_timing()
809 i2c_hal_get_sda_timing(&(i2c_context[i2c_num].hal), sample_time, hold_time); in i2c_get_data_timing()
810 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_get_data_timing()
814 esp_err_t i2c_set_timeout(i2c_port_t i2c_num, int timeout) in i2c_set_timeout() argument
816 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_timeout()
819 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_timeout()
820 i2c_hal_set_tout(&(i2c_context[i2c_num].hal), timeout); in i2c_set_timeout()
821 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_set_timeout()
825 esp_err_t i2c_get_timeout(i2c_port_t i2c_num, int *timeout) in i2c_get_timeout() argument
827 …ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX && timeout != NULL, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NU… in i2c_get_timeout()
828 i2c_hal_get_tout(&(i2c_context[i2c_num].hal), timeout); in i2c_get_timeout()
832 esp_err_t i2c_isr_register(i2c_port_t i2c_num, void (*fn)(void *), void *arg, int intr_alloc_flags,… in i2c_isr_register() argument
834 ESP_RETURN_ON_FALSE(i2c_num < I2C_NUM_MAX, ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_isr_register()
836 … esp_err_t ret = esp_intr_alloc(i2c_periph_signal[i2c_num].irq, intr_alloc_flags, fn, arg, handle); in i2c_isr_register()
845 esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num, bool sda_pullup_en, bool … in i2c_set_pin() argument
847 ESP_RETURN_ON_FALSE(( i2c_num < I2C_NUM_MAX ), ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_set_pin()
863 sda_out_sig = i2c_periph_signal[i2c_num].sda_out_sig; in i2c_set_pin()
864 sda_in_sig = i2c_periph_signal[i2c_num].sda_in_sig; in i2c_set_pin()
865 scl_out_sig = i2c_periph_signal[i2c_num].scl_out_sig; in i2c_set_pin()
866 scl_in_sig = i2c_periph_signal[i2c_num].scl_in_sig; in i2c_set_pin()
893 i2c_context[i2c_num].scl_io_num = scl_io_num; in i2c_set_pin()
894 i2c_context[i2c_num].sda_io_num = sda_io_num; in i2c_set_pin()
899 esp_err_t i2c_master_write_to_device(i2c_port_t i2c_num, uint8_t device_address, in i2c_master_write_to_device() argument
925 err = i2c_master_cmd_begin(i2c_num, handle, ticks_to_wait); in i2c_master_write_to_device()
933 esp_err_t i2c_master_read_from_device(i2c_port_t i2c_num, uint8_t device_address, in i2c_master_read_from_device() argument
959 err = i2c_master_cmd_begin(i2c_num, handle, ticks_to_wait); in i2c_master_read_from_device()
967 esp_err_t i2c_master_write_read_device(i2c_port_t i2c_num, uint8_t device_address, in i2c_master_write_read_device() argument
1009 err = i2c_master_cmd_begin(i2c_num, handle, ticks_to_wait); in i2c_master_write_read_device()
1273 static void IRAM_ATTR i2c_master_cmd_begin_static(i2c_port_t i2c_num) in i2c_master_cmd_begin_static() argument
1275 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_master_cmd_begin_static()
1280 … i2c_hal_read_rxfifo(&(i2c_context[i2c_num].hal), cmd->data + cmd->bytes_used, p_i2c->rx_cnt); in i2c_master_cmd_begin_static()
1338 i2c_hal_write_txfifo(&(i2c_context[i2c_num].hal), write_pr, fifo_fill); in i2c_master_cmd_begin_static()
1339 i2c_hal_write_cmd_reg(&(i2c_context[i2c_num].hal), hw_cmd, p_i2c->cmd_idx); in i2c_master_cmd_begin_static()
1340 i2c_hal_write_cmd_reg(&(i2c_context[i2c_num].hal), hw_end_cmd, p_i2c->cmd_idx + 1); in i2c_master_cmd_begin_static()
1341 i2c_hal_enable_master_tx_it(&(i2c_context[i2c_num].hal)); in i2c_master_cmd_begin_static()
1356 i2c_hal_write_cmd_reg(&(i2c_context[i2c_num].hal), hw_cmd, p_i2c->cmd_idx); in i2c_master_cmd_begin_static()
1357 i2c_hal_write_cmd_reg(&(i2c_context[i2c_num].hal), hw_end_cmd, p_i2c->cmd_idx + 1); in i2c_master_cmd_begin_static()
1358 i2c_hal_enable_master_rx_it(&(i2c_context[i2c_num].hal)); in i2c_master_cmd_begin_static()
1362 i2c_hal_write_cmd_reg(&(i2c_context[i2c_num].hal), hw_cmd, p_i2c->cmd_idx); in i2c_master_cmd_begin_static()
1371 i2c_hal_update_config(&(i2c_context[i2c_num].hal)); in i2c_master_cmd_begin_static()
1372 i2c_hal_trans_start(&(i2c_context[i2c_num].hal)); in i2c_master_cmd_begin_static()
1395 esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, TickType_t ticks_to… in i2c_master_cmd_begin() argument
1397 ESP_RETURN_ON_FALSE(( i2c_num < I2C_NUM_MAX ), ESP_ERR_INVALID_ARG, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_master_cmd_begin()
1398 …ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num] != NULL, ESP_ERR_INVALID_STATE, I2C_TAG, I2C_DRIVER_NOT_INS… in i2c_master_cmd_begin()
1399 …ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num]->mode == I2C_MODE_MASTER, ESP_ERR_INVALID_STATE, I2C_TAG, I… in i2c_master_cmd_begin()
1405 if ( (p_i2c_obj[i2c_num]->intr_alloc_flags & ESP_INTR_FLAG_IRAM) && in i2c_master_cmd_begin()
1414 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_master_cmd_begin()
1425 || i2c_hal_is_bus_busy(&(i2c_context[i2c_num].hal))) { in i2c_master_cmd_begin()
1426 i2c_hw_fsm_reset(i2c_num); in i2c_master_cmd_begin()
1429 i2c_reset_tx_fifo(i2c_num); in i2c_master_cmd_begin()
1430 i2c_reset_rx_fifo(i2c_num); in i2c_master_cmd_begin()
1442 i2c_reset_tx_fifo(i2c_num); in i2c_master_cmd_begin()
1443 i2c_reset_rx_fifo(i2c_num); in i2c_master_cmd_begin()
1446 i2c_hal_disable_intr_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_master_cmd_begin()
1447 i2c_hal_clr_intsts_mask(&(i2c_context[i2c_num].hal), I2C_LL_INTR_MASK); in i2c_master_cmd_begin()
1449 i2c_master_cmd_begin_static(i2c_num); in i2c_master_cmd_begin()
1472 i2c_hw_fsm_reset(i2c_num); in i2c_master_cmd_begin()
1492 i2c_hw_fsm_reset(i2c_num); in i2c_master_cmd_begin()
1505 int i2c_slave_write_buffer(i2c_port_t i2c_num, const uint8_t *data, int size, TickType_t ticks_to_w… in i2c_slave_write_buffer() argument
1507 ESP_RETURN_ON_FALSE(( i2c_num < I2C_NUM_MAX ), ESP_FAIL, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_slave_write_buffer()
1508 ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num] != NULL, ESP_FAIL, I2C_TAG, I2C_DRIVER_ERR_STR); in i2c_slave_write_buffer()
1510 …ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num]->mode == I2C_MODE_SLAVE, ESP_FAIL, I2C_TAG, I2C_MODE_SLAVE_… in i2c_slave_write_buffer()
1511 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_slave_write_buffer()
1526 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_slave_write_buffer()
1527 i2c_hal_enable_slave_tx_it(&(i2c_context[i2c_num].hal)); in i2c_slave_write_buffer()
1528 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_slave_write_buffer()
1535 int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t *data, size_t max_size, TickType_t ticks_to_w… in i2c_slave_read_buffer() argument
1537 ESP_RETURN_ON_FALSE(( i2c_num < I2C_NUM_MAX ), ESP_FAIL, I2C_TAG, I2C_NUM_ERROR_STR); in i2c_slave_read_buffer()
1538 ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num] != NULL, ESP_FAIL, I2C_TAG, I2C_DRIVER_ERR_STR); in i2c_slave_read_buffer()
1540 …ESP_RETURN_ON_FALSE(p_i2c_obj[i2c_num]->mode == I2C_MODE_SLAVE, ESP_FAIL, I2C_TAG, I2C_MODE_SLAVE_… in i2c_slave_read_buffer()
1544 i2c_obj_t *p_i2c = p_i2c_obj[i2c_num]; in i2c_slave_read_buffer()
1550 I2C_ENTER_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_slave_read_buffer()
1551 i2c_hal_enable_slave_rx_it(&(i2c_context[i2c_num].hal)); in i2c_slave_read_buffer()
1552 I2C_EXIT_CRITICAL(&(i2c_context[i2c_num].spinlock)); in i2c_slave_read_buffer()