1 /* 2 * Copyright (C) 2022-2024, Xiaohua Semiconductor Co., Ltd. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2022-04-28 CDT first version 9 */ 10 11 #ifndef __DRV_I2C_H__ 12 #define __DRV_I2C_H__ 13 14 #include <rtdevice.h> 15 #include "board_config.h" 16 #include "drv_irq.h" 17 #include "drv_dma.h" 18 19 #ifdef BSP_USING_I2C 20 21 /* C binding of definitions if building with C++ compiler */ 22 #ifdef __cplusplus 23 extern "C" 24 { 25 #endif 26 27 /******************************************************************************* 28 * Global type definitions ('typedef') 29 ******************************************************************************/ 30 struct hc32_i2c_config 31 { 32 const char *name; 33 CM_I2C_TypeDef *Instance; 34 rt_uint32_t clock; 35 rt_uint32_t baudrate; 36 rt_uint32_t timeout; 37 struct dma_config *i2c_tx_dma; 38 struct dma_config *i2c_rx_dma; 39 }; 40 41 struct hc32_i2c 42 { 43 struct hc32_i2c_config *config; 44 struct rt_i2c_bus_device i2c_bus; 45 rt_uint8_t i2c_dma_flag; 46 }; 47 48 /******************************************************************************* 49 * Global pre-processor symbols/macros ('#define') 50 ******************************************************************************/ 51 #define I2C_USING_TX_DMA_FLAG (1U) 52 #define I2C_USING_RX_DMA_FLAG (1U << 1) 53 54 #ifdef __cplusplus 55 } 56 #endif 57 58 #endif /* BSP_USING_I2C */ 59 60 #endif /* __DRV_I2C_H__ */ 61