关于STM32F405单片机控制雷达模块lidar_lite_v3程序及说明

#include "stm32f4_iic.h"
#include "lidar_lite_v3.h"
#include "stm32f4_delay.h"


uint8_t WriteBuffer = 0x55,ReadBuffer = 0,ret;
uint8_t ReadData[2];


void lidar_lite_v3_init(void)
{
//WriteBuffer = 0x00;
//ret = I2C_Write(Open_I2C,0xC4,0x00,&WriteBuffer,sizeof(WriteBuffer));
WriteBuffer = 0x80;
ret = I2C_Write(Open_I2C,0xC4,0x02,&WriteBuffer,sizeof(WriteBuffer));
WriteBuffer = 0x08;
ret = I2C_Write(Open_I2C,0xC4,0x04,&WriteBuffer,sizeof(WriteBuffer));
WriteBuffer = 0x00;
ret = I2C_Write(Open_I2C,0xC4,0x1c,&WriteBuffer,sizeof(WriteBuffer));
ret = I2C_Read(Open_I2C,0xC4,0x02,&ReadBuffer,sizeof(ReadBuffer));
ret = I2C_Read(Open_I2C,0xC4,0x04,&ReadBuffer,sizeof(ReadBuffer));
ret = I2C_Read(Open_I2C,0xC4,0x1c,&ReadBuffer,sizeof(ReadBuffer));
//WriteBuffer = 0xaa;
}


void lidar_test(void)
{
while(1)
{
WriteBuffer = 0x04;
ret = I2C_Write(Open_I2C,0xC4,0x00,&WriteBuffer,sizeof(WriteBuffer));
Delay_10us(2);
while(1)
{
WriteBuffer = 0x01;
ret = I2C_Write(Open_I2C,0xC4,0x01,&WriteBuffer,sizeof(WriteBuffer));
ret = I2C_Read(Open_I2C,0xC4,0x01,&ReadBuffer,sizeof(ReadBuffer));
if((ReadBuffer&0x01) == 0)
{
ret = I2C_Read(Open_I2C,0xC4,0x8f,ReadData,sizeof(ReadData));
break;
}
}
/*ret = I2C_Read(Open_I2C,0xC4,0x45,&ReadBuffer,sizeof(ReadBuffer));
Delay_10us(2);
ret = I2C_Write(Open_I2C,0xC4,0x45,&WriteBuffer,sizeof(WriteBuffer));
ret = I2C_Read(Open_I2C,0xC4,0x45,&ReadBuffer,sizeof(ReadBuffer));*/
}
}

你可能感兴趣的:(嵌入式MCU)