Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CaroloCup
FreeRTOSHAL
fhal-driver
Commits
7aeafca1
Commit
7aeafca1
authored
Feb 08, 2022
by
Andreas Werner
Browse files
MPU9250: add debug output and missing get ID
parent
1b04e9f1
Changes
3
Hide whitespace changes
Inline
Side-by-side
include/mpu9250.h
View file @
7aeafca1
...
...
@@ -534,5 +534,7 @@ extern const struct accel_ops mpu9250_accel_ops;
* Get MPU9250 based on id
*/
#define MPU9250_ID(id) HAL_GET_ID(hal, mpu9250, mpu9250_##id)
#define MPU9250_GYRO_ID(id) HAL_GET_ID(gyro, mpu9250, mpu9250_gyro_##id)
#define MPU9250_ACCEL_ID(id) HAL_GET_ID(accel, mpu9250, mpu9250_accel_##id)
/**\}*/
#endif
sensor/icm20948.c
View file @
7aeafca1
...
...
@@ -254,28 +254,34 @@ struct mpu9250 *mpu9250_init(uint32_t index, struct spi *spi, uint8_t cs, uint16
{
ret
=
mpu_send
(
mpu
,
MPU_GYRO_CONFIG_1
,
MPU_GYRO_CONFIG_1_GYRO_DLPFCFG
(
2
)
|
MPU_GYRO_CONFIG_1_GYRO_FCHOICE
|
MPU_GYRO_CONFIG_1_GYRO_FS_SEL_2000DPS
,
waittime
);
if
(
ret
<
0
)
{
PRINTF
(
"Send Config Failed
\n
"
);
goto
mpu9250_init_error2
;
}
/* Set sample rate to 1.125 kHz */
ret
=
mpu_send
(
mpu
,
MPU_GYRO_SMPLRT_DIV
,
0x0
,
waittime
);
if
(
ret
<
0
)
{
PRINTF
(
"Set sample rate to 1.125 kHz Failed
\n
"
);
goto
mpu9250_init_error2
;
}
/* Set sample rate to 1.125 kHz */
ret
=
mpu_send
(
mpu
,
MPU_ACCEL_SMPLRT_DIV_1
,
0x0
,
waittime
);
if
(
ret
<
0
)
{
PRINTF
(
"Set sample rate to 1.125 kHz Failed
\n
"
);
goto
mpu9250_init_error2
;
}
ret
=
mpu_send
(
mpu
,
MPU_ACCEL_SMPLRT_DIV_2
,
0x0
,
waittime
);
if
(
ret
<
0
)
{
PRINTF
(
"MPU_ACCEL_SMPLRT_DIV_2 Failed
\n
"
);
goto
mpu9250_init_error2
;
}
/* Set accelerometer full-scale to 2 g, maximum sensitivity, and set FCHOICE */
ret
=
mpu_send
(
mpu
,
MPU_ACCEL_CONFIG
,
MPU_ACCEL_CONFIG_ACCEL_FS_SEL_8G
|
MPU_ACCEL_CONFIG_ACCEL_FCHOICE
|
MPU_ACCEL_CONFIG_ACCEL_DLPFCFG
(
0
),
waittime
);
if
(
ret
<
0
)
{
PRINTF
(
"Set accelerometer full-scale to 2 g, maximum sensitivity, and set FCHOICE Failed
\n
"
);
goto
mpu9250_init_error2
;
}
}
PRINTF
(
"MPU Setup Completed
\n
"
);
return
mpu
;
mpu9250_init_error2:
spiSlave_deinit
(
mpu
->
slave
);
...
...
sensor/mpu9250.c
View file @
7aeafca1
...
...
@@ -244,7 +244,7 @@ struct mpu9250 *mpu9250_init(uint32_t index, struct spi *spi, uint8_t cs, uint16
goto
mpu9250_init_error2
;
}
PRINTF
(
"MPU Config"
);
PRINTF
(
"MPU Config
\n
"
);
{
ret
=
mpu_clearSetBit
(
mpu
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment