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 IMU_Aq by
Revision 1:92e66f3dbb78, committed 2016-02-23
- Comitter:
- adam_z
- Date:
- Tue Feb 23 08:49:02 2016 +0000
- Parent:
- 0:2c03c9f00e49
- Commit message:
- output remain constant
Changed in this revision
LSM6DS3.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2c03c9f00e49 -r 92e66f3dbb78 LSM6DS3.lib --- a/LSM6DS3.lib Fri Feb 19 09:52:24 2016 +0000 +++ b/LSM6DS3.lib Tue Feb 23 08:49:02 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/teams/adamchuang/code/LSM6DS3/#301b2cb34ead +https://developer.mbed.org/teams/adamchuang/code/LSM6DS3/#c19d384b2896
diff -r 2c03c9f00e49 -r 92e66f3dbb78 main.cpp --- a/main.cpp Fri Feb 19 09:52:24 2016 +0000 +++ b/main.cpp Tue Feb 23 08:49:02 2016 +0000 @@ -1,18 +1,42 @@ #include "mbed.h" -PwmOut mypwm(PWM_OUT); - -DigitalOut myled(LED1); - +#include "LSM6DS3.h" +#include "LSM6DS3_Types.h" +#include "LSM6DS3_Registers.h" +/* +SPI device(SPI_MOSI, SPI_MISO, SPI_SCK); +DigitalOut cs(SPI_CS); +//DigitalOut led(LED1); int main() { - - mypwm.period_ms(10); - mypwm.pulsewidth_ms(1); - - printf("pwm set to %.2f %%\n", mypwm.read() * 100); - - while(1) { - myled = !myled; - wait(1); + int i = 0; + while(1) { + //device.write(0x55); + cs = 0; + device.write(i++); + //device.write(0xE0); + cs = 1; + //led = !led; + wait_us(50); + } +}*/ + +LSM6DS3 sensor(SPI_MODE, SPI_SCK); +Serial pc(USBTX,USBRX); +int main() +{ + if( sensor.begin() != 0 ) { + pc.printf("Problem starting the sensor with CS @ Pin PB_6.\r\n"); + } else { + pc.printf("Sensor with CS @ Pin PB_6 started.\r\n"); } -} + sensor.setOffset(-141, 154, 82, 38, -79, -28); + while(true) { + float data_array[12]; + + data_array[0] = sensor.readRawAccelX(); + data_array[1] = sensor.readRawAccelY(); + data_array[8] = sensor.readRawGyroZ(); + pc.printf("Accel X: %d\r\n", data_array[8]); + + } +} \ No newline at end of file