Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Sample_manerine_SPI_LSM9DS0 by
Revision 2:0d90c0436797, committed 2016-09-01
- Comitter:
- open4416
- Date:
- Thu Sep 01 17:14:29 2016 +0000
- Parent:
- 1:b42c3522a50a
- Child:
- 3:502b83f7761c
- Commit message:
- serial out Ax Wx
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 01 16:37:11 2016 +0000
+++ b/main.cpp Thu Sep 01 17:14:29 2016 +0000
@@ -9,7 +9,7 @@
DigitalOut led(D13); //detection
DigitalOut TT_ext(D12);
-//~~~SPI~~~//
+//~~~IMU_SPI~~~//
DigitalOut SPI_CSG(D7,1); //low for GYRO enable
DigitalOut SPI_CSXM(D6,1); //low for ACC/MAG enable
SPI spi(D4, D5, D3); //MOSI MISO SCLK
@@ -24,6 +24,18 @@
//~~~globle~~~//
Ticker TT; //call a timer
int count = 0; //one second counter for extrenal led blink
+
+//~~~IMU_SPI~~~//
+short low_byte = 0x00; //buffer
+short high_byte = 0x00;
+
+short Wx = 0x00;
+short Wy = 0x00;
+short Wz = 0x00;
+
+short Ax = 0x00;
+short Ay = 0x00;
+short Az = 0x00;
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑end of Varible registor↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑//
@@ -96,7 +108,6 @@
spi.write(CTRL_REG2_XM);
spi.write(0xC0); //cut off 50 Hz/ Scale +-2g
SPI_CSXM = 1; //end spi talking
-
}
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑end of init_IMU funtion↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑//
@@ -113,17 +124,20 @@
count = count+1; //one second counter
SPI_CSG = 0; //start spi talking
- spi.write(0x8f); //read WHO_AM_I_G 0x0f | B1000 0000
- int temp = spi.write(0);
+ spi.write(0xE8); //read B11101000 read/multi/address
+ low_byte = spi.write(0);
+ high_byte = spi.write(0);
+ Wx = high_byte << 8 |low_byte;
SPI_CSG = 1; //end spi talking
SPI_CSXM = 0; //start spi talking
- spi.write(0x8f); //read WHO_AM_I_XM 0x0f | B1000 0000
- int temp2 = spi.write(0);
+ spi.write(0xE8); //read B11101000 read/multi/address
+ low_byte = spi.write(0);
+ high_byte = spi.write(0);
+ Ax = high_byte << 8 |low_byte;
SPI_CSXM = 1; //end spi talking
- pc.printf("who_am_I_G:%d\t", temp);
- pc.printf("who_am_I_XM:%d\n", temp2);
+ pc.printf("%d\t%d\n", Wx, Ax);
}
//↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑end of Timebase funtion↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑//
\ No newline at end of file
