好资料 |
非常不错的资料,值得参考,谢谢啦 |
非常不错的资料,值得参考 |
这个才是 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); } } |
由于CC2530是无IIC硬件支持的,所以写了一个,上面应该是采用普通测距模式,由于该芯片是不提供测距函数的,因此是根据ARDUINO的原码移植的。 |