method
IIC_MPU6050_Init()
IIC pin of MPU6050 initialization
| Return value | type |
| none | void |
IIC_Start()
Simulation IIC starting signal
IIC_Stop()
Simulation IIC end signal
| Return value | type |
| none | void |
IIC_Wait_Ack()
IIC waiting to be answered
| Return value | type |
| 0: No response; 1: Receive the answer | int |
IIC_Ack()
IIC response
| Return value | type |
| none | void |
IIC_NAck()
IIC No Response
| Return value | type |
| none | void |
IIC_Send_Byte(u8 txd)
IIC send a byte
| parameter | type | Annotation |
| txd | u8 | The byte data sent |
| Return value | type |
| none | void |
i2cWrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *data)
IIC writing data to the register
| parameter | type | Annotation |
| addr | uint8_t | Device address |
| reg | uint8_t | Register address |
| len | uint8_t | Number of bytes |
| data | uint8_t* | data |
| Return value | type |
| 0: Successfully write; 1: Unsuccessful writing | int |
i2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
IIC reader data
| parameter | type | Annotation |
| addr | uint8_t | Device address |
| reg | uint8_t | Register address |
| len | uint8_t | Number of bytes |
| buf | uint8_t* | Read data cache |
| Return value | type |
| 0: Read it successfully; 1: No successfully read out | int |
IIC_Read_Byte(unsigned char ack)
IIC read a byte
| parameter | type | Annotation |
| ack | unsigned char | Whether to send a response signal; 1: Send; 0: Do not send |
| Return value | type |
| Receive: Reading data | u8 |
I2C_ReadOneByte(unsigned char I2C_Addr, unsigned char addr)
Read a value of specified device specified register
| parameter | type | Annotation |
| I2C_Addr | unsigned char | Device IIC address |
| addr | unsigned char | Register address |
| Return value | type |
| Res: read data | unsigned char |
IICreadBytes(u8 dev, u8 reg, u8 length, u8 *data)
IIC continuous reading data
| parameter | type | Annotation |
| dev | u8 | Target device IIC address |
| reg | u8 | Register address |
| length | u8 | Number of bytes |
| data | u8* | Reading data will be stored |
| Return value | type |
| Count: Number of bytes read -1 | u8 |
IICwriteBytes(u8 dev, u8 reg, u8 length, u8* data)
Write multiple bytes into the specified device specified register
| parameter | type | Annotation |
| dev | u8 | Target device address |
| reg | u8 | Register address |
| length | u8 | Number of bytes to be written |
| data | u8* | The first address of the data to be written |
| Return value | type |
| 1: Is it successful? | u8 |
IICreadByte(u8 dev, u8 reg, u8 *data)
Read a value of specified device specified register
| parameter | type | Annotation |
| dev | u8 | Target device address |
| reg | u8 | Register address |
| data | u8* | Reading data will be stored |
| Return value | type |
| 1: Return whether it is successful | u8 |
IICwriteByte(unsigned char dev, unsigned char reg, unsigned char data)
Write a device specified by the designated device to specify a byte of the register
| parameter | type | Annotation |
| dev | unsigned char | Target device address |
| reg | unsigned char | Register address |
| data | unsigned char | The byte data sent |
| Return value | type |
| 1: Return whether it is successful | u8 |
IICwriteBits(u8 dev, u8 reg, u8 bitStart, u8 length, u8 data)
Reading, modifying, and writing a specified device specifies multiple bits in a byte of the register
| parameter | type | Annotation |
| dev | u8 | Target device address |
| reg | u8 | Register address |
| bitStart | u8 | The starting position of the target byte |
| length | u8 | The number of the target byte |
| data | u8 | Stock the value of changing the target byte position |
| Return value | type |
| 1: Success; 0: Fail | u8 |
IICwriteBit(u8 dev, u8 reg, u8 bitNum, u8 data)
Read, modify, and write a specified device to specify 1 digit in a byte of the register
| parameter | type | Annotation |
| dev | u8 | Target device address |
| reg | u8 | Register address |
| bitNum | u8 | To modify the bitnum bit of the target byte |
| data | u8 | At the time of 0, the target level will be clear, otherwise it will be placed |
| Return value | type |
| 1: Success; 0: Fail | u8 |