在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會員中心
創(chuàng)作中心

完善資料讓更多小伙伴認識你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

【Renesas RA6M4開發(fā)板之I2C讀取mpu6050】

RT-Thread單片機學習 ? 來源:RT-Thread單片機學習 ? 作者:RT-Thread單片機學習 ? 2023-01-17 09:07 ? 次閱讀

1.0 mpu6050

在這里插入圖片描述

此圖轉(zhuǎn)載欽源盛數(shù)碼專營店

本篇通過Renesas RA6M4開發(fā)板采用I2C讀取mpu6050傳感器的角加速度,角速度和溫度示例程序演示。

1.1 mpu6050介紹

MPU6050是一種非常流行的空間運動傳感器芯片,可以獲取器件當前的三個加速度分量和三個旋轉(zhuǎn)角速度。由于其體積小巧,功能強大,精度較高,不僅被廣泛應用于工業(yè),同時也是航模愛好者的神器,被安裝在各類飛行器上馳騁藍天。

1.2 mpu6050特點

使用芯片:MPU-6050

供電電源:3-5V(內(nèi)部低壓差穩(wěn)壓)

通信方式:標準lIC通信協(xié)議

芯片內(nèi)置16BITAD轉(zhuǎn)換器,16位數(shù)據(jù)輸出

陀螺儀范圍:±250 500 1000 2000 °/s

加速度范圍:±2±4±8±16G

溫度范圍:-20℃~60℃

采用沉金PCB,機器焊接工藝保證質(zhì)量

引腳間距2.54MM

需在氣體環(huán)境中工作,不可測量液體和反接電源

尺寸大小如下:

1.3 mpu6050應用運動感測游戲
現(xiàn)實增強
行人導航器
“零觸控”手勢用戶接口
姿勢快捷方式
認證
電子穩(wěn)像(EIS: Electronic lmage Stabilization )
光學穩(wěn)像(Ols: Optical lmage Stabilization )

  1. RT-theard配置 2.1 硬件需求1、需要mpu6050采集氣體環(huán)境下的氣壓和溫度,I2C通訊接線 SDA—p504;SCL—p506 ,不需要關(guān)注地址后面庫自帶配置了,與ssd1306不同

實現(xiàn)功能:
采用I2C讀取mpu6050傳感器的角加速度,角速度和溫度示例

2、RA6M4開發(fā)板

3、USB下載線,ch340串口和附帶6根母母線, rx—p613;tx—p614

2.2 軟件配置Renesas RA6M4開發(fā)板環(huán)境配置參照:【基于 RT-Thread Studio的CPK-RA6M4 開發(fā)板環(huán)境搭建】
1、新建項目RA6M4-mpu6050工程

2、點擊RT-theard Setting,在軟件包下添加軟件包,然后搜索mpu相關(guān)軟件支持包,點擊添加即可,然后出現(xiàn)對應包。

3、配置ssd306,右鍵選擇配置項

4、在軟件包中開啟示例程序。

5、在硬件中,啟動I2C,設(shè)置端口SDA—p505;SCL—p506

6、全部保存剛剛的配置,更新當前配置文件

保存完是灰色,沒有保存是藍色。

  1. 代碼分析1、剛剛加載軟件包在packages文件夾下,

mpu6xxx.c代碼更改為如下
(或者頭文件添加#include "bsp_api.h",否則會報錯unitx_t,根據(jù)提示全部改為rt_unitx_t也OK,下面是第二種方法,增加了手動校準)
mpu6xxx.c

/* * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-10-23 flybreak the first version * 2021-09-09 scratch-er added setting and getting sensor offsets */

#include 
    
#include 
    

#include 
    
#include 
    

#define DBG_TAG "mpu6xxx"
#define DBG_LVL DBG_INFO
#include 
    

#include "mpu6xxx.h"
#include "mpu6xxx_reg.h"

#ifdef PKG_USING_MPU6XXX_MAG
#include "ak8963_reg.h"
#endif

#define MPU6XXX_ACCEL_SEN (16384)
#define MPU6XXX_GYRO_SEN (1310)

#define MPU60X0_SPI_MAX_SPEED (1000 * 1000)
#define MPU60X0_TEMP_SEN (340)
#define MPU60X0_TEMP_OFFSET (36.5)

#define MPU6500_TEMP_SEN (333.87)
#define MPU6500_TEMP_OFFSET (21)

// MAG
#define AK8963_RANGE (4912)
#define AK8963_FULLSCALE (32760)

/** * This function writes the value of the register for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param data value to write * * @return the writing status, RT_EOK reprensents writing the value of the register successfully. */
static rt_err_t mpu6xxx_write_reg(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t data)
{
   
    rt_int8_t res = 0;
#ifdef RT_USING_I2C
    struct rt_i2c_msg msgs;
    rt_uint8_t buf[2] = {
   reg, data};
#endif
    if (dev->bus->type == RT_Device_Class_I2CBUS)
    {
   
#ifdef RT_USING_I2C
        msgs.addr  = dev->i2c_addr;    /* slave address */
        msgs.flags = RT_I2C_WR;        /* write flag */
        msgs.buf   = buf;              /* Send data pointer */
        msgs.len   = 2;

        if (rt_i2c_transfer((struct rt_i2c_bus_device *)dev->bus, &msgs, 1) == 1)
        {
   
            res = RT_EOK;
        }
        else
        {
   
            res = -RT_ERROR;
        }
#endif
    }
    else
    {
   
#ifdef RT_USING_SPI
        res = rt_spi_send_then_send((struct rt_spi_device *)dev->bus, ®, 1, &data, 1);
#endif
    }
    return res;
}

/** * This function reads the value of registers for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param len number of register * @param buf read data pointer * * @return the reading status, RT_EOK reprensents reading the value of registers successfully. */
static rt_err_t mpu6xxx_read_regs(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t len, rt_uint8_t *buf)
{
   
    rt_int8_t res = 0;
#ifdef RT_USING_I2C
    struct rt_i2c_msg msgs[2];
#endif
#ifdef RT_USING_SPI
    rt_uint8_t tmp;
#endif
    if (dev->bus->type == RT_Device_Class_I2CBUS)
    {
   
#ifdef RT_USING_I2C
        msgs[0].addr  = dev->i2c_addr;    /* Slave address */
        msgs[0].flags = RT_I2C_WR;        /* Write flag */
        msgs[0].buf   = ®             /* Slave register address */
        msgs[0].len   = 1;                /* Number of bytes sent */

        msgs[1].addr  = dev->i2c_addr;    /* Slave address */
        msgs[1].flags = RT_I2C_RD;        /* Read flag */
        msgs[1].buf   = buf;              /* Read data pointer */
        msgs[1].len   = len;              /* Number of bytes read */

        if (rt_i2c_transfer((struct rt_i2c_bus_device *)dev->bus, msgs, 2) == 2)
        {
   
            res = RT_EOK;
        }
        else
        {
   
            res = -RT_ERROR;
        }
#endif
    }
    else
    {
   
#ifdef RT_USING_SPI
        //The first bit of the first byte contains the Read/Write bit and indicates the Read (1) or Write (0) operation.
        tmp = reg | 0x80;

        res = rt_spi_send_then_recv((struct rt_spi_device *)dev->bus, &tmp, 1, buf, len);
#endif
    }
    return res;
}

/** * This function writes a bit value of registers for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param bit the position of the register * @param data value to write * * @return the writing status, RT_EOK reprensents writing a bit value of registers successfully. */
static rt_err_t mpu6xxx_write_bit(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t bit, rt_uint8_t data)
{
   
    rt_uint8_t byte;
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, reg, 1, &byte);
    if (res != RT_EOK)
    {
   
        return res;
    }

    byte = (data != 0) ? (byte | (1 << bit)) : (byte & ~(1 << bit));

    return mpu6xxx_write_reg(dev, reg, byte);
}

/** * This function reads a bit value of registers for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param bit the position of the register * @param data read data pointer * * @return the reading status, RT_EOK reprensents reading a bit value of registers successfully. */
static rt_err_t mpu6xxx_read_bit(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t bit, rt_uint8_t *data)
{
   
    rt_uint8_t byte;
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, reg, 1, &byte);
    if (res != RT_EOK)
    {
   
        return res;
    }

    *data = byte & (1 << bit);

    return RT_EOK;
}

/** * This function writes multi-bit value of registers for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param start_bit the start position of the register * @param len number of bits to write * @param data value to write * * @return the writing status, RT_EOK reprensents writing multi-bit value of registers successfully. */
static rt_err_t mpu6xxx_write_bits(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t start_bit, rt_uint8_t len, rt_uint8_t data)
{
   
    rt_uint8_t byte, mask;
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, reg, 1, &byte);
    if (res != RT_EOK)
    {
   
        return res;
    }

    mask = ((1 << len) - 1) << (start_bit - len + 1);
    data <<= (start_bit - len + 1); // shift data into correct position
    data &= mask; // zero all non-important bits in data
    byte &= ~(mask); // zero all important bits in existing byte
    byte |= data; // combine data with existing byte

    return mpu6xxx_write_reg(dev, reg, byte);
}

/** * This function reads multi-bit value of registers for mpu6xxx * * @param dev the pointer of device driver structure * @param reg the register for mpu6xxx * @param start_bit the start position of the register * @param len number of bits to write * @param data read data pointer * * @return the reading status, RT_EOK reprensents reading multi-bit value of registers successfully. */
static rt_err_t mpu6xxx_read_bits(struct mpu6xxx_device *dev, rt_uint8_t reg, rt_uint8_t start_bit, rt_uint8_t len, rt_uint8_t *data)
{
   
    rt_uint8_t byte, mask;
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, reg, 1, &byte);
    if (res != RT_EOK)
    {
   
        return res;
    }

    mask = ((1 << len) - 1) << (start_bit - len + 1);
    byte &= mask;
    byte >>= (start_bit - len + 1);
    *data = byte;

    return RT_EOK;
}

// MAG
#ifdef PKG_USING_MPU6XXX_MAG

#define MAG_READ_DELAY_TIME 50

static void mpu92_mag_write_reg(struct mpu6xxx_device *dev, rt_uint8_t addr, rt_uint8_t data)
{
   
    rt_uint8_t  status = 0;
    rt_uint32_t timeout = MAG_READ_DELAY_TIME;

    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV4_ADDR, AK8963_I2C_ADDR);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV4_REG, addr);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV4_DO, data);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV4_CTRL, MPU6500_I2C_SLVx_EN);

    do
    {
   
        mpu6xxx_read_regs(dev, MPU6XXX_RA_I2C_MST_STATUS, 1, &status);
        rt_thread_mdelay(1);
    } while (((status & MPU6500_I2C_SLV4_DONE) == 0) && (timeout--));

}

#endif // PKG_USING_MPU6XXX_MAG

/** * This function gets the raw data of the accelerometer * * @param dev the pointer of device driver structure * @param accel the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
static rt_err_t mpu6xxx_get_accel_raw(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *accel)
{
   
    rt_uint8_t buffer[6];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_ACCEL_XOUT_H, 6, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    accel->x = ((rt_uint16_t)buffer[0] << 8) + buffer[1];
    accel->y = ((rt_uint16_t)buffer[2] << 8) + buffer[3];
    accel->z = ((rt_uint16_t)buffer[4] << 8) + buffer[5];

    return RT_EOK;
}

/** * This function gets the raw data of the gyroscope * * @param dev the pointer of device driver structure * @param gyro the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
static rt_err_t mpu6xxx_get_gyro_raw(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *gyro)
{
   
    rt_uint8_t buffer[6];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_GYRO_XOUT_H, 6, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    gyro->x = ((rt_uint16_t)buffer[0] << 8) + buffer[1];
    gyro->y = ((rt_uint16_t)buffer[2] << 8) + buffer[3];
    gyro->z = ((rt_uint16_t)buffer[4] << 8) + buffer[5];

    return RT_EOK;
}

#ifdef PKG_USING_MPU6XXX_MAG
/** * This function gets the raw data of the magnetometer * * @param dev the pointer of device driver structure * @param mag the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
static rt_err_t mpu6xxx_get_mag_raw(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *mag)
{
   
    rt_uint8_t buffer[8];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_EXT_SENS_DATA_00, 8, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    mag->x = ((rt_uint16_t)buffer[2] << 8) + buffer[1];
    mag->y = ((rt_uint16_t)buffer[4] << 8) + buffer[3];
    mag->z = ((rt_uint16_t)buffer[6] << 8) + buffer[5];

    return RT_EOK;
}
#endif

/** * This function gets the raw data of the temperature * * @param dev the pointer of device driver structure * @param temp read data pointer * * @return the reading status, RT_EOK reprensents reading the data successfully. */
static rt_err_t mpu6xxx_get_temp_raw(struct mpu6xxx_device *dev, rt_int16_t *temp)
{
   
    rt_uint8_t buffer[2];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_TEMP_OUT_H, 2, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    *temp = ((rt_uint16_t)buffer[0] << 8) + buffer[1];

    return RT_EOK;
}

/** * This function gets mpu6xxx parameters. * * @param dev the pointer of device driver structure * @param cmd Configuration item * @param param read data pointer * * @return the reading status, RT_EOK reprensents reading the data successfully. */
static rt_err_t mpu6xxx_get_param(struct mpu6xxx_device *dev, enum mpu6xxx_cmd cmd, rt_uint16_t *param)
{
   
    rt_uint8_t data = 0;
    rt_err_t res = RT_EOK;

    RT_ASSERT(dev);

    switch (cmd)
    {
   
    case MPU6XXX_GYRO_RANGE:  /* Gyroscope full scale range */
        res = mpu6xxx_read_bits(dev, MPU6XXX_RA_GYRO_CONFIG, MPU6XXX_GCONFIG_FS_SEL_BIT, MPU6XXX_GCONFIG_FS_SEL_LENGTH, &data);
        *param = data;
        break;
    case MPU6XXX_ACCEL_RANGE: /* Accelerometer full scale range */
        res = mpu6xxx_read_bits(dev, MPU6XXX_RA_ACCEL_CONFIG, MPU6XXX_ACONFIG_AFS_SEL_BIT, MPU6XXX_ACONFIG_AFS_SEL_LENGTH, &data);
        *param = data;
        break;
    case MPU6XXX_DLPF_CONFIG: /* Digital Low Pass Filter */
        res = mpu6xxx_read_bits(dev, MPU6XXX_RA_CONFIG, MPU6XXX_CFG_DLPF_CFG_BIT, MPU6XXX_CFG_DLPF_CFG_LENGTH, &data);
        *param = data;
        break;
    case MPU6XXX_SAMPLE_RATE: /* Sample Rate */
        /* Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV) */
        res = mpu6xxx_read_bits(dev, MPU6XXX_RA_CONFIG, MPU6XXX_CFG_DLPF_CFG_BIT, MPU6XXX_CFG_DLPF_CFG_LENGTH, &data);
        if (res != RT_EOK)
        {
   
            break;
        }

        if (data == 0 || data == 7) /* dlpf is disable */
        {
   
            res = mpu6xxx_read_regs(dev, MPU6XXX_RA_SMPLRT_DIV, 1, &data);
            *param = 8000 / (data + 1);
        }
        else /* dlpf is enable */
        {
   
            res = mpu6xxx_read_regs(dev, MPU6XXX_RA_SMPLRT_DIV, 1, &data);
            *param = 1000 / (data + 1);
        }
        break;
    case MPU6XXX_SLEEP: /* sleep mode */
        res = mpu6xxx_read_bit(dev, MPU6XXX_RA_PWR_MGMT_1, MPU6XXX_PWR1_SLEEP_BIT, &data);
        *param = data;
        break;
    }

    return res;
}

/** * This function set mpu6xxx parameters. * * @param dev the pointer of device driver structure * @param cmd Configuration item * @param param Configuration item parameter * * @return the setting status, RT_EOK reprensents setting the parameter successfully. */
rt_err_t mpu6xxx_set_param(struct mpu6xxx_device *dev, enum mpu6xxx_cmd cmd, rt_uint16_t param)
{
   
    rt_uint8_t data = 0;
    rt_err_t res = RT_EOK;

    RT_ASSERT(dev);

    switch (cmd)
    {
   
    case MPU6XXX_GYRO_RANGE:  /* Gyroscope full scale range */
        res = mpu6xxx_write_bits(dev, MPU6XXX_RA_GYRO_CONFIG, MPU6XXX_GCONFIG_FS_SEL_BIT, MPU6XXX_GCONFIG_FS_SEL_LENGTH, param);
        dev->config.gyro_range = param;
        break;
    case MPU6XXX_ACCEL_RANGE: /* Accelerometer full scale range */
        res = mpu6xxx_write_bits(dev, MPU6XXX_RA_ACCEL_CONFIG, MPU6XXX_ACONFIG_AFS_SEL_BIT, MPU6XXX_ACONFIG_AFS_SEL_LENGTH, param);
        dev->config.accel_range = param;
        break;
    case MPU6XXX_DLPF_CONFIG: /* Digital Low Pass Filter */
        res = mpu6xxx_write_bits(dev, MPU6XXX_RA_CONFIG, MPU6XXX_CFG_DLPF_CFG_BIT, MPU6XXX_CFG_DLPF_CFG_LENGTH, param);
        break;
    case MPU6XXX_SAMPLE_RATE: /* Sample Rate = 16-bit unsigned value. Sample Rate = [1000 - 4]HZ when dlpf is enable Sample Rate = [8000 - 32]HZ when dlpf is disable */

        //Sample Rate = Gyroscope Output Rate / (1 + SMPLRT_DIV)
        res = mpu6xxx_read_bits(dev, MPU6XXX_RA_CONFIG, MPU6XXX_CFG_DLPF_CFG_BIT, MPU6XXX_CFG_DLPF_CFG_LENGTH, &data);
        if (res != RT_EOK)
        {
   
            break;
        }

        if (data == 0 || data == 7) /* dlpf is disable */
        {
   
            if (param > 8000)
                data = 0;
            else if (param < 32)
                data = 0xFF;
            else
                data = 8000 / param - 1;
        }
        else /* dlpf is enable */
        {
   
            if (param > 1000)
                data = 0;
            else if (param < 4)
                data = 0xFF;
            else
                data = 1000 / param - 1;
        }
        res = mpu6xxx_write_reg(dev, MPU6XXX_RA_SMPLRT_DIV, data);
        break;
    case MPU6XXX_SLEEP: /* Configure sleep mode */
        res = mpu6xxx_write_bit(dev, MPU6XXX_RA_PWR_MGMT_1, MPU6XXX_PWR1_SLEEP_BIT, param);
        break;
    }

    return res;
}

/** * This function gets the data of the accelerometer, unit: mg(mm/s^2) * * @param dev the pointer of device driver structure * @param accel the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
rt_err_t mpu6xxx_get_accel(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *accel)
{
   
    struct mpu6xxx_3axes tmp;
    rt_uint16_t sen;
    rt_err_t res;

    res = mpu6xxx_get_accel_raw(dev, &tmp);
    if (res != RT_EOK)
    {
   
        return res;
    }

    sen = MPU6XXX_ACCEL_SEN >> dev->config.accel_range;

    accel->x = (rt_int32_t)tmp.x * 1000 / sen;
    accel->y = (rt_int32_t)tmp.y * 1000 / sen;
    accel->z = (rt_int32_t)tmp.z * 1000 / sen;

    return RT_EOK;
}

/** * This function gets the data of the gyroscope, unit: deg/10s * Here deg/10s means 10 times higher precision than deg/s. * * @param dev the pointer of device driver structure * @param gyro the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
rt_err_t mpu6xxx_get_gyro(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *gyro)
{
   
    struct mpu6xxx_3axes tmp;
    rt_uint16_t sen;
    rt_err_t res;

    res = mpu6xxx_get_gyro_raw(dev, &tmp);
    if (res != RT_EOK)
    {
   
        return res;
    }

    sen = MPU6XXX_GYRO_SEN >> dev->config.gyro_range;

    gyro->x = (rt_int32_t)tmp.x * 100 / sen;
    gyro->y = (rt_int32_t)tmp.y * 100 / sen;
    gyro->z = (rt_int32_t)tmp.z * 100 / sen;

    return RT_EOK;
}

#ifdef PKG_USING_MPU6XXX_MAG

/** * This function gets the data of the magnetometer, unit: uT * * @param dev the pointer of device driver structure * @param gyro the pointer of 3axes structure for receive data * * @return the reading status, RT_EOK reprensents reading the data successfully. */
rt_err_t mpu6xxx_get_mag(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *mag)
{
   
    struct mpu6xxx_3axes tmp;
    rt_err_t res;

    res = mpu6xxx_get_mag_raw(dev, &tmp);
    if (res != RT_EOK)
    {
   
        return res;
    }

    mag->x = ((rt_int32_t)tmp.x * AK8963_RANGE) / AK8963_FULLSCALE;
    mag->y = ((rt_int32_t)tmp.y * AK8963_RANGE) / AK8963_FULLSCALE;
    mag->z = ((rt_int32_t)tmp.z * AK8963_RANGE) / AK8963_FULLSCALE;

    return RT_EOK;
}

#endif

/** * This function gets the data of the temperature, unit: Centigrade * * @param dev the pointer of device driver structure * @param temp read data pointer * * @return the reading status, RT_EOK reprensents reading the data successfully. */
rt_err_t mpu6xxx_get_temp(struct mpu6xxx_device *dev, float *temp)
{
   
    rt_int16_t tmp;
    rt_err_t res;

    res = mpu6xxx_get_temp_raw(dev, &tmp);
    if (res != RT_EOK)
    {
   
        return res;
    }

    if (dev->id == MPU6050_WHO_AM_I)
    {
   
        /* mpu60x0: Temperature in degrees C = (TEMP_OUT Register Value as a signed quantity)/340 + 36.53 */
        *temp = (double)tmp / MPU60X0_TEMP_SEN + MPU60X0_TEMP_OFFSET;
    }
    else
    {
   
        /* mpu6500: ((TEMP_OUT - RoomTemp_Offset)/Temp_Sensitivity)+ 21degC */
        *temp = (double)tmp / MPU6500_TEMP_SEN + MPU6500_TEMP_OFFSET;
    }

    return RT_EOK;
}

/** * This function sets the offset of the accelerometer * * @param dev the pointer of device driver structure * @param offset the pointer of 3axes structure of offsets * * @return the setting status, RT_EOK reprensents setting the offsets successfully. */
rt_err_t mpu6xxx_set_accel_offset(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *offset)
{
   
    rt_err_t res=0;
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_XA_OFFS_H, (offset->x)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_XA_OFFS_L_TC, (offset->x)&0x00ff);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_YA_OFFS_H, (offset->y)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_YA_OFFS_L_TC, (offset->y)&0x00ff);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_ZA_OFFS_H, (offset->z)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_ZA_OFFS_L_TC, (offset->z)&0x00ff);
    return res;
}

/** * This function gets the offset of the accelerometer * * @param dev the pointer of device driver structure * @param offset the pointer of 3axes structure of offsets * * @return the setting status, RT_EOK reprensents reading the offsets successfully. */
rt_err_t mpu6xxx_get_accel_offset(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *offset)
{
   
    rt_uint8_t buffer[6];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_XA_OFFS_H, 6, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    offset->x = ((rt_uint16_t)buffer[0] << 8) + buffer[1];
    offset->y = ((rt_uint16_t)buffer[2] << 8) + buffer[3];
    offset->z = ((rt_uint16_t)buffer[4] << 8) + buffer[5];

return RT_EOK;
}

/** * This function sets the offset of the gyroscope * * @param dev the pointer of device driver structure * @param offset the pointer of 3axes structure of offsets * * @return the setting status, RT_EOK reprensents setting the offsets successfully. */
rt_err_t mpu6xxx_set_gyro_offset(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *offset)
{
   
    rt_err_t res=0;
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_XG_OFFS_USRH, (offset->x)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_XG_OFFS_USRL, (offset->x)&0x00ff);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_YG_OFFS_USRH, (offset->y)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_YG_OFFS_USRL, (offset->y)&0x00ff);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_ZG_OFFS_USRH, (offset->z)>>8);
    res |= mpu6xxx_write_reg(dev, MPU6XXX_RA_ZG_OFFS_USRL, (offset->z)&0x00ff);
    return res;
}

/** * This function gets the offset of the gyroscope * * @param dev the pointer of device driver structure * @param offset the pointer of 3axes structure of offsets * * @return the setting status, RT_EOK reprensents reading the offsets successfully. */
rt_err_t mpu6xxx_get_gyro_offset(struct mpu6xxx_device *dev, struct mpu6xxx_3axes *offset)
{
   
    rt_uint8_t buffer[6];
    rt_err_t res;

    res = mpu6xxx_read_regs(dev, MPU6XXX_RA_XG_OFFS_USRH, 6, buffer);
    if (res != RT_EOK)
    {
   
        return res;
    }

    offset->x = ((rt_uint16_t)buffer[0] << 8) + buffer[1];
    offset->y = ((rt_uint16_t)buffer[2] << 8) + buffer[3];
    offset->z = ((rt_uint16_t)buffer[4] << 8) + buffer[5];

return RT_EOK;
}

/** * This function initialize the mpu6xxx device. * * @param dev_name the name of transfer device * @param param the i2c device address for i2c communication, RT_NULL for spi * * @return the pointer of device driver structure, RT_NULL reprensents initialization failed. */
struct mpu6xxx_device *mpu6xxx_init(const char *dev_name, rt_uint8_t param)
{
   
    struct mpu6xxx_device *dev = RT_NULL;
    rt_uint8_t reg = 0xFF, res = RT_EOK;

    RT_ASSERT(dev_name);

    dev = rt_calloc(1, sizeof(struct mpu6xxx_device));
    if (dev == RT_NULL)
    {
   
        LOG_E("Can't allocate memory for mpu6xxx device on '%s' ", dev_name);
        goto __exit;
    }

    dev->bus = rt_device_find(dev_name);
    if (dev->bus == RT_NULL)
    {
   
        LOG_E("Can't find device:'%s'", dev_name);
        goto __exit;
    }

    if (dev->bus->type == RT_Device_Class_I2CBUS)
    {
   
        if (param != RT_NULL)
        {
   
            dev->i2c_addr = param;
        }
        else
        {
   
            /* find mpu6xxx device at address: 0x68 */
            dev->i2c_addr = MPU6XXX_ADDRESS_AD0_LOW;
            if (mpu6xxx_read_regs(dev, MPU6XXX_RA_WHO_AM_I, 1, ®) != RT_EOK)
            {
   
                /* find mpu6xxx device at address 0x69 */
                dev->i2c_addr = MPU6XXX_ADDRESS_AD0_HIGH;
                if (mpu6xxx_read_regs(dev, MPU6XXX_RA_WHO_AM_I, 1, ®) != RT_EOK)
                {
   
                    LOG_E("Can't find device at '%s'!", dev_name);
                    goto __exit;
                }
            }
            LOG_D("Device i2c address is:'0x%x'!", dev->i2c_addr);
        }
    }
    else if (dev->bus->type == RT_Device_Class_SPIDevice)
    {
   
#ifdef RT_USING_SPI
        struct rt_spi_configuration cfg;

        cfg.data_width = 8;
        cfg.mode = RT_SPI_MASTER | RT_SPI_MODE_0 | RT_SPI_MSB;
        cfg.max_hz = MPU60X0_SPI_MAX_SPEED; /* Set spi max speed */

        rt_spi_configure((struct rt_spi_device *)dev->bus, &cfg);
#endif
    }
    else
    {
   
        LOG_E("Unsupported device:'%s'!", dev_name);
        goto __exit;
    }

    if (mpu6xxx_read_regs(dev, MPU6XXX_RA_WHO_AM_I, 1, ®) != RT_EOK)
    {
   
        LOG_E("Failed to read device id!");
        goto __exit;
    }

    dev->id = reg;

    switch (dev->id)
    {
   
    case MPU6050_WHO_AM_I:
        LOG_I("Find device: mpu6050!");
        break;
    case MPU6500_WHO_AM_I:
        LOG_I("Find device: mpu6500!");
        break;
    case MPU9250_WHO_AM_I:
        LOG_I("Find device: mpu9250!");
        break;
    case ICM20608G_WHO_AM_I:
    case ICM20608D_WHO_AM_I:
        LOG_I("Find device: icm20608!");
        break;
    case 0xFF:
        LOG_E("No device connection!");
        goto __exit;
    default:
        LOG_W("Unknown device id: 0x%x!", reg);
    }

    res += mpu6xxx_get_param(dev, MPU6XXX_ACCEL_RANGE, &dev->config.accel_range);
    res += mpu6xxx_get_param(dev, MPU6XXX_GYRO_RANGE, &dev->config.gyro_range);

    res += mpu6xxx_write_bits(dev, MPU6XXX_RA_PWR_MGMT_1, MPU6XXX_PWR1_CLKSEL_BIT, MPU6XXX_PWR1_CLKSEL_LENGTH, MPU6XXX_CLOCK_PLL_XGYRO);
    res += mpu6xxx_set_param(dev, MPU6XXX_GYRO_RANGE, MPU6XXX_GYRO_RANGE_250DPS);
    res += mpu6xxx_set_param(dev, MPU6XXX_ACCEL_RANGE, MPU6XXX_ACCEL_RANGE_2G);
    res += mpu6xxx_set_param(dev, MPU6XXX_SLEEP, MPU6XXX_SLEEP_DISABLE);

#ifdef PKG_USING_MPU6XXX_MAG
    mpu6xxx_write_reg(dev, MPU6XXX_RA_USER_CTRL, 0x20);
    mpu92_mag_write_reg(dev, AK8963_REG_CNTL2, 0x01);      /* [0] Reset Device */
    rt_thread_mdelay(1);
    mpu92_mag_write_reg(dev, AK8963_REG_CNTL1, 0x00);      /* [1] Power-down mode */
    mpu92_mag_write_reg(dev, AK8963_REG_CNTL1, 0x0F);      /* [2] Fuse ROM access mode */
    mpu92_mag_write_reg(dev, AK8963_REG_CNTL1, 0x00);      /* [3] Power-down mode */
    rt_thread_mdelay(1);    // 100us
    mpu92_mag_write_reg(dev, AK8963_REG_CNTL1, 0x16);      /* [4] 16bits and Continuous measurement mode 2 */

    /* config mpu9250 i2c */
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_MST_CTRL, 0x5D);
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV0_ADDR, AK8963_I2C_ADDR | 0x80);
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV0_REG, AK8963_REG_ST1);
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV0_CTRL, MPU6500_I2C_SLVx_EN | 8);
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_SLV4_CTRL, 0x09);
    rt_thread_mdelay(2);
    mpu6xxx_write_reg(dev, MPU6XXX_RA_I2C_MST_DELAY_CTRL, 0x81);
#endif

    if (res == RT_EOK)
    {
   
        LOG_I("Device init succeed!");
    }
    else
    {
   
        LOG_W("Error in device initialization!");
    }
    return dev;

__exit:
    if (dev != RT_NULL)
    {
   
        rt_free(dev);
    }
    return RT_NULL;
}

/** * This function releases memory * * @param dev the pointer of device driver structure */
void mpu6xxx_deinit(struct mpu6xxx_device *dev)
{
   
    RT_ASSERT(dev);

    rt_free(dev);
}

static void mpu6xxx(int argc, char **argv)
{
   
    static struct mpu6xxx_device *dev = RT_NULL;

    /* If the number of arguments less than 2 */
    if (argc < 2)
    {
   
        rt_kprintf("\\n");
        rt_kprintf("mpu6xxx [OPTION] [PARAM]\\n");
        rt_kprintf(" probe 
   );
        rt_kprintf(" sr  Set sample rate to var\\n");
        rt_kprintf(" var = [1000 - 4] when dlpf is enable\\n");
        rt_kprintf(" var = [8000 - 32] when dlpf is disable\\n");
        rt_kprintf(" gr  Set gyro range to var\\n");
        rt_kprintf(" var = [0 - 3] means [250 - 2000DPS]\\n");
        rt_kprintf(" ar  Set accel range to var\\n");
        rt_kprintf(" var = [0 - 3] means [2 - 16G]\\n");
        rt_kprintf(" sleep  Set sleep status\\n");
        rt_kprintf(" var = 0 means disable, = 1 means enable\\n");
        rt_kprintf(" read [num] read [num] times mpu6xxx\\n");
        rt_kprintf(" num default 5\\n");
        return ;
    }
    else if (!strcmp(argv[1], "read"))
    {
   
        struct mpu6xxx_3axes accel, gyro, mag;
        float temp;
        rt_uint16_t num = 5;

        if (dev == RT_NULL)
        {
   
            rt_kprintf("Please probe mpu6xxx first!\\n");
            return ;
        }
        if (argc == 3)
        {
   
            num = atoi(argv[2]);
        }

        while (num --)
        {
   
            mpu6xxx_get_accel(dev, &accel);
            mpu6xxx_get_gyro(dev, &gyro);
            mpu6xxx_get_mag(dev, &mag);
            mpu6xxx_get_temp(dev, &temp);

            rt_kprintf("accel.x = %4d mg, accel.y = %4d mg, accel.z = %4d mg, ", accel.x+50, accel.y, accel.z-800);
            rt_kprintf("gyro.x = %4d deg/10s, gyro.y = %4d deg/10s, gyro.z = %4d deg/10s, ", gyro.x-70, gyro.y+22, gyro.z-9);
            rt_kprintf("mag.x = %4d uT, mag.y = %4d uT, mag.z = %4d uT", mag.x, mag.y, mag.z);
            rt_kprintf("temp = %d.%d ℃\\n", (int)(temp * 100) / 100, (int)(temp * 100) % 100);

            rt_thread_mdelay(100);
        }
    }
    else if (argc == 3)
    {
   
        if (!strcmp(argv[1], "probe"))
        {
   
            if (dev)
            {
   
                mpu6xxx_deinit(dev);
            }
            dev = mpu6xxx_init(argv[2], RT_NULL);
        }
        else if (dev == RT_NULL)
        {
   
            rt_kprintf("Please probe mpu6xxx first!\\n");
            return ;
        }
        else if (!strcmp(argv[1], "sr"))
        {
   
            mpu6xxx_set_param(dev, MPU6XXX_SAMPLE_RATE, atoi(argv[2]));
        }
        else if (!strcmp(argv[1], "sleep"))
        {
   
            mpu6xxx_set_param(dev, MPU6XXX_SLEEP, atoi(argv[2]));
        }
        else if (!strcmp(argv[1], "gr"))
        {
   
            mpu6xxx_set_param(dev, MPU6XXX_GYRO_RANGE, atoi(argv[2]));
        }
        else if (!strcmp(argv[1], "ar"))
        {
   
            mpu6xxx_set_param(dev, MPU6XXX_ACCEL_RANGE, atoi(argv[2]));
        }
        else
        {
   
            rt_kprintf("Unknown command, please enter 'mpu6xxx' get help information!\\n");
        }
    }
    else
    {
   
        rt_kprintf("Unknown command, please enter 'mpu6xxx' get help information!\\n");
    }
}
#ifdef FINSH_USING_MSH
    MSH_CMD_EXPORT(mpu6xxx, mpu6xxx sensor function);
#endif

mpu6050.c

/* * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2022-07-11 Asus the first version */

#include "sensor_inven_mpu6xxx.h"

int rt_hw_mpu6xxx_port(void)
{
   
    struct rt_sensor_config cfg;

    cfg.intf.dev_name = "i2c1";
    cfg.intf.user_data = (void *)MPU6XXX_ADDR_DEFAULT;
    cfg.irq_pin.pin = RT_PIN_NONE;

    rt_hw_mpu6xxx_init("mpu", &cfg);
    return 0;
}
INIT_APP_EXPORT(rt_hw_mpu6xxx_port);

3、main.c文件在re_gen文件夾下,主程序圍繞“hal_entry();”函數(shù)(在src文件夾),這些默認不變

  1. 下載驗證1、編譯重構(gòu)

編譯成功

2、下載程序

下載成功

3、CMD串口調(diào)試

然后板載復位,開始串口打印顯示!

開始測試,輸入 mpu6xxx

接著校準mpu6050,輸入 mpu6xxx probe i2c1

晃動傳感器,讀取角加速度,角速度和溫度,輸入mpu6xxx read 20
效果如下

打印日志

\\ | /
- RT -     Thread Operating System
 / | \\     4.1.0 build Jul 13 2022 21:35:51
 2006 - 2022 Copyright by RT-Thread team
[I/mpu6xxx] Find device: mpu6050!
[I/mpu6xxx] Device init succeed!
[I/sensor] rt_sensor[acce_mpu] init success
[I/sensor] rt_sensor[gyro_mpu] init success
[I/sensor] rt_sensor[mag_mpu] init success
[I/sensor.inven.mpu6xxx] sensor init success

Hello RT-Thread!
msh >mpu6xxx

mpu6xxx [OPTION] [PARAM]
         probe       Probe mpu6xxx by given name such as i2c1
         sr               Set sample rate to var
                               var = [1000 -  4] when dlpf is enable
                               var = [8000 - 32] when dlpf is disable
         gr               Set gyro range to var
                               var = [0 - 3] means [250 - 2000DPS]
         ar               Set accel range to var
                               var = [0 - 3] means [2 - 16G]
         sleep            Set sleep status
                               var = 0 means disable, = 1 means enable
         read [num]            read [num] times mpu6xxx
                               num default 5
msh >mpu6xxx probe i2c1
[I/mpu6xxx] Find device: mpu6050!
[I/mpu6xxx] Device init succeed!
msh >mpu6xxx read 20
accel.x =  200 mg, accel.y =   -4 mg, accel.z =    3 mg, gyro.x =    0 deg/10s, gyro.y =   -1 deg/10s, gyro.z =   -2 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.65 ℃℃
accel.x =  203 mg, accel.y =   -4 mg, accel.z =   19 mg, gyro.x =   -1 deg/10s, gyro.y =   -1 deg/10s, gyro.z =    0 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.65 ℃℃
accel.x =  194 mg, accel.y =   -9 mg, accel.z =    6 mg, gyro.x =   -1 deg/10s, gyro.y =    1 deg/10s, gyro.z =   -2 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.60 ℃℃
accel.x =  210 mg, accel.y =   11 mg, accel.z =   15 mg, gyro.x =   -6 deg/10s, gyro.y =    0 deg/10s, gyro.z =   -1 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.60 ℃℃
accel.x =  389 mg, accel.y =  408 mg, accel.z =  499 mg, gyro.x =   25 deg/10s, gyro.y = -127 deg/10s, gyro.z =  353 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.65 ℃℃
accel.x =  187 mg, accel.y = -218 mg, accel.z =  -70 mg, gyro.x =   37 deg/10s, gyro.y =  -15 deg/10s, gyro.z =  478 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.74 ℃℃
accel.x = -149 mg, accel.y = -561 mg, accel.z =  246 mg, gyro.x = -2571 deg/10s, gyro.y =  479 deg/10s, gyro.z =  121 deg/10s, mag.x =    0 uT, mag.y =
    0 uT, mag.z =    0 uTtemp = 31.60 ℃℃
accel.x =  104 mg, accel.y = -109 mg, accel.z =  -42 mg, gyro.x = -1431 deg/10s, gyro.y = -1333 deg/10s, gyro.z = -1885 deg/10s, mag.x =    0 uT, mag.y
 =    0 uT, mag.z =    0 uTtemp = 31.70 ℃℃
accel.x =  677 mg, accel.y = -592 mg, accel.z =  330 mg, gyro.x = -313 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -1443 deg/10s, mag.x =    0 uT, mag.y
=    0 uT, mag.z =    0 uTtemp = 31.55 ℃℃
accel.x =  749 mg, accel.y =  -57 mg, accel.z = -410 mg, gyro.x = -1377 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -611 deg/10s, mag.x =    0 uT, mag.y
=    0 uT, mag.z =    0 uTtemp = 31.65 ℃℃
accel.x =  512 mg, accel.y = -146 mg, accel.z = -1845 mg, gyro.x = -799 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -149 deg/10s, mag.x =    0 uT, mag.y
=    0 uT, mag.z =    0 uTtemp = 31.55 ℃℃
accel.x = -180 mg, accel.y =  420 mg, accel.z = -2800 mg, gyro.x =  519 deg/10s, gyro.y = 1497 deg/10s, gyro.z =  140 deg/10s, mag.x =    0 uT, mag.y =
    0 uT, mag.z =    0 uTtemp = 31.60 ℃℃
accel.x =  237 mg, accel.y =  243 mg, accel.z = -1148 mg, gyro.x = 1585 deg/10s, gyro.y = 2523 deg/10s, gyro.z = 1265 deg/10s, mag.x =    0 uT, mag.y =
    0 uT, mag.z =    0 uTtemp = 31.60 ℃℃
accel.x =   77 mg, accel.y = -667 mg, accel.z = -257 mg, gyro.x =  907 deg/10s, gyro.y = 2523 deg/10s, gyro.z = 1608 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.51 ℃℃
accel.x = -239 mg, accel.y = -726 mg, accel.z =  644 mg, gyro.x =  557 deg/10s, gyro.y = 2523 deg/10s, gyro.z =  651 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.51 ℃℃
accel.x = -230 mg, accel.y = -556 mg, accel.z =  181 mg, gyro.x =  215 deg/10s, gyro.y =  294 deg/10s, gyro.z =  -54 deg/10s, mag.x =    0 uT, mag.y =
   0 uT, mag.z =    0 uTtemp = 31.65 ℃℃
accel.x = -385 mg, accel.y = -600 mg, accel.z =  570 mg, gyro.x =   -1 deg/10s, gyro.y = -2045 deg/10s, gyro.z = -128 deg/10s, mag.x =    0 uT, mag.y =
    0 uT, mag.z =    0 uTtemp = 31.55 ℃℃
accel.x = -335 mg, accel.y = -419 mg, accel.z = -310 mg, gyro.x = -1128 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -1016 deg/10s, mag.x =    0 uT, mag.y
 =    0 uT, mag.z =    0 uTtemp = 31.55 ℃℃
accel.x =  534 mg, accel.y =  100 mg, accel.z = -1428 mg, gyro.x = -1368 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -1052 deg/10s, mag.x =    0 uT, mag.
y =    0 uT, mag.z =    0 uTtemp = 31.55 ℃℃
accel.x =  469 mg, accel.y =  265 mg, accel.z = -1841 mg, gyro.x = -1220 deg/10s, gyro.y = -2479 deg/10s, gyro.z = -656 deg/10s, mag.x =    0 uT, mag.y
 =    0 uT, mag.z =    0 uTtemp = 31.46 ℃℃

數(shù)據(jù)顯示一開始沒有怎么變化,后面就會變化加快(我手抖了),mpu6050不支持磁力所以全部為零。

這樣我們就可以天馬行空啦!

審核編輯:湯梓紅

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學習之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請聯(lián)系本站處理。 舉報投訴
  • I2C
    I2C
    +關(guān)注

    關(guān)注

    28

    文章

    1487

    瀏覽量

    123754
  • Renesas
    +關(guān)注

    關(guān)注

    0

    文章

    1757

    瀏覽量

    22756
  • 開發(fā)板
    +關(guān)注

    關(guān)注

    25

    文章

    5050

    瀏覽量

    97471
  • MPU6050
    +關(guān)注

    關(guān)注

    39

    文章

    307

    瀏覽量

    71408
  • RA6M4
    +關(guān)注

    關(guān)注

    0

    文章

    51

    瀏覽量

    450
收藏 人收藏

    評論

    相關(guān)推薦

    Renesas RA6M4開發(fā)板I2C(模擬)驅(qū)動ssd1306 OLED屏幕】

    Renesas RA6M4開發(fā)板I2C(模擬)驅(qū)動ssd1306 OLED屏幕】
    的頭像 發(fā)表于 01-11 09:34 ?4551次閱讀
    【<b class='flag-5'>Renesas</b> <b class='flag-5'>RA6M4</b><b class='flag-5'>開發(fā)板</b><b class='flag-5'>之</b><b class='flag-5'>I2C</b>(模擬)驅(qū)動ssd1306 OLED屏幕】

    Renesas RA6M4開發(fā)板I2C讀取BMP180氣壓溫度】

    本篇通過Renesas RA6M4開發(fā)板采用I2C讀取BMP180傳感器的氣壓溫度示例程序演示。
    的頭像 發(fā)表于 01-16 09:29 ?4010次閱讀
    【<b class='flag-5'>Renesas</b> <b class='flag-5'>RA6M4</b><b class='flag-5'>開發(fā)板</b><b class='flag-5'>之</b><b class='flag-5'>I2C</b><b class='flag-5'>讀取</b>BMP180氣壓溫度】

    基于 STM32 的硬件 I2C 讀取 MPU6050 數(shù)據(jù)

    ,0x18,MPU6050_RA_GYRO_CONFIG); //角速度量程 2000度/s}注:0xD0 表示 MPU6050 的地址。我們知道 I2C從器件(在此當然是指 MPU6050
    發(fā)表于 05-27 17:43

    通過Renesas RA6M4開發(fā)板采用I2C讀取mpu6050傳感器的角速度

    1.0 mpu6050本篇通過Renesas RA6M4開發(fā)板采用I2C讀取
    發(fā)表于 07-29 11:24

    Renesas RA6M4開發(fā)板USB-H評測活動

    1、Renesas RA6M4開發(fā)板USB-H評測  這次是第二次接觸這塊開發(fā)板了,但是還是第一次仔細觀察這塊
    發(fā)表于 11-22 16:08

    mpu6050對應i2c地址是什么_如何讀取數(shù)據(jù)

    本文主要介紹了mpu6050對應i2c地址是什么,并通過stm32的硬件讀取mpu6050的數(shù)據(jù)。MPU6050
    發(fā)表于 12-11 16:04 ?2.5w次閱讀
    <b class='flag-5'>mpu6050</b>對應<b class='flag-5'>i2c</b>地址是什么_如何<b class='flag-5'>讀取</b>數(shù)據(jù)

    如何使用STM32單片機的硬件I2C讀取MPU6050的數(shù)據(jù)資料和程序免費下載

    本文檔的主要內(nèi)容詳細介紹的是如何使用STM32單片機的硬件I2C讀取MPU6050的數(shù)據(jù)資料和程序免費下載。
    發(fā)表于 07-25 17:31 ?0次下載
    如何使用STM32單片機的硬件<b class='flag-5'>I2C</b><b class='flag-5'>讀取</b><b class='flag-5'>MPU6050</b>的數(shù)據(jù)資料和程序免費下載

    使用AVR單片機的I2C讀取MPU6050發(fā)送到串口的程序免費下載

    本文檔的主要內(nèi)容詳細介紹的是使用AVR單片機的I2C讀取MPU6050的數(shù)據(jù)發(fā)送到串口的程序免費下載。
    發(fā)表于 08-06 16:39 ?9次下載
    使用AVR單片機的<b class='flag-5'>I2C</b><b class='flag-5'>讀取</b><b class='flag-5'>MPU6050</b>發(fā)送到串口的程序免費下載

    使用MPU6050傳感器讀取I2C總線數(shù)據(jù)的程序免費下載

    本文檔的主要內(nèi)容詳細介紹的是使用MPU6050傳感器讀取I2C總線數(shù)據(jù)的程序免費下載。
    發(fā)表于 08-09 17:40 ?15次下載
    使用<b class='flag-5'>MPU6050</b>傳感器<b class='flag-5'>讀取</b><b class='flag-5'>I2C</b>總線數(shù)據(jù)的程序免費下載

    stm32使用MPU6050讀取溫度值驗證I2C

    stm32使用MPU6050讀取溫度值驗證I2C
    發(fā)表于 12-06 12:06 ?5次下載
    stm32使用<b class='flag-5'>MPU6050</b><b class='flag-5'>讀取</b>溫度值驗證<b class='flag-5'>I2C</b>

    I2C總線讀取MPU6050

    基于MSP430處理器的 I2C總線讀取MPU6050傳感器數(shù)據(jù)
    發(fā)表于 12-06 13:36 ?15次下載
    <b class='flag-5'>I2C</b>總線<b class='flag-5'>讀取</b><b class='flag-5'>MPU6050</b>

    STM32-I2C總線通信與MPU6050

    地址MPU6050電氣原理圖1、I2C總線I2C(Inter-integrated Circuit)總線是由PHILIPS公司開發(fā)的兩線式串行總線,用于連接微控制器及其外圍設(shè)備,是微電
    發(fā)表于 12-06 14:06 ?27次下載
    STM32-<b class='flag-5'>I2C</b>總線通信與<b class='flag-5'>MPU6050</b>

    使用I2C連接AGX Xavier和MPU6050讀取IMU數(shù)據(jù)

    )GNDpin 6 (GND)SCLpin 5 (SCL)SDApin 3 (SDA)通信協(xié)議實用I2C進行通信,詳情見 I2C serial communication protocol打開Jetson Nano,打開終端頁面
    發(fā)表于 12-06 15:51 ?5次下載
    使用<b class='flag-5'>I2C</b>連接AGX Xavier和<b class='flag-5'>MPU6050</b>并<b class='flag-5'>讀取</b>IMU數(shù)據(jù)

    開發(fā)板評測】Renesas RA6M4開發(fā)板SDIO(SDHI)

    本次評測的開發(fā)板Renesas的CPK-RA6M4開發(fā)板,它是一款Renesas官方基于RA6M4
    的頭像 發(fā)表于 12-27 13:15 ?2504次閱讀

    Renesas RA6M4開發(fā)板DHT11溫濕度讀取

    本篇通過Renesas RA6M4開發(fā)板DHT11溫濕度讀取示例程序演示。
    的頭像 發(fā)表于 01-18 17:18 ?1688次閱讀
    【<b class='flag-5'>Renesas</b> <b class='flag-5'>RA6M4</b><b class='flag-5'>開發(fā)板</b><b class='flag-5'>之</b>DHT11溫濕度<b class='flag-5'>讀取</b>】
    主站蜘蛛池模板: 免费在线看a| 女人被两根一起进3p在线观看| 国产三级在线播放| www.日本三级| 黄色成人在线网站| 1515hh四虎免费观38com| 99热久久精品最新| 欧美白人极品性喷潮| 天天操人人爱| 看免费视频| 在线欧美视频免费观看国产| 免费在线你懂的| 欧美aaaaa性bbbbb小妇| 99久久成人国产精品免费| 久久婷婷综合五月一区二区| 日日爱网站| 亚洲国产一区二区三区a毛片 | 亚洲激情| 日本乱理论片免费看| 国产一区二区三区影院 | 人人干人人干人人干| 黄色网址网站在线观看| 色综合中文字幕| 五月天婷婷丁香花| 久久精品国产亚洲婷婷| 好爽毛片一区二区三区四| 99久久香蕉国产综合影院| 91九色蝌蚪在线| 国产精品久久新婚兰兰| 狠狠操狠狠干| 天天色影综合网| 国产aaa级一级毛片| 韩国午夜影院| 色视视频| 奇米影视婷婷| 五月婷婷丁香花| 国产精品一区电影| 91视频观看| 日韩一二三级| 一级特黄aaa大片免费看| 欧美性xxxx交|