drv_i2c.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  1. /*
  2. * Copyright (c) 2022-2024 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include <rtthread.h>
  8. #include <rtdevice.h>
  9. #include <rtdbg.h>
  10. #ifdef BSP_USING_I2C
  11. #include "drv_i2c.h"
  12. #include "hpm_i2c_drv.h"
  13. #include "hpm_dma_mgr.h"
  14. #include "hpm_dmamux_drv.h"
  15. #include "hpm_l1c_drv.h"
  16. #include "board.h"
  17. #ifdef RT_USING_I2C
  18. #define HPM_RTT_DRV_RETRY_TIMEOUT (1000000)
  19. #ifndef HPM_I2C_DRV_DEFAULT_RETRY_COUNT
  20. #define HPM_I2C_DRV_DEFAULT_RETRY_COUNT (5000U)
  21. #endif
  22. struct hpm_i2c
  23. {
  24. struct rt_i2c_bus_device bus;
  25. I2C_Type *base;
  26. clock_name_t clk_name;
  27. char *bus_name;
  28. rt_sem_t xfer_sem;
  29. rt_bool_t enable_dma;
  30. rt_uint8_t dmamux;
  31. dma_resource_t dma;
  32. rt_uint8_t i2c_irq;
  33. rt_uint8_t is_read;
  34. rt_uint8_t irq_priority;
  35. };
  36. static struct hpm_i2c hpm_i2cs[] =
  37. {
  38. #if defined(BSP_USING_I2C0)
  39. {
  40. .base = HPM_I2C0,
  41. .bus_name = "i2c0",
  42. .clk_name = clock_i2c0,
  43. #if defined(BSP_I2C0_USING_DMA)
  44. .enable_dma = RT_TRUE,
  45. #endif
  46. .dmamux = HPM_DMA_SRC_I2C0,
  47. .i2c_irq = IRQn_I2C0,
  48. #if defined(BSP_I2C0_IRQ_PRIORITY)
  49. .irq_priority = BSP_I2C0_IRQ_PRIORITY,
  50. #else
  51. .irq_priority = 1,
  52. #endif
  53. },
  54. #endif
  55. #if defined(BSP_USING_I2C1)
  56. {
  57. .base = HPM_I2C1,
  58. .bus_name = "i2c1",
  59. .clk_name = clock_i2c1,
  60. #if defined(BSP_I2C1_USING_DMA)
  61. .enable_dma = RT_TRUE,
  62. #endif
  63. .dmamux = HPM_DMA_SRC_I2C1,
  64. .i2c_irq = IRQn_I2C1,
  65. #if defined(BSP_I2C1_IRQ_PRIORITY)
  66. .irq_priority = BSP_I2C1_IRQ_PRIORITY,
  67. #else
  68. .irq_priority = 1,
  69. #endif
  70. },
  71. #endif
  72. #if defined(BSP_USING_I2C2)
  73. {
  74. .base = HPM_I2C2,
  75. .bus_name = "i2c2",
  76. .clk_name = clock_i2c2,
  77. #if defined(BSP_I2C2_USING_DMA)
  78. .enable_dma = RT_TRUE,
  79. #endif
  80. .dmamux = HPM_DMA_SRC_I2C2,
  81. .i2c_irq = IRQn_I2C2,
  82. #if defined(BSP_I2C2_IRQ_PRIORITY)
  83. .irq_priority = BSP_I2C2_IRQ_PRIORITY,
  84. #else
  85. .irq_priority = 1,
  86. #endif
  87. },
  88. #endif
  89. #if defined(BSP_USING_I2C3)
  90. {
  91. .base = HPM_I2C3,
  92. .bus_name = "i2c3",
  93. .clk_name = clock_i2c3,
  94. #if defined(BSP_I2C3_USING_DMA)
  95. .enable_dma = RT_TRUE,
  96. #endif
  97. .dmamux = HPM_DMA_SRC_I2C3,
  98. .i2c_irq = IRQn_I2C3,
  99. #if defined(BSP_I2C3_IRQ_PRIORITY)
  100. .irq_priority = BSP_I2C3_IRQ_PRIORITY,
  101. #else
  102. .irq_priority = 1,
  103. #endif
  104. },
  105. #endif
  106. #if defined(BSP_USING_I2C4)
  107. {
  108. .base = HPM_I2C4,
  109. .bus_name = "i2c4",
  110. .clk_name = clock_i2c4,
  111. #if defined(BSP_I2C4_USING_DMA)
  112. .enable_dma = RT_TRUE,
  113. #endif
  114. .dmamux = HPM_DMA_SRC_I2C4,
  115. .i2c_irq = IRQn_I2C4,
  116. #if defined(BSP_I2C4_IRQ_PRIORITY)
  117. .irq_priority = BSP_I2C4_IRQ_PRIORITY,
  118. #else
  119. .irq_priority = 1,
  120. #endif
  121. },
  122. #endif
  123. #if defined(BSP_USING_I2C5)
  124. {
  125. .base = HPM_I2C5,
  126. .bus_name = "i2c5",
  127. .clk_name = clock_i2c5,
  128. #if defined(BSP_I2C5_USING_DMA)
  129. .enable_dma = RT_TRUE,
  130. #endif
  131. .dmamux = HPM_DMA_SRC_I2C5,
  132. .i2c_irq = IRQn_I2C5,
  133. #if defined(BSP_I2C5_IRQ_PRIORITY)
  134. .irq_priority = BSP_I2C5_IRQ_PRIORITY,
  135. #else
  136. .irq_priority = 1,
  137. #endif
  138. },
  139. #endif
  140. #if defined(BSP_USING_I2C6)
  141. {
  142. .base = HPM_I2C6,
  143. .bus_name = "i2c6",
  144. .clk_name = clock_i2c6,
  145. #if defined(BSP_I2C6_USING_DMA)
  146. .enable_dma = RT_TRUE,
  147. #endif
  148. .dmamux = HPM_DMA_SRC_I2C6,
  149. .i2c_irq = IRQn_I2C6,
  150. #if defined(BSP_I2C6_IRQ_PRIORITY)
  151. .irq_priority = BSP_I2C6_IRQ_PRIORITY,
  152. #else
  153. .irq_priority = 1,
  154. #endif
  155. },
  156. #endif
  157. #if defined(BSP_USING_I2C7)
  158. {
  159. .base = HPM_I2C7,
  160. .bus_name = "i2c7",
  161. .clk_name = clock_i2c7,
  162. #if defined(BSP_I2C7_USING_DMA)
  163. .enable_dma = RT_TRUE,
  164. #endif
  165. .dmamux = HPM_DMA_SRC_I2C7,
  166. .i2c_irq = IRQn_I2C7,
  167. #if defined(BSP_I2C7_IRQ_PRIORITY)
  168. .irq_priority = BSP_I2C7_IRQ_PRIORITY,
  169. #else
  170. .irq_priority = 1,
  171. #endif
  172. },
  173. #endif
  174. };
  175. static rt_ssize_t hpm_i2c_master_transfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num);
  176. static hpm_stat_t i2c_tx_trigger_dma(DMA_Type *dma_ptr, uint8_t ch_num, I2C_Type *i2c_ptr, uint32_t src, uint32_t size);
  177. static hpm_stat_t i2c_rx_trigger_dma(DMA_Type *dma_ptr, uint8_t ch_num, I2C_Type *i2c_ptr, uint32_t dst, uint32_t size);
  178. struct rt_i2c_bus_device_ops hpm_i2c_ops =
  179. {
  180. hpm_i2c_master_transfer,
  181. RT_NULL,
  182. RT_NULL
  183. };
  184. static inline void handle_i2c_isr(I2C_Type *ptr)
  185. {
  186. volatile uint32_t irq_status;
  187. RT_ASSERT(ptr != RT_NULL);
  188. rt_base_t level;
  189. level = rt_hw_interrupt_disable();
  190. irq_status = i2c_get_status(ptr);
  191. if (irq_status & I2C_EVENT_TRANSACTION_COMPLETE)
  192. {
  193. for (uint32_t i = 0; i < sizeof(hpm_i2cs) / sizeof(hpm_i2cs[0]); i++)
  194. {
  195. if (hpm_i2cs[i].base == ptr)
  196. {
  197. rt_sem_release(hpm_i2cs[i].xfer_sem);
  198. }
  199. }
  200. i2c_disable_irq(ptr, I2C_EVENT_TRANSACTION_COMPLETE);
  201. i2c_clear_status(ptr, I2C_EVENT_TRANSACTION_COMPLETE);
  202. }
  203. rt_hw_interrupt_enable(level);
  204. }
  205. #if defined(BSP_USING_I2C0)
  206. SDK_DECLARE_EXT_ISR_M(IRQn_I2C0, i2c0_isr);
  207. void i2c0_isr(void)
  208. {
  209. handle_i2c_isr(HPM_I2C0);
  210. }
  211. #endif
  212. #if defined(BSP_USING_I2C1)
  213. SDK_DECLARE_EXT_ISR_M(IRQn_I2C1, i2c1_isr);
  214. void i2c1_isr(void)
  215. {
  216. handle_i2c_isr(HPM_I2C1);
  217. }
  218. #endif
  219. #if defined(BSP_USING_I2C2)
  220. SDK_DECLARE_EXT_ISR_M(IRQn_I2C2, i2c2_isr);
  221. void i2c2_isr(void)
  222. {
  223. handle_i2c_isr(HPM_I2C2);
  224. }
  225. #endif
  226. #if defined(BSP_USING_I2C3)
  227. SDK_DECLARE_EXT_ISR_M(IRQn_I2C3, i2c3_isr);
  228. void i2c3_isr(void)
  229. {
  230. handle_i2c_isr(HPM_I2C3);
  231. }
  232. #endif
  233. #if defined(BSP_USING_I2C4)
  234. SDK_DECLARE_EXT_ISR_M(IRQn_I2C4, i2c4_isr);
  235. void i2c4_isr(void)
  236. {
  237. handle_i2c_isr(HPM_I2C4);
  238. }
  239. #endif
  240. #if defined(BSP_USING_I2C5)
  241. SDK_DECLARE_EXT_ISR_M(IRQn_I2C5, i2c5_isr);
  242. void i2c5_isr(void)
  243. {
  244. handle_i2c_isr(HPM_I2C5);
  245. }
  246. #endif
  247. #if defined(BSP_USING_I2C6)
  248. SDK_DECLARE_EXT_ISR_M(IRQn_I2C6, i2c6_isr);
  249. void i2c6_isr(void)
  250. {
  251. handle_i2c_isr(HPM_I2C6);
  252. }
  253. #endif
  254. #if defined(BSP_USING_I2C7)
  255. SDK_DECLARE_EXT_ISR_M(IRQn_I2C7, i2c7_isr);
  256. void i2c7_isr(void)
  257. {
  258. handle_i2c_isr(HPM_I2C7);
  259. }
  260. #endif
  261. static hpm_stat_t i2c_tx_trigger_dma(DMA_Type *dma_ptr, uint8_t ch_num, I2C_Type *i2c_ptr, uint32_t src, uint32_t size)
  262. {
  263. dma_handshake_config_t config;
  264. dma_default_handshake_config(dma_ptr, &config);
  265. config.ch_index = ch_num;
  266. config.dst = (uint32_t)&i2c_ptr->DATA;
  267. config.dst_fixed = true;
  268. config.src = src;
  269. config.src_fixed = false;
  270. config.data_width = DMA_TRANSFER_WIDTH_BYTE;
  271. config.size_in_byte = size;
  272. return dma_setup_handshake(dma_ptr, &config, true);
  273. }
  274. static hpm_stat_t i2c_rx_trigger_dma(DMA_Type *dma_ptr, uint8_t ch_num, I2C_Type *i2c_ptr, uint32_t dst, uint32_t size)
  275. {
  276. dma_handshake_config_t config;
  277. dma_default_handshake_config(dma_ptr, &config);
  278. config.ch_index = ch_num;
  279. config.dst = dst;
  280. config.dst_fixed = false;
  281. config.src = (uint32_t)&i2c_ptr->DATA;
  282. config.src_fixed = true;
  283. config.data_width = DMA_TRANSFER_WIDTH_BYTE;
  284. config.size_in_byte = size;
  285. return dma_setup_handshake(dma_ptr, &config, true);
  286. }
  287. void i2c_dma_channel_tc_callback(DMA_Type *ptr, uint32_t channel, void *user_data)
  288. {
  289. struct hpm_i2c *i2c = (struct hpm_i2c *)user_data;
  290. RT_ASSERT(i2c != RT_NULL);
  291. RT_ASSERT(ptr != RT_NULL);
  292. rt_base_t level;
  293. level = rt_hw_interrupt_disable();
  294. if ((i2c->dma.base == ptr) && i2c->dma.channel == channel)
  295. {
  296. dma_mgr_disable_chn_irq(&i2c->dma, DMA_MGR_INTERRUPT_MASK_TC);
  297. if (i2c->is_read == true)
  298. {
  299. rt_sem_release(i2c->xfer_sem);
  300. }
  301. }
  302. rt_hw_interrupt_enable(level);
  303. }
  304. static rt_ssize_t hpm_i2c_master_transfer(struct rt_i2c_bus_device *bus, struct rt_i2c_msg msgs[], rt_uint32_t num)
  305. {
  306. RT_ASSERT(bus != RT_NULL);
  307. RT_ASSERT(msgs != RT_NULL);
  308. struct rt_i2c_msg *msg;
  309. struct hpm_i2c *i2c_info = (struct hpm_i2c *)bus;
  310. hpm_stat_t i2c_stat = status_success;
  311. rt_size_t ret = 0;
  312. rt_uint32_t i;
  313. rt_uint8_t *raw_alloc_buf = RT_NULL;
  314. rt_uint8_t *aligned_buf = RT_NULL;
  315. rt_uint8_t *dummy_buf = RT_NULL;
  316. rt_uint32_t aligned_len = 0;
  317. rt_uint32_t remaining_size = 0;
  318. rt_uint32_t transfer_len;
  319. for (i = 0; i < num; i++)
  320. {
  321. msg = &msgs[i];
  322. remaining_size = msg->len;
  323. if ((msg->len > 0) && (i2c_info->enable_dma))
  324. {
  325. aligned_len = (msg->len + HPM_L1C_CACHELINE_SIZE - 1U) & ~(HPM_L1C_CACHELINE_SIZE - 1U);
  326. if (l1c_dc_is_enabled())
  327. {
  328. if (msg->flags & RT_I2C_RD)
  329. {
  330. /* The allocated pointer is always RT_ALIGN_SIZE aligned */
  331. raw_alloc_buf = (uint8_t*)rt_malloc(aligned_len + HPM_L1C_CACHELINE_SIZE - RT_ALIGN_SIZE);
  332. RT_ASSERT(raw_alloc_buf != RT_NULL);
  333. }
  334. else
  335. {
  336. /* The allocated pointer is always RT_ALIGN_SIZE aligned */
  337. raw_alloc_buf = (uint8_t*)rt_malloc(aligned_len + HPM_L1C_CACHELINE_SIZE - RT_ALIGN_SIZE);
  338. RT_ASSERT(raw_alloc_buf != RT_NULL);
  339. aligned_buf = (uint8_t*)HPM_L1C_CACHELINE_ALIGN_UP((uint32_t)raw_alloc_buf);
  340. rt_memcpy(aligned_buf, msg->buf, msg->len);
  341. l1c_dc_flush((uint32_t)aligned_buf, aligned_len);
  342. }
  343. }
  344. }
  345. else
  346. {
  347. aligned_buf = (uint8_t*) msg->buf;
  348. }
  349. if (msg->flags & RT_I2C_ADDR_10BIT)
  350. {
  351. i2c_enable_10bit_address_mode(i2c_info->base, true);
  352. }
  353. else
  354. {
  355. i2c_enable_10bit_address_mode(i2c_info->base, false);
  356. }
  357. dummy_buf = aligned_buf;
  358. if (msg->flags & RT_I2C_RD)
  359. {
  360. /* maybe probe i2c device */
  361. if (msg->len == 0)
  362. {
  363. i2c_stat = i2c_master_read(i2c_info->base, msg->addr, dummy_buf, remaining_size);
  364. }
  365. else
  366. {
  367. while (remaining_size)
  368. {
  369. transfer_len = MIN(I2C_SOC_TRANSFER_COUNT_MAX, remaining_size);
  370. if ((i2c_info->enable_dma))
  371. {
  372. /* sequential transfer now is not support dma */
  373. if ((msg->flags & RT_I2C_NO_START) || (msg->flags & RT_I2C_NO_STOP) ||
  374. (msg->flags & RT_I2C_NO_READ_ACK) || (msg->flags & RT_I2C_NO_READ_ACK) ) {
  375. i2c_stat = status_invalid_argument;
  376. break;
  377. }
  378. i2c_info->is_read = true;
  379. i2c_enable_irq(i2c_info->base, I2C_EVENT_TRANSACTION_COMPLETE);
  380. dmamux_config(HPM_DMAMUX, i2c_info->dma.channel, i2c_info->dmamux, true);
  381. i2c_stat = i2c_rx_trigger_dma(i2c_info->dma.base, i2c_info->dma.channel, i2c_info->base,
  382. core_local_mem_to_sys_address(0, (uint32_t) dummy_buf), transfer_len);
  383. if (i2c_stat != status_success)
  384. {
  385. break;
  386. }
  387. i2c_stat = i2c_master_start_dma_read(i2c_info->base, msg->addr, msg->len);
  388. if (i2c_stat != status_success)
  389. {
  390. break;
  391. }
  392. rt_sem_take(i2c_info->xfer_sem, RT_WAITING_FOREVER);
  393. }
  394. else
  395. {
  396. i2c_master_transfer(i2c_info->base, msg->addr, dummy_buf, transfer_len, msg->flags);
  397. }
  398. dummy_buf += transfer_len;
  399. remaining_size -= transfer_len;
  400. }
  401. if (raw_alloc_buf != RT_NULL)
  402. {
  403. l1c_dc_invalidate((uint32_t) aligned_buf, aligned_len);
  404. rt_memcpy(msg->buf, aligned_buf, msg->len);
  405. rt_free(raw_alloc_buf);
  406. raw_alloc_buf = RT_NULL;
  407. aligned_buf = RT_NULL;
  408. }
  409. }
  410. }
  411. else
  412. {
  413. /* maybe probe i2c device */
  414. if (msg->len == 0)
  415. {
  416. i2c_stat = i2c_master_write(i2c_info->base, msg->addr, dummy_buf, remaining_size);
  417. }
  418. else
  419. {
  420. while (remaining_size)
  421. {
  422. transfer_len = MIN(I2C_SOC_TRANSFER_COUNT_MAX, remaining_size);
  423. if (i2c_info->enable_dma)
  424. {
  425. /* sequential transfer now is not support dma */
  426. if ((msg->flags & RT_I2C_NO_START) || (msg->flags & RT_I2C_NO_STOP) ||
  427. (msg->flags & RT_I2C_NO_READ_ACK) || (msg->flags & RT_I2C_NO_READ_ACK) ) {
  428. i2c_stat = status_invalid_argument;
  429. break;
  430. }
  431. i2c_info->is_read = false;
  432. i2c_enable_irq(i2c_info->base, I2C_EVENT_TRANSACTION_COMPLETE);
  433. dmamux_config(HPM_DMAMUX, i2c_info->dma.channel, i2c_info->dmamux, true);
  434. i2c_stat = i2c_tx_trigger_dma(i2c_info->dma.base, i2c_info->dma.channel, i2c_info->base,
  435. core_local_mem_to_sys_address(0, (uint32_t) dummy_buf), transfer_len);
  436. if (i2c_stat != status_success)
  437. {
  438. break;
  439. }
  440. i2c_stat = i2c_master_start_dma_write(i2c_info->base, msg->addr, msg->len);
  441. if (i2c_stat != status_success)
  442. {
  443. break;
  444. }
  445. rt_sem_take(i2c_info->xfer_sem, RT_WAITING_FOREVER);
  446. }
  447. else
  448. {
  449. i2c_master_transfer(i2c_info->base, msg->addr, dummy_buf, transfer_len, msg->flags);
  450. }
  451. dummy_buf += transfer_len;
  452. remaining_size -= transfer_len;
  453. }
  454. if (raw_alloc_buf != RT_NULL)
  455. {
  456. rt_free(raw_alloc_buf);
  457. raw_alloc_buf = RT_NULL;
  458. aligned_buf = RT_NULL;
  459. }
  460. }
  461. }
  462. if (i2c_stat != status_success)
  463. {
  464. break;
  465. }
  466. }
  467. if (i2c_stat != status_success)
  468. {
  469. return ret;
  470. }
  471. ret = i;
  472. return ret;
  473. }
  474. int rt_hw_i2c_init(void)
  475. {
  476. rt_err_t ret = RT_EOK;
  477. hpm_stat_t stat;
  478. i2c_config_t config;
  479. rt_uint32_t freq;
  480. char sem_name[RT_NAME_MAX];
  481. for (uint32_t i = 0; i < sizeof(hpm_i2cs) / sizeof(hpm_i2cs[0]); i++) {
  482. init_i2c_pins(hpm_i2cs[i].base);
  483. clock_add_to_group(hpm_i2cs[i].clk_name, BOARD_RUNNING_CORE & 0x1);
  484. clock_set_source_divider(hpm_i2cs[i].clk_name, clk_src_osc24m, 1U);
  485. config.i2c_mode = i2c_mode_normal;
  486. config.is_10bit_addressing = false;
  487. freq = clock_get_frequency(hpm_i2cs[i].clk_name);
  488. stat = i2c_init_master(hpm_i2cs[i].base, freq, &config);
  489. if (stat != status_success) {
  490. LOG_E("rt i2c device %s init failed", hpm_i2cs[i].bus_name);
  491. }
  492. hpm_i2cs[i].bus.ops = &hpm_i2c_ops;
  493. if (hpm_i2cs[i].enable_dma)
  494. {
  495. stat = dma_mgr_request_resource(&hpm_i2cs[i].dma);
  496. if (stat != status_success)
  497. {
  498. return -RT_ERROR;
  499. }
  500. dma_mgr_install_chn_tc_callback(&hpm_i2cs[i].dma, i2c_dma_channel_tc_callback, (void *)&hpm_i2cs[i]);
  501. dma_mgr_enable_dma_irq_with_priority(&hpm_i2cs[i].dma, 1);
  502. intc_m_enable_irq_with_priority(hpm_i2cs[i].i2c_irq, hpm_i2cs[i].irq_priority);
  503. i2c_disable_irq(hpm_i2cs[i].base, I2C_EVENT_TRANSACTION_COMPLETE);
  504. rt_sprintf(sem_name, "%s_s", hpm_i2cs[i].bus_name);
  505. hpm_i2cs[i].xfer_sem = rt_sem_create(sem_name, 0, RT_IPC_FLAG_PRIO);
  506. if (hpm_i2cs[i].xfer_sem == RT_NULL)
  507. {
  508. ret = RT_ENOMEM;
  509. break;
  510. }
  511. }
  512. ret = rt_i2c_bus_device_register(&hpm_i2cs[i].bus, hpm_i2cs[i].bus_name);
  513. if (ret != RT_EOK) {
  514. LOG_E("rt i2c device %s register failed, status=%d\n", hpm_i2cs[i].bus_name, ret);
  515. }
  516. }
  517. return ret;
  518. }
  519. INIT_DEVICE_EXPORT(rt_hw_i2c_init);
  520. #endif /* RT_USING_I2C */
  521. #endif /*BSP_USING_I2C*/