95
To write multiple byte values, developer can change step 4 to:
write(file, &szData8, sizeof(szData8)); // where szData is an array of bytes
G-sensor Control
The ADI ADXL345 provides I2C and SPI interfaces. I2C interface is used by setting the CS pin to
high on this DE1_SoC board.
The ADI ADXL345 G-sensor provides user-selectable resolution up to 13-bit
±
16g. The
resolution can be configured through the DATA_FORAMT(0x31) register. In the demonstration, we
configure the data format as:
Full resolution mode
±
16g range mode
Left-justified mode
The X/Y/Z data value can be derived from the DATAX0(0x32), DATAX1(0x33), DATAY0(0x34),
DATAY1(0x35), DATAZ0(0x36), and DATAX1(0x37) registers. The DATAX0 represents the least
significant byte, and DATAX1 represents the most significant byte. It is recommended to perform
multiple-byte read of all registers to prevent change in data between reads of sequential registers.
Developer can use the following statement to read 6 bytes of X, Y, or Z value.
read(file, szData8, sizeof(szData8)); // where szData is an array of six-bytes
Demonstration Source Code
Build tool: Altera SoC EDS v13.0
Project directory: \Demonstration\SoC\hps_gsensor
Binary file: gsensor
Build command: make ('make clean' to remove all temporal files)
Execute command: ./gsensor [loop count]
Demonstration Setup
Connect the USB cable to the USB-to-UART connector (J4) on the DE1_SoC board and host
PC.
Make sure the executable file "
gsensor
" is copied into the SD card under the "
/home/root
"
folder in Linux.
Insert the booting micro sdcard into the DE1_SoC board.
Summary of Contents for DE1-SOC
Page 1: ...1...
Page 108: ...107 Figure 8 4 Select Devices Page...