Yunhorn_OLD_R1_R2_R5/Inc/tof.h

46 lines
1.9 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 定义防止递归包含 ----------------------------------------------------------*/
#ifndef _TOF_H
#define _TOF_H
/* 包含的头文件 --------------------------------------------------------------*/
//#include <stdbool.h>
#include "main.h"
#include "i2c_user.h"
/* 宏定义 --------------------------------------------------------------------*/
#define TOF_DEV_ADDR 0x52 //从机地址
#define TOF_DEV_ADDR_Difference 0x02 //从机地址等差
#define TOF_DIS_ADDR 0x00 //滤波距离数据地址
#define TOF_DIS_LENGTH 0x02 //数据长度
#define TOF_WR 0x00 //写
#define TOF_RD 0x01 //读
#define TOF_DIS_EN 0x0032//50mm
#define TOF_DIS_OVER 0x00FF//255mm
#define TOF_DIS_LIMIT 0x09C4
#define TOF_DIS_INVALID 0x22B8 //Invalid distance range
#define TOF_DEV_MAX_COUNT 2 //最大传感器数量
#define TOF_DIS_LEVEL1 0x01F4 //距离档位1500mm
#define TOF_DIS_LEVEL2 0x03E8 //距离档位21000mm
#define TOF_DIS_LEVEL3 0x05DC //距离档位31500mm
#define u8 uint8_t
#define u16 uint16_t
/* 函数申明 ------------------------------------------------------------------*/
uint16_t Get_Real_TOF_Distance(uint16_t Dev_Addr);//ok
void Get_Real_TOF_Distance_to_u8Table(uint16_t Dev_Addr,uint8_t *buf);//ok
uint8_t Get_Real_TOF_Distance_to_u8_Low_mm(uint16_t Dev_Addr);//ok
uint8_t Get_Real_TOF_Distance_to_u8_Lose_cm(uint16_t Dev_Addr);//ok
bool Get_Real_TOF_Distance_to_bool(uint16_t Dev_Addr);//ok
void Get_TOF_Count(uint8_t *buf,uint16_t level);//ok
void Get_TOF_Data(u8 *buf,u16 count);
u16 Get_TOF_Distance(u16 Dev_Addr);
#endif