/** ########################################################################## ** Filename : ** Project : ** Module : ** Processor : ** Version : 1.0 ** Compiler : ** Date/Time : ** Abstract : ** Contents : ** Note : 此文档用于规范代码书写; * 注意, * 1.所有文件用UTF-8格式 * 2.tab键空格4个 * 3.各模块,都要有 初始化函数 init, 反初始化函数 deinit, * 周期任务task,进入休眠goto sleep, * 唤醒后 goto wake ,判断是否可休眠judge_pre_sleep 等主要函数接口 * 4. ** ** (c) Copyright dmdz Co.,Ltd ** -------------------------------------------------------------------------- ** R E V I S I O N H I S T O R Y ** -------------------------------------------------------------------------- ** Date Ver Author Description ** -20191106- --V01-- --LYJ--- --初版-- ** -20230602- --V1.0-- --mingyea--- --修改-- ** #########################################################################*/ #ifndef I2C_CFG_ #define I2C_CFG_ /*--------------------------------------------------------------------------- - I N C L U D E F I L E S ----------------------------------------------------------------------------*/ #include "common_types.h" #include "error.h" //#include "IO_Map.h" /* Include inherited components */ #include "cpu.h" /*--------------------------------------------------------------------------- - D E F I N E S / M A C R O S ----------------------------------------------------------------------------*/ #define I2C_MADE_BY_SIMU //模拟I2C #define I2C_INTERRUPT_EN //开启中断方式 #define I2C_TASK_TIME_UNIT 1u //放在1ms定时器里 #define I2C_FRAME_MAX_SIZE 20u //字节 #define I2C_TIME_TOTAL_ID_START_BIT 0 #define I2C_TIME_TOTAL_ID_ADDR 1 #define I2C_TIME_TOTAL_ID_WRITE 2 #define I2C_TIME_TOTAL_ID_READ 3 #define I2C_TIME_TOTAL_ID_STOP_BIT 4 #define I2C_TIME_TOTAL_ID_MAX 5 //#define I2C_API_RECALL #define I2C_DEBUG_EN //#define I2C_TEST_EN /*--------------------------------------------------------------------------- - T Y P E D E F I N I T I O N S ----------------------------------------------------------------------------*/ //typedef u16 word; typedef u8 i2c_len_type; /*--------------------------------------------------------------------------- - S T A T I C V A R I A B L E S ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- * G L O B A L V A R I A B L E S ----------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- - C O N S T A N T S ----------------------------------------------------------------------------*/ extern const FL_I2C_MasterMode_InitTypeDef g_IICInitStructer; extern const u16 g_i2c_time_total[I2C_TIME_TOTAL_ID_MAX] ; /*--------------------------------------------------------------------------- - F U N C T I O N P R O T O T Y P E ----------------------------------------------------------------------------*/ #ifdef I2C_API_RECALL #define CI2C1_Init i2c_init #define CI2C_re_init_para i2c_re_init_para #define CI2C1_SelectSlave i2c_sel_slave_addr #define CI2C1_SendBlock i2c_send_block #define CI2C1_RecvBlock i2c_recv_block #else void CI2C1_Init(void); void CI2C_re_init_para(void); u8 CI2C1_SelectSlave(u8 Slv); u8 CI2C1_SendBlock(void* Ptr,i2c_len_type Siz,i2c_len_type *Snt); u8 CI2C1_RecvBlock(void* Ptr,i2c_len_type Siz,i2c_len_type *Rcv); #endif #endif