/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2023-04-10 19813 the first version */ #ifndef APPLICATIONS_PERI_IIC_IIC_H_ #define APPLICATIONS_PERI_IIC_IIC_H_ /*********************↓ define ↓************************/ /*********************↑ define ↑************************/ /** * * * * * */ /*********************↓ include ↓************************/ #include #include /*********************↑ include ↑************************/ /** * * * * * */ /*********************↓ extern ↓************************/ /*********************↑ extern ↑************************/ /** * * * * * */ /********************↓ declaration ↓***********************/ typedef enum { IIC1 = 0, IIC2 , IIC3 }IICDef; typedef struct { GPIO_TypeDef *port; // GPIO uint16_t SCL_pin; // SCL 引脚 uint16_t SDA_pin; // SDA 引脚 uint8_t SCL_us; // SCL 延时时间 uint8_t SDA_us; // SDA 延时时间 // uint8_t Ack; // 是否回复 uint8_t Devaddr; // 设备地址 }IIC_Info; void IIC_Init(IICDef i); void IIC_Start(IICDef i); void IIC_Stop(IICDef i); void IIC_WriteByte(IICDef i, uint8_t data); uint8_t IIC_Wait_Ask(IICDef i); uint8_t IIC_FindAddr(IICDef i); uint8_t IIC_AddrCheck(IICDef i , uint8_t *readaddr); uint8_t IIC_DevReadByte(IICDef i, uint8_t addr); uint8_t IIC_ReadByte(IICDef i); uint8_t IIC_MultipleReadByte(IICDef i); void IIC_DevReadBuf(IICDef i, uint8_t addr, uint8_t *rbuf ,uint8_t len); void IIC_DevWriteByte(IICDef i, uint8_t addr, uint8_t data); void IIC_DevWriteBuf(IICDef i, uint8_t addr, uint8_t *wbuf ,uint8_t len); /********************↑ declaration ↑***********************/ /** * * * * * */ /*********************↓ global variables ↓************************/ /*********************↑ global variables ↑************************/ /** * * * * * */ #endif /* APPLICATIONS_PERI_IIC_IIC_H_ */