boards/arm/tiva: mpu6050 driver binding to TM4C1294

Fixed printf warning during compilation and added MPU6050 to bringup of tm4c.
This commit is contained in:
Filipe Cavalcanti
2023-05-06 17:05:20 -03:00
committed by Alan Carvalho de Assis
parent 2b51111030
commit 9355bd9d01
2 changed files with 63 additions and 1 deletions
+2 -1
View File
@@ -973,7 +973,8 @@ static void tiva_i2c_tracedump(struct tiva_i2c_priv_s *priv)
{
trace = &priv->trace[i];
syslog(LOG_DEBUG,
"%2d. STATUS: %08x COUNT: %3d EVENT: %2d PARM: %08x TIME: %d\n",
"%2d. STATUS: %08lx COUNT: %3ld EVENT: %2d PARM: %08lx "
"TIME: %ld\n",
i + 1, trace->status, trace->count, trace->event, trace->parm,
trace->time - priv->ttime);
}
@@ -30,6 +30,7 @@
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/sensors/bmi160.h>
#include <nuttx/sensors/mpu60x0.h>
#include <nuttx/sensors/qencoder.h>
#include <arch/board/board.h>
#include <nuttx/fs/fs.h>
@@ -192,6 +193,58 @@ static int tm4c_bmi160_setup(int bus)
}
#endif
/****************************************************************************
* Name: tm4c_mpu60x0_setup
*
* Description:
* Initialize and register the Invensense MPU60x0 sensor.
*
* Input Parameters:
* bus - A number identifying the I2C bus.
*
* Returned Value:
* On success, zero (OK) is returned. On failure, a negated errno value
* is returned to indicate the nature of the failure.
*
****************************************************************************/
#ifdef CONFIG_SENSORS_MPU60X0
static int tm4c_mpu60x0_setup(int bus)
{
int ret;
struct i2c_master_s *i2c;
struct mpu_config_s *mpu_config;
/* Initialize i2c device */
i2c = tiva_i2cbus_initialize(bus);
if (!i2c)
{
syslog(LOG_ERR, "ERROR: Failed to initialize i2c%d.\n", bus);
return -ENODEV;
}
mpu_config = kmm_zalloc(sizeof(struct mpu_config_s));
if (mpu_config == NULL)
{
syslog(LOG_ERR, "ERROR: Failed to allocate mpu60x0 driver\n");
return -ENOMEM;
}
else
{
mpu_config->i2c = i2c;
mpu_config->addr = 0x68;
ret = mpu60x0_register("/dev/imu0", mpu_config);
if (ret < 0)
{
syslog(LOG_ERR, "Error registering MPU60X0\n");
}
}
return ret;
}
#endif
/****************************************************************************
* Name: tm4c_pwm_register
*
@@ -366,6 +419,14 @@ int tm4c_bringup(void)
#endif
#endif
#ifdef CONFIG_SENSORS_MPU60X0
ret = tm4c_mpu60x0_setup(0);
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: MPU60X0 on I2C0 failed %d\n", ret);
}
#endif
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */