EasyManua.ls Logo

ST VL6180X - Page 21

ST VL6180X
27 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
DocID026571 Rev 1 21/27
AN4545 Example code
27
///////////////////////////////////////////////////////////////////
int VL6180X_Init() {
char reset;
reset = ReadByte(0x016);
if (reset==1){ // check to see has it be Initialised already
///////////////////////////////////////////////////////////////////
// Added latest settings here - see Section 8
///////////////////////////////////////////////////////////////////
WriteByte(0x016, 0x00); //change fresh out of set status to 0
}
return 0;
}
///////////////////////////////////////////////////////////////////
// Start a range measurement in single shot mode
///////////////////////////////////////////////////////////////////
int VL6180X_Start_Range() {
WriteByte(0x018,0x01);
return 0;
}
///////////////////////////////////////////////////////////////////
// poll for new sample ready ready
///////////////////////////////////////////////////////////////////
int VL6180X_Poll_Range() {
char status;
char range_status;
// check the status
status = ReadByte(0x04f);
range_status = status & 0x07;
// wait for new measurement ready status
while (range_status != 0x04) {
status = ReadByte(0x04f);
range_status = status & 0x07
;
wait_ms(1); // (can be removed)
}
return 0;
}
///////////////////////////////////////////////////////////////////
// Read range result (mm)
///////////////////////////////////////////////////////////////////
int VL6180X_Read_Range() {

Related product manuals