công cụ tìm kiếm bảng dữ liệu linh kiện điện tử
  Vietnamese  ▼
ALLDATASHEET.VN

X  

AN4545 bảng dữ liệu(PDF) 20 Page - STMicroelectronics

tên linh kiện AN4545
Giải thích chi tiết về linh kiện  VL6180X basic ranging application note
PDF  27 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
nhà sản xuất  STMICROELECTRONICS [STMicroelectronics]
Trang chủ  http://www.st.com
Logo STMICROELECTRONICS - STMicroelectronics

AN4545 bảng dữ liệu(HTML) 20 Page - STMicroelectronics

Back Button AN4545 Datasheet HTML 16Page - STMicroelectronics AN4545 Datasheet HTML 17Page - STMicroelectronics AN4545 Datasheet HTML 18Page - STMicroelectronics AN4545 Datasheet HTML 19Page - STMicroelectronics AN4545 Datasheet HTML 20Page - STMicroelectronics AN4545 Datasheet HTML 21Page - STMicroelectronics AN4545 Datasheet HTML 22Page - STMicroelectronics AN4545 Datasheet HTML 23Page - STMicroelectronics AN4545 Datasheet HTML 24Page - STMicroelectronics Next Button
Zoom Inzoom in Zoom Outzoom out
 20 / 27 page
background image
Example code
AN4545
20/27
DocID026571 Rev 1
7
Example code
Below is example code on how to perform ranging with VL6180X using single shot mode.
The code is based on the STM32 F401 Nucleo board and can be compiled using the mbed
Compiler.
///////////////////////////////////////////////////////////////////
// Beginning of code
///////////////////////////////////////////////////////////////////
#include "mbed.h"
Serial pc(SERIAL_TX, SERIAL_RX); // set-up serial to pc
I2C i2c(I2C_SDA, I2C_SCL); // Set up I²C on the STM32 NUCLEO-401RE
#define addr
(0x52) // I²C address of VL6180X shifted by 1 bit
//(0x29 << 1) so the R/W command can be added
///////////////////////////////////////////////////////////////////
// Split 16-bit register address into two bytes and write
// the address + data via I²C
///////////////////////////////////////////////////////////////////
void WriteByte(wchar_t reg,char data) {
char data_write[3];
data_write[0] = (reg >> 8) & 0xFF;; // MSB of register address
data_write[1] = reg
&
0xFF; // LSB of register address
data_write[2] = data & 0xFF;
i2c.write(addr, data_write, 3);
}
///////////////////////////////////////////////////////////////////
// Split 16-bit register address into two bytes and write
// required register address to VL6180X and read the data back
///////////////////////////////////////////////////////////////////
char ReadByte(wchar_t reg) {
char data_write[2];
char data_read[1];
data_write[0] = (reg >> 8) & 0xFF; // MSB of register address
data_write[1] = reg
&
0xFF; // LSB of register address
i2c.write(addr, data_write, 2);
i2c.read(addr, data_read, 1);
return
data_read[0];
}
///////////////////////////////////////////////////////////////////
// load settings



Html Pages

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27


bảng dữ liệu tải về

Go To PDF Page


Link URL



Cho đến nay ALLDATASHEET có giúp ích cho doanh nghiệp của bạn hay không?  [ DONATE ] 

Alldatasheet là   |   Quảng cáo   |   Liên lạc với chúng tôi   |   Chính sách bảo mật   |   Liên kết đến bảng dữ liệu    |   Trao đổi link   |   Tìm kiếm theo nhà sản xuất
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com