找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

zigbee cc2530裸机模拟IIC接口程序 实现VL53L0X激光测距

查看数: 6273 | 评论数: 6 | 收藏 3
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2019-4-13 14:58

正文摘要:

采用IAR环境,实现普通模块测距,串口输出数据。 代码如下: #include "VL53L0.h" #include "myiic.h" uint16_t bswap(u8 b[]) {         uint16_t val = ((b[0]< ...

回复

ID:735263 发表于 2020-4-26 23:59
好资料
ID:140706 发表于 2019-10-3 14:48
非常不错的资料,值得参考,谢谢啦
ID:140706 发表于 2019-10-3 14:47
非常不错的资料,值得参考
无效楼层,该帖已经被删除
ID:471057 发表于 2019-4-13 15:03
这个才是 main.c

/**************************************/
/*           WeBee团队                */
/*         Zigbee学习例程             */
/*例程名称:                         */
/*建立时间:2012/04/18               */
/*描述:main
**************************************/
#include <ioCC2530.h>
#include "type.h"
#include "clock.h"
#include "uart.h"
#include "VL53L0.h"
#include "myiic.h"
#include "delay.h"

void main(void)
{   
  clockInit();
  uartInit();
  IIC_Init();
  u8 val = 0;
  u8 gbuf[16];
  uint32_t cnt = 0;
//  uint16_t count[3];
  
  while(1)
  {
    VL53L0X_Write_Byte(VL53L0X_REG_SYSRANGE_START, 0x01);//启动检测
    while(cnt < 100)//当检测完成,即读取距离值
    {
      delay_ms(10);
      val = VL53L0X_Read_Byte(VL53L0X_REG_RESULT_RANGE_STATUS);
      if( val & 0x01) break;
      cnt++;
    }
//    if( val & 0x01)
//      uartSendString("\r\n readey \r\n",12);
//    else
//      uartSendString("\r\n NOT readey \r\n",16);
    VL53L0X_Read_Len(VL53L0X_Add, 0x14 , 12, gbuf);//读取数据
//    count[0] = makeuint16(gbuf[7], gbuf[6]);//ambient count
//    count[1] = makeuint16(gbuf[9], gbuf[8]);//signal count
//    count[2] = makeuint16(gbuf[11], gbuf[10]);//距离
//    DeviceRangeStatusInternal = ((gbuf[0] & 0x78) >> 3);//status
   
    //打印距离值
    uartPutInt16(makeuint16(gbuf[11], gbuf[10]));
    delay_ms(500);
  }
}
ID:471057 发表于 2019-4-13 15:01
由于CC2530是无IIC硬件支持的,所以写了一个,上面应该是采用普通测距模式,由于该芯片是不提供测距函数的,因此是根据ARDUINO的原码移植的。

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表