i2c.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. // Copyright 2015-2016 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef _DRIVER_I2C_H_
  14. #define _DRIVER_I2C_H_
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include <esp_types.h>
  19. #include "esp_err.h"
  20. #include "esp_intr_alloc.h"
  21. #include "freertos/FreeRTOS.h"
  22. #include "freertos/semphr.h"
  23. #include "freertos/xtensa_api.h"
  24. #include "freertos/task.h"
  25. #include "freertos/queue.h"
  26. #include "freertos/ringbuf.h"
  27. #include "driver/gpio.h"
  28. #define I2C_APB_CLK_FREQ APB_CLK_FREQ /*!< I2C source clock is APB clock, 80MHz */
  29. #define I2C_FIFO_LEN (32) /*!< I2C hardware fifo length */
  30. typedef enum{
  31. I2C_MODE_SLAVE = 0, /*!< I2C slave mode */
  32. I2C_MODE_MASTER, /*!< I2C master mode */
  33. I2C_MODE_MAX,
  34. }i2c_mode_t;
  35. typedef enum {
  36. I2C_MASTER_WRITE = 0, /*!< I2C write data */
  37. I2C_MASTER_READ, /*!< I2C read data */
  38. } i2c_rw_t;
  39. typedef enum {
  40. I2C_DATA_MODE_MSB_FIRST = 0, /*!< I2C data msb first */
  41. I2C_DATA_MODE_LSB_FIRST = 1, /*!< I2C data lsb first */
  42. I2C_DATA_MODE_MAX
  43. } i2c_trans_mode_t;
  44. typedef enum{
  45. I2C_CMD_RESTART = 0, /*!<I2C restart command */
  46. I2C_CMD_WRITE, /*!<I2C write command */
  47. I2C_CMD_READ, /*!<I2C read command */
  48. I2C_CMD_STOP, /*!<I2C stop command */
  49. I2C_CMD_END /*!<I2C end command */
  50. }i2c_opmode_t;
  51. typedef enum{
  52. I2C_NUM_0 = 0, /*!< I2C port 0 */
  53. I2C_NUM_1 , /*!< I2C port 1 */
  54. I2C_NUM_MAX
  55. } i2c_port_t;
  56. typedef enum {
  57. I2C_ADDR_BIT_7 = 0, /*!< I2C 7bit address for slave mode */
  58. I2C_ADDR_BIT_10, /*!< I2C 10bit address for slave mode */
  59. I2C_ADDR_BIT_MAX,
  60. } i2c_addr_mode_t;
  61. typedef enum {
  62. I2C_MASTER_ACK = 0x0, /*!< I2C ack for each byte read */
  63. I2C_MASTER_NACK = 0x1, /*!< I2C nack for each byte read */
  64. I2C_MASTER_LAST_NACK = 0x2, /*!< I2C nack for the last byte*/
  65. I2C_MASTER_ACK_MAX,
  66. } i2c_ack_type_t;
  67. /**
  68. * @brief I2C initialization parameters
  69. */
  70. typedef struct{
  71. i2c_mode_t mode; /*!< I2C mode */
  72. gpio_num_t sda_io_num; /*!< GPIO number for I2C sda signal */
  73. gpio_pullup_t sda_pullup_en; /*!< Internal GPIO pull mode for I2C sda signal*/
  74. gpio_num_t scl_io_num; /*!< GPIO number for I2C scl signal */
  75. gpio_pullup_t scl_pullup_en; /*!< Internal GPIO pull mode for I2C scl signal*/
  76. union {
  77. struct {
  78. uint32_t clk_speed; /*!< I2C clock frequency for master mode, (no higher than 1MHz for now) */
  79. } master;
  80. struct {
  81. uint8_t addr_10bit_en; /*!< I2C 10bit address mode enable for slave mode */
  82. uint16_t slave_addr; /*!< I2C address for slave mode */
  83. } slave;
  84. };
  85. }i2c_config_t;
  86. typedef void* i2c_cmd_handle_t; /*!< I2C command handle */
  87. /**
  88. * @brief I2C driver install
  89. *
  90. * @param i2c_num I2C port number
  91. * @param mode I2C mode( master or slave )
  92. * @param slv_rx_buf_len receiving buffer size for slave mode
  93. * @note
  94. * Only slave mode will use this value, driver will ignore this value in master mode.
  95. * @param slv_tx_buf_len sending buffer size for slave mode
  96. * @note
  97. * Only slave mode will use this value, driver will ignore this value in master mode.
  98. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  99. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  100. * @note
  101. * In master mode, if the cache is likely to be disabled(such as write flash) and the slave is time-sensitive,
  102. * `ESP_INTR_FLAG_IRAM` is suggested to be used. In this case, please use the memory allocated from internal RAM in i2c read and write function,
  103. * because we can not access the psram(if psram is enabled) in interrupt handle function when cache is disabled.
  104. *
  105. * @return
  106. * - ESP_OK Success
  107. * - ESP_ERR_INVALID_ARG Parameter error
  108. * - ESP_FAIL Driver install error
  109. */
  110. esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_buf_len, size_t slv_tx_buf_len, int intr_alloc_flags);
  111. /**
  112. * @brief I2C driver delete
  113. *
  114. * @param i2c_num I2C port number
  115. *
  116. * @return
  117. * - ESP_OK Success
  118. * - ESP_ERR_INVALID_ARG Parameter error
  119. */
  120. esp_err_t i2c_driver_delete(i2c_port_t i2c_num);
  121. /**
  122. * @brief I2C parameter initialization
  123. *
  124. * @param i2c_num I2C port number
  125. * @param i2c_conf pointer to I2C parameter settings
  126. *
  127. * @return
  128. * - ESP_OK Success
  129. * - ESP_ERR_INVALID_ARG Parameter error
  130. */
  131. esp_err_t i2c_param_config(i2c_port_t i2c_num, const i2c_config_t* i2c_conf);
  132. /**
  133. * @brief reset I2C tx hardware fifo
  134. *
  135. * @param i2c_num I2C port number
  136. *
  137. * @return
  138. * - ESP_OK Success
  139. * - ESP_ERR_INVALID_ARG Parameter error
  140. */
  141. esp_err_t i2c_reset_tx_fifo(i2c_port_t i2c_num);
  142. /**
  143. * @brief reset I2C rx fifo
  144. *
  145. * @param i2c_num I2C port number
  146. *
  147. * @return
  148. * - ESP_OK Success
  149. * - ESP_ERR_INVALID_ARG Parameter error
  150. */
  151. esp_err_t i2c_reset_rx_fifo(i2c_port_t i2c_num);
  152. /**
  153. * @brief I2C isr handler register
  154. *
  155. * @param i2c_num I2C port number
  156. * @param fn isr handler function
  157. * @param arg parameter for isr handler function
  158. * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
  159. * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
  160. * @param handle handle return from esp_intr_alloc.
  161. *
  162. * @return
  163. * - ESP_OK Success
  164. * - ESP_ERR_INVALID_ARG Parameter error
  165. */
  166. esp_err_t i2c_isr_register(i2c_port_t i2c_num, void (*fn)(void*), void * arg, int intr_alloc_flags, intr_handle_t *handle);
  167. /**
  168. * @brief to delete and free I2C isr.
  169. *
  170. * @param handle handle of isr.
  171. *
  172. * @return
  173. * - ESP_OK Success
  174. * - ESP_ERR_INVALID_ARG Parameter error
  175. */
  176. esp_err_t i2c_isr_free(intr_handle_t handle);
  177. /**
  178. * @brief Configure GPIO signal for I2C sck and sda
  179. *
  180. * @param i2c_num I2C port number
  181. * @param sda_io_num GPIO number for I2C sda signal
  182. * @param scl_io_num GPIO number for I2C scl signal
  183. * @param sda_pullup_en Whether to enable the internal pullup for sda pin
  184. * @param scl_pullup_en Whether to enable the internal pullup for scl pin
  185. * @param mode I2C mode
  186. *
  187. * @return
  188. * - ESP_OK Success
  189. * - ESP_ERR_INVALID_ARG Parameter error
  190. */
  191. esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num,
  192. gpio_pullup_t sda_pullup_en, gpio_pullup_t scl_pullup_en, i2c_mode_t mode);
  193. /**
  194. * @brief Create and init I2C command link
  195. * @note
  196. * Before we build I2C command link, we need to call i2c_cmd_link_create() to create
  197. * a command link.
  198. * After we finish sending the commands, we need to call i2c_cmd_link_delete() to
  199. * release and return the resources.
  200. *
  201. * @return i2c command link handler
  202. */
  203. i2c_cmd_handle_t i2c_cmd_link_create();
  204. /**
  205. * @brief Free I2C command link
  206. * @note
  207. * Before we build I2C command link, we need to call i2c_cmd_link_create() to create
  208. * a command link.
  209. * After we finish sending the commands, we need to call i2c_cmd_link_delete() to
  210. * release and return the resources.
  211. *
  212. * @param cmd_handle I2C command handle
  213. */
  214. void i2c_cmd_link_delete(i2c_cmd_handle_t cmd_handle);
  215. /**
  216. * @brief Queue command for I2C master to generate a start signal
  217. * @note
  218. * Only call this function in I2C master mode
  219. * Call i2c_master_cmd_begin() to send all queued commands
  220. *
  221. * @param cmd_handle I2C cmd link
  222. *
  223. * @return
  224. * - ESP_OK Success
  225. * - ESP_ERR_INVALID_ARG Parameter error
  226. */
  227. esp_err_t i2c_master_start(i2c_cmd_handle_t cmd_handle);
  228. /**
  229. * @brief Queue command for I2C master to write one byte to I2C bus
  230. * @note
  231. * Only call this function in I2C master mode
  232. * Call i2c_master_cmd_begin() to send all queued commands
  233. *
  234. * @param cmd_handle I2C cmd link
  235. * @param data I2C one byte command to write to bus
  236. * @param ack_en enable ack check for master
  237. *
  238. * @return
  239. * - ESP_OK Success
  240. * - ESP_ERR_INVALID_ARG Parameter error
  241. */
  242. esp_err_t i2c_master_write_byte(i2c_cmd_handle_t cmd_handle, uint8_t data, bool ack_en);
  243. /**
  244. * @brief Queue command for I2C master to write buffer to I2C bus
  245. * @note
  246. * Only call this function in I2C master mode
  247. * Call i2c_master_cmd_begin() to send all queued commands
  248. *
  249. * @param cmd_handle I2C cmd link
  250. * @param data data to send
  251. * @note
  252. * If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
  253. * @param data_len data length
  254. * @param ack_en enable ack check for master
  255. *
  256. * @return
  257. * - ESP_OK Success
  258. * - ESP_ERR_INVALID_ARG Parameter error
  259. */
  260. esp_err_t i2c_master_write(i2c_cmd_handle_t cmd_handle, uint8_t* data, size_t data_len, bool ack_en);
  261. /**
  262. * @brief Queue command for I2C master to read one byte from I2C bus
  263. * @note
  264. * Only call this function in I2C master mode
  265. * Call i2c_master_cmd_begin() to send all queued commands
  266. *
  267. * @param cmd_handle I2C cmd link
  268. * @param data pointer accept the data byte
  269. * @note
  270. * If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
  271. * @param ack ack value for read command
  272. *
  273. * @return
  274. * - ESP_OK Success
  275. * - ESP_ERR_INVALID_ARG Parameter error
  276. */
  277. esp_err_t i2c_master_read_byte(i2c_cmd_handle_t cmd_handle, uint8_t* data, i2c_ack_type_t ack);
  278. /**
  279. * @brief Queue command for I2C master to read data from I2C bus
  280. * @note
  281. * Only call this function in I2C master mode
  282. * Call i2c_master_cmd_begin() to send all queued commands
  283. *
  284. * @param cmd_handle I2C cmd link
  285. * @param data data buffer to accept the data from bus
  286. * @note
  287. * If the psram is enabled and intr_flag is `ESP_INTR_FLAG_IRAM`, please use the memory allocated from internal RAM.
  288. * @param data_len read data length
  289. * @param ack ack value for read command
  290. *
  291. * @return
  292. * - ESP_OK Success
  293. * - ESP_ERR_INVALID_ARG Parameter error
  294. */
  295. esp_err_t i2c_master_read(i2c_cmd_handle_t cmd_handle, uint8_t* data, size_t data_len, i2c_ack_type_t ack);
  296. /**
  297. * @brief Queue command for I2C master to generate a stop signal
  298. * @note
  299. * Only call this function in I2C master mode
  300. * Call i2c_master_cmd_begin() to send all queued commands
  301. *
  302. * @param cmd_handle I2C cmd link
  303. *
  304. * @return
  305. * - ESP_OK Success
  306. * - ESP_ERR_INVALID_ARG Parameter error
  307. */
  308. esp_err_t i2c_master_stop(i2c_cmd_handle_t cmd_handle);
  309. /**
  310. * @brief I2C master send queued commands.
  311. * This function will trigger sending all queued commands.
  312. * The task will be blocked until all the commands have been sent out.
  313. * The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks,
  314. * you need to take care of the multi-thread issue.
  315. * @note
  316. * Only call this function in I2C master mode
  317. *
  318. * @param i2c_num I2C port number
  319. * @param cmd_handle I2C command handler
  320. * @param ticks_to_wait maximum wait ticks.
  321. *
  322. * @return
  323. * - ESP_OK Success
  324. * - ESP_ERR_INVALID_ARG Parameter error
  325. * - ESP_FAIL Sending command error, slave doesn't ACK the transfer.
  326. * - ESP_ERR_INVALID_STATE I2C driver not installed or not in master mode.
  327. * - ESP_ERR_TIMEOUT Operation timeout because the bus is busy.
  328. */
  329. esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, TickType_t ticks_to_wait);
  330. /**
  331. * @brief I2C slave write data to internal ringbuffer, when tx fifo empty, isr will fill the hardware
  332. * fifo from the internal ringbuffer
  333. * @note
  334. * Only call this function in I2C slave mode
  335. *
  336. * @param i2c_num I2C port number
  337. * @param data data pointer to write into internal buffer
  338. * @param size data size
  339. * @param ticks_to_wait Maximum waiting ticks
  340. *
  341. * @return
  342. * - ESP_FAIL(-1) Parameter error
  343. * - Others(>=0) The number of data bytes that pushed to the I2C slave buffer.
  344. */
  345. int i2c_slave_write_buffer(i2c_port_t i2c_num, uint8_t* data, int size, TickType_t ticks_to_wait);
  346. /**
  347. * @brief I2C slave read data from internal buffer. When I2C slave receive data, isr will copy received data
  348. * from hardware rx fifo to internal ringbuffer. Then users can read from internal ringbuffer.
  349. * @note
  350. * Only call this function in I2C slave mode
  351. *
  352. * @param i2c_num I2C port number
  353. * @param data data pointer to write into internal buffer
  354. * @param max_size Maximum data size to read
  355. * @param ticks_to_wait Maximum waiting ticks
  356. *
  357. * @return
  358. * - ESP_FAIL(-1) Parameter error
  359. * - Others(>=0) The number of data bytes that read from I2C slave buffer.
  360. */
  361. int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t* data, size_t max_size, TickType_t ticks_to_wait);
  362. /**
  363. * @brief set I2C master clock period
  364. *
  365. * @param i2c_num I2C port number
  366. * @param high_period clock cycle number during SCL is high level, high_period is a 14 bit value
  367. * @param low_period clock cycle number during SCL is low level, low_period is a 14 bit value
  368. *
  369. * @return
  370. * - ESP_OK Success
  371. * - ESP_ERR_INVALID_ARG Parameter error
  372. */
  373. esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period);
  374. /**
  375. * @brief get I2C master clock period
  376. *
  377. * @param i2c_num I2C port number
  378. * @param high_period pointer to get clock cycle number during SCL is high level, will get a 14 bit value
  379. * @param low_period pointer to get clock cycle number during SCL is low level, will get a 14 bit value
  380. *
  381. * @return
  382. * - ESP_OK Success
  383. * - ESP_ERR_INVALID_ARG Parameter error
  384. */
  385. esp_err_t i2c_get_period(i2c_port_t i2c_num, int* high_period, int* low_period);
  386. /**
  387. * @brief enable hardware filter on I2C bus
  388. * Sometimes the I2C bus is disturbed by high frequency noise(about 20ns), or the rising edge of
  389. * the SCL clock is very slow, these may cause the master state machine broken. enable hardware
  390. * filter can filter out high frequency interference and make the master more stable.
  391. * @note
  392. * Enable filter will slow the SCL clock.
  393. *
  394. * @param i2c_num I2C port number
  395. * @param cyc_num the APB cycles need to be filtered(0<= cyc_num <=7).
  396. * When the period of a pulse is less than cyc_num * APB_cycle, the I2C controller will ignore this pulse.
  397. *
  398. * @return
  399. * - ESP_OK Success
  400. * - ESP_ERR_INVALID_ARG Parameter error
  401. */
  402. esp_err_t i2c_filter_enable(i2c_port_t i2c_num, uint8_t cyc_num);
  403. /**
  404. * @brief disable filter on I2C bus
  405. *
  406. * @param i2c_num I2C port number
  407. *
  408. * @return
  409. * - ESP_OK Success
  410. * - ESP_ERR_INVALID_ARG Parameter error
  411. */
  412. esp_err_t i2c_filter_disable(i2c_port_t i2c_num);
  413. /**
  414. * @brief set I2C master start signal timing
  415. *
  416. * @param i2c_num I2C port number
  417. * @param setup_time clock number between the falling-edge of SDA and rising-edge of SCL for start mark, it's a 10-bit value.
  418. * @param hold_time clock num between the falling-edge of SDA and falling-edge of SCL for start mark, it's a 10-bit value.
  419. *
  420. * @return
  421. * - ESP_OK Success
  422. * - ESP_ERR_INVALID_ARG Parameter error
  423. */
  424. esp_err_t i2c_set_start_timing(i2c_port_t i2c_num, int setup_time, int hold_time);
  425. /**
  426. * @brief get I2C master start signal timing
  427. *
  428. * @param i2c_num I2C port number
  429. * @param setup_time pointer to get setup time
  430. * @param hold_time pointer to get hold time
  431. *
  432. * @return
  433. * - ESP_OK Success
  434. * - ESP_ERR_INVALID_ARG Parameter error
  435. */
  436. esp_err_t i2c_get_start_timing(i2c_port_t i2c_num, int* setup_time, int* hold_time);
  437. /**
  438. * @brief set I2C master stop signal timing
  439. *
  440. * @param i2c_num I2C port number
  441. * @param setup_time clock num between the rising-edge of SCL and the rising-edge of SDA, it's a 10-bit value.
  442. * @param hold_time clock number after the STOP bit's rising-edge, it's a 14-bit value.
  443. *
  444. * @return
  445. * - ESP_OK Success
  446. * - ESP_ERR_INVALID_ARG Parameter error
  447. */
  448. esp_err_t i2c_set_stop_timing(i2c_port_t i2c_num, int setup_time, int hold_time);
  449. /**
  450. * @brief get I2C master stop signal timing
  451. *
  452. * @param i2c_num I2C port number
  453. * @param setup_time pointer to get setup time.
  454. * @param hold_time pointer to get hold time.
  455. *
  456. * @return
  457. * - ESP_OK Success
  458. * - ESP_ERR_INVALID_ARG Parameter error
  459. */
  460. esp_err_t i2c_get_stop_timing(i2c_port_t i2c_num, int* setup_time, int* hold_time);
  461. /**
  462. * @brief set I2C data signal timing
  463. *
  464. * @param i2c_num I2C port number
  465. * @param sample_time clock number I2C used to sample data on SDA after the rising-edge of SCL, it's a 10-bit value
  466. * @param hold_time clock number I2C used to hold the data after the falling-edge of SCL, it's a 10-bit value
  467. *
  468. * @return
  469. * - ESP_OK Success
  470. * - ESP_ERR_INVALID_ARG Parameter error
  471. */
  472. esp_err_t i2c_set_data_timing(i2c_port_t i2c_num, int sample_time, int hold_time);
  473. /**
  474. * @brief get I2C data signal timing
  475. *
  476. * @param i2c_num I2C port number
  477. * @param sample_time pointer to get sample time
  478. * @param hold_time pointer to get hold time
  479. *
  480. * @return
  481. * - ESP_OK Success
  482. * - ESP_ERR_INVALID_ARG Parameter error
  483. */
  484. esp_err_t i2c_get_data_timing(i2c_port_t i2c_num, int* sample_time, int* hold_time);
  485. /**
  486. * @brief set I2C timeout value
  487. * @param i2c_num I2C port number
  488. * @param timeout timeout value for I2C bus (unit: APB 80Mhz clock cycle)
  489. * @return
  490. * - ESP_OK Success
  491. * - ESP_ERR_INVALID_ARG Parameter error
  492. */
  493. esp_err_t i2c_set_timeout(i2c_port_t i2c_num, int timeout);
  494. /**
  495. * @brief get I2C timeout value
  496. * @param i2c_num I2C port number
  497. * @param timeout pointer to get timeout value
  498. * @return
  499. * - ESP_OK Success
  500. * - ESP_ERR_INVALID_ARG Parameter error
  501. */
  502. esp_err_t i2c_get_timeout(i2c_port_t i2c_num, int* timeout);
  503. /**
  504. * @brief set I2C data transfer mode
  505. *
  506. * @param i2c_num I2C port number
  507. * @param tx_trans_mode I2C sending data mode
  508. * @param rx_trans_mode I2C receving data mode
  509. *
  510. * @return
  511. * - ESP_OK Success
  512. * - ESP_ERR_INVALID_ARG Parameter error
  513. */
  514. esp_err_t i2c_set_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t tx_trans_mode, i2c_trans_mode_t rx_trans_mode);
  515. /**
  516. * @brief get I2C data transfer mode
  517. *
  518. * @param i2c_num I2C port number
  519. * @param tx_trans_mode pointer to get I2C sending data mode
  520. * @param rx_trans_mode pointer to get I2C receiving data mode
  521. *
  522. * @return
  523. * - ESP_OK Success
  524. * - ESP_ERR_INVALID_ARG Parameter error
  525. */
  526. esp_err_t i2c_get_data_mode(i2c_port_t i2c_num, i2c_trans_mode_t *tx_trans_mode, i2c_trans_mode_t *rx_trans_mode);
  527. #ifdef __cplusplus
  528. }
  529. #endif
  530. #endif /*_DRIVER_I2C_H_*/