0

This is a newbie question but I'm not having much luck googling.

I'm wanting to write code that accesses an InvenSense MPU-6050 motion sensor package. I've obtained the Embedded Motion Driver 5.1.1 package. It contains example code plus a driver in the form of a directory tree of .c and .h files. The file structure of the driver is

\---msp430
    |   msp430USB.cmd
    |   msp430_clock.c
    |   msp430_clock.h
    |   msp430_i2c.c
    |   msp430_i2c.h
    |   msp430_interrupt.c
    |   msp430_interrupt.h
    |
    +---F5xx_F6xx_Core_Lib
    |       HAL_FLASH.c
    |       HAL_FLASH.h
    |       HAL_MACROS.h
    |       HAL_PMAP.c
    |       HAL_PMAP.h
    |       HAL_PMM.c
    |       HAL_PMM.h
    |       HAL_TLV.c
    |       HAL_TLV.h
    |       HAL_UCS.c
    |       HAL_UCS.h
    |
    +---USB_API
    |   +---USB_CDC_API
    |   |       UsbCdc.c
    |   |       UsbCdc.h
    |   |
    |   +---USB_Common
    |   |       defMSP430USB.h
    |   |       device.h
    |   |       dma.c
    |   |       types.h
    |   |       usb.c
    |   |       usb.h
    |   |       UsbIsr.h
    |   |
    |   +---USB_HID_API
    |   |       UsbHid.c
    |   |       UsbHid.h
    |   |       UsbHidReq.c
    |   |       UsbHidReq.h
    |   |
    |   +---USB_MSC_API
    |   |       UsbMsc.h
    |   |       UsbMscReq.c
    |   |       UsbMscReq.h
    |   |       UsbMscScsi.c
    |   |       UsbMscScsi.h
    |   |       UsbMscStateMachine.c
    |   |       UsbMscStateMachine.h
    |   |
    |   \---USB_PHDC_API
    |           UsbPHDC.c
    |           UsbPHDC.h
    |
    \---USB_eMPL
            descriptors.c
            descriptors.h
            eMPL_CDC.inf
            usbConstructs.c
            usbConstructs.h
            usbEventHandling.c
            UsbIsr.c

It's intended to be used with a development environment called "Code Composer Studio." I'm trying to use it with the stock Arduino development environment (1.8.1). I create a new sketch and copy the example code into it. It includes various files from the driver tree;

#include "USB_eMPL/descriptors.h"

#include "USB_API/USB_Common/device.h"
#include "USB_API/USB_Common/types.h"
#include "USB_API/USB_Common/usb.h"

#include "F5xx_F6xx_Core_Lib/HAL_UCS.h"
#include "F5xx_F6xx_Core_Lib/HAL_PMM.h"
#include "F5xx_F6xx_Core_Lib/HAL_FLASH.h"

#include "USB_API/USB_CDC_API/UsbCdc.h"

#include "usbConstructs.h"

I've read about how to import libraries. However this isn't a library- copying it into the "libraries" folder of the project and restarting the IDE doesn't make anything new appear in Sketch->Include Library and nor does it allow the program to compile.

Copying the driver files and subdirectories into the same folder as the sketch gets me past the first hurdle of those include files not being found, but then similar lines in files in the driver subdirectories also cause errors because the paths are wrong. The files are obviously intended to be in a central dev environment "include" directory so the search always starts from the same point in the filesystem.

I've therefore tried copying the driver files into C:\Program Files (x86)\Arduino\libraries as the folder "msp430." This added an "msp430" item to the "Include Library" menu, but compilation still fails with unresolved includes. Using trial and error, it seems that I can only get files to be recognised if they're in their own folder in 'libraries.' So by pulling all the nested subfolders out and changing the paths in the top level again gets me past the first hurdle of the include files in the top level of code, but all the includes in the driver files then fail because they're looking for files in nested directories. I could go through and remove all the path information from every #include, but then everything's in the same "namespace" and with such generic names as "types.h" I can see that screwing up very quickly. So I can't believe that's how included files are generally managed on here.

So having said what hasn't worked, does anyone know what I can do that will work?

  • If you just google "Arduino MPU6050" you will get billions of hits, including a large number of Arduino-specific libraries, code samples, examples, tutorials, schematics, etc. Everything you need to get it working. – Majenko Mar 22 '17 at 14:24
  • Yeah I've got examples that just read the sensor outputs, but there's a "motion processor" in there that lets you do things like FFT filtering of the raw data before it comes out of the device, calculate quaternion data for you and a few other things. That's what this driver gives access to. – Craig Graham Mar 22 '17 at 15:03
  • You mean the DMP? Then you want this: geekmomprojects.com/mpu-6050-dmp-data-from-i2cdevlib – Majenko Mar 22 '17 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.