Software I2C(IIC_Software)

The driver library is located in the
MPU6050/IIC_SOFTWARE
directory, which is only used in the car to make communication support for MPU6050

method

IIC_MPU6050_Init()

IIC pin of MPU6050 initialization

Return valuetype
nonevoid

IIC_Start()

Simulation IIC starting signal

Return valuetype
1int

IIC_Stop()

Simulation IIC end signal

Return valuetype
nonevoid

IIC_Wait_Ack()

IIC waiting to be answered

Return valuetype
0: No response; 1: Receive the answerint

IIC_Ack()

IIC response

Return valuetype
nonevoid

IIC_NAck()

IIC No Response

Return valuetype
nonevoid

IIC_Send_Byte(u8 txd)

IIC send a byte

parametertypeAnnotation
txdu8The byte data sent
Return valuetype
nonevoid

i2cWrite(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *data)

IIC writing data to the register

parametertypeAnnotation
addruint8_tDevice address
reguint8_tRegister address
lenuint8_tNumber of bytes
datauint8_t*data
Return valuetype
0: Successfully write; 1: Unsuccessful writingint

i2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)

IIC reader data

parametertypeAnnotation
addruint8_tDevice address
reguint8_tRegister address
lenuint8_tNumber of bytes
bufuint8_t*Read data cache
Return valuetype
0: Read it successfully; 1: No successfully read outint

IIC_Read_Byte(unsigned char ack)

IIC read a byte

parametertypeAnnotation
ackunsigned charWhether to send a response signal; 1: Send; 0: Do not send
Return valuetype
Receive: Reading datau8

I2C_ReadOneByte(unsigned char I2C_Addr, unsigned char addr)

Read a value of specified device specified register

parametertypeAnnotation
I2C_Addrunsigned charDevice IIC address
addrunsigned charRegister address
Return valuetype
Res: read dataunsigned char

IICreadBytes(u8 dev, u8 reg, u8 length, u8 *data)

IIC continuous reading data

parametertypeAnnotation
devu8Target device IIC address
regu8Register address
lengthu8Number of bytes
datau8*Reading data will be stored
Return valuetype
Count: Number of bytes read -1u8

IICwriteBytes(u8 dev, u8 reg, u8 length, u8* data)

Write multiple bytes into the specified device specified register

parametertypeAnnotation
devu8Target device address
regu8Register address
lengthu8Number of bytes to be written
datau8*The first address of the data to be written
Return valuetype
1: Is it successful?u8

IICreadByte(u8 dev, u8 reg, u8 *data)

Read a value of specified device specified register

parametertypeAnnotation
devu8Target device address
regu8Register address
datau8*Reading data will be stored
Return valuetype
1: Return whether it is successfulu8

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

parametertypeAnnotation
devunsigned charTarget device address
regunsigned charRegister address
dataunsigned charThe byte data sent
Return valuetype
1: Return whether it is successfulu8

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

parametertypeAnnotation
devu8Target device address
regu8Register address
bitStartu8The starting position of the target byte
lengthu8The number of the target byte
datau8Stock the value of changing the target byte position
Return valuetype
1: Success; 0: Failu8

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

parametertypeAnnotation
devu8Target device address
regu8Register address
bitNumu8To modify the bitnum bit of the target byte
datau8At the time of 0, the target level will be clear, otherwise it will be placed
Return valuetype
1: Success; 0: Failu8