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.
Dependencies: mbed-dev
Fork of Adafruit9-DOf_AHRS_Regler_Discrete by
Diff: Source/Adafruit_L3GD20_U.cpp
- Revision:
- 1:8c4f93e10af3
- Parent:
- 0:772bf4786416
- Child:
- 3:cc828af4a4c6
--- a/Source/Adafruit_L3GD20_U.cpp Sat Mar 21 12:33:05 2015 +0000
+++ b/Source/Adafruit_L3GD20_U.cpp Thu Oct 19 11:50:04 2017 +0000
@@ -73,13 +73,15 @@
{
- /* Set the range the an appropriate value */
+ /* Set the range to an appropriate value */
_range = rng;
/* Make sure we have the correct chip ID since this checks
for correct address and that the IC is properly connected */
- uint8_t id = read8(GYRO_REGISTER_WHO_AM_I);
- //Serial.println(id, HEX);
+ uint8_t id = 0;
+ id = read8(GYRO_REGISTER_WHO_AM_I);
+ Serial serial( USBTX, USBRX);
+ serial.printf("WHOAMI Gyro %d \r\n", id);
if ((id != L3GD20_ID) && (id != L3GD20H_ID))
{
return false;
@@ -97,8 +99,8 @@
0 XEN X-axis enable (0 = disabled, 1 = enabled) 1 */
/* Reset then switch to normal mode and enable all three channels */
- write8(GYRO_REGISTER_CTRL_REG1, 0x00);
- write8(GYRO_REGISTER_CTRL_REG1, 0x0F);
+ write8(GYRO_REGISTER_CTRL_REG1, 0x80);
+ write8(GYRO_REGISTER_CTRL_REG1, 0xBF);// 380 Hz; 100 Hz cutoff LPF1
/* ------------------------------------------------------------------ */
/* Set CTRL_REG2 (0x21)
@@ -107,10 +109,10 @@
--- ------ --------------------------------------------- -------
5-4 HPM1/0 High-pass filter mode selection 00
3-0 HPCF3..0 High-pass filter cutoff frequency selection 0000 */
-
+
/* Nothing to do ... keep default values */
/* ------------------------------------------------------------------ */
-
+ // -> High-pass cutoff frequency: 27 Hz
/* Set CTRL_REG3 (0x22)
====================================================================
BIT Symbol Description Default
@@ -210,8 +212,13 @@
/* Shift values to create properly formed integer (low byte first) */
event->gyro.x = (int16_t)(data[0] | (data[1] << 8));
+ raw.x = (int16_t)(data[0] | (data[1] << 8));
+
event->gyro.y = (int16_t)(data[2] | (data[3] << 8));
+ raw.y = (int16_t)(data[2] | (data[3] << 8));
+
event->gyro.z = (int16_t)(data[4] | (data[5] << 8));
+ raw.y = (int16_t)(data[4] | (data[5] << 8));
/* Make sure the sensor isn't saturating if auto-ranging is enabled */
if (!_autoRangeEnabled)
