第一次提交

This commit is contained in:
2026-05-29 17:36:34 +08:00
commit 5b3333125d
1318 changed files with 722705 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
#include "tfminiplus.h"
#include "stdlib.h"
#include "bsp_dwt.h"
static TFMiniInstance *tfmini;
TFMiniInstance *TFMiniRegister(I2C_HandleTypeDef *hi2c)
{
tfmini = (TFMiniInstance *)malloc(sizeof(TFMiniInstance));
IIC_Init_Config_s conf = {
.handle = hi2c,
.dev_address = 0x10,
.id = tfmini,
.work_mode = IIC_BLOCK_MODE,
};
tfmini->iic = IICRegister(&conf);
DWT_Delay(0.5);
return tfmini;
}
float GetDistance(TFMiniInstance *tfmini)
{
uint8_t cmd_buf[5] = {0x5A, 0x05, 0x00, 0x06, 0x65};
IICTransmit(tfmini->iic, cmd_buf, 5, IIC_SEQ_RELEASE);
IICReceive(tfmini->iic, tfmini->buf, 11, IIC_SEQ_RELEASE);
tfmini->Mode = tfmini->buf[6];
tfmini->Dist = (uint16_t)tfmini->buf[2] + (((uint16_t)tfmini->buf[3]) << 8);
tfmini->Strength = tfmini->buf[4] | (tfmini->buf[5] << 8);
return tfmini->Dist;
}
+20
View File
@@ -0,0 +1,20 @@
#ifndef __TFMINIPLUS_H__
#define __TFMINIPLUS_H__
#include "stdint.h"
#include "bsp_iic.h"
typedef struct
{
IICInstance *iic;
uint8_t Mode; //= buf[6];
uint16_t Dist; //= buf[2] | (buf[3] << 8);
uint32_t Strength; //= buf[4] | (buf[5] << 8);
uint8_t buf[9];
} TFMiniInstance;
TFMiniInstance *TFMiniRegister(I2C_HandleTypeDef *hi2c);
float GetDistance(TFMiniInstance *tfmini);
#endif
+3
View File
@@ -0,0 +1,3 @@
# tfminiplus
北醒激光单点激光雷达模块的简单实现。目前使用iic阻塞通信耗时和速度都太慢,需修改为中断读取,bsp_iic已经提供相应的接口。