motion library for mpu6050, mpu9250 and etc, supports i2c and spi

Committer:
yihui
Date:
Tue Jul 05 07:19:59 2016 +0000
Revision:
0:814475fdc553
initial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 0:814475fdc553 1
yihui 0:814475fdc553 2 /******************************************************************************
yihui 0:814475fdc553 3 * $Id: mbed_spi.h $
yihui 0:814475fdc553 4 *****************************************************************************/
yihui 0:814475fdc553 5 /**
yihui 0:814475fdc553 6 * @defgroup MBED_System_Layer MBED System Layer
yihui 0:814475fdc553 7 * @brief MBED System Layer APIs.
yihui 0:814475fdc553 8 * To interface with any platform, eMPL needs access to various
yihui 0:814475fdc553 9 * system layer functions.
yihui 0:814475fdc553 10 *
yihui 0:814475fdc553 11 * @{
yihui 0:814475fdc553 12 * @file mbed_spi.h
yihui 0:814475fdc553 13 * @brief Serial communication functions needed by eMPL to
yihui 0:814475fdc553 14 * communicate to the MPU devices.
yihui 0:814475fdc553 15 * @details This driver assumes that eMPL is with a sub-master clock set
yihui 0:814475fdc553 16 * to 20MHz. The following MBEDs are supported:
yihui 0:814475fdc553 17 */
yihui 0:814475fdc553 18 #ifndef _MBED_SPI_H_
yihui 0:814475fdc553 19 #define _MBED_SPI_H_
yihui 0:814475fdc553 20
yihui 0:814475fdc553 21 #ifdef __cplusplus
yihui 0:814475fdc553 22 extern "C" {
yihui 0:814475fdc553 23 #endif
yihui 0:814475fdc553 24
yihui 0:814475fdc553 25 #include "spi_api.h"
yihui 0:814475fdc553 26
yihui 0:814475fdc553 27 /**
yihui 0:814475fdc553 28 * @brief Set up the SPI port and configure the MBED as the master.
yihui 0:814475fdc553 29 */
yihui 0:814475fdc553 30 void mbed_spi_init(PinName mosi, PinName miso, PinName sclk, PinName cs);
yihui 0:814475fdc553 31
yihui 0:814475fdc553 32 /**
yihui 0:814475fdc553 33 * @brief Enable SPI port.
yihui 0:814475fdc553 34 */
yihui 0:814475fdc553 35 void mbed_spi_enable(void);
yihui 0:814475fdc553 36
yihui 0:814475fdc553 37 /**
yihui 0:814475fdc553 38 * @brief Disable SPI communication.
yihui 0:814475fdc553 39 * This function will disable the SPI hardware and should be called prior to
yihui 0:814475fdc553 40 * entering low-power mode.
yihui 0:814475fdc553 41 */
yihui 0:814475fdc553 42 void mbed_spi_disable(void);
yihui 0:814475fdc553 43
yihui 0:814475fdc553 44 /**
yihui 0:814475fdc553 45 * @brief Write to a device register.
yihui 0:814475fdc553 46 *
yihui 0:814475fdc553 47 * @param[in] reg_addr Slave register to be written to.
yihui 0:814475fdc553 48 * @param[in] length Number of bytes to write.
yihui 0:814475fdc553 49 * @param[out] data Data to be written to register.
yihui 0:814475fdc553 50 *
yihui 0:814475fdc553 51 * @return 0 if successful.
yihui 0:814475fdc553 52 */
yihui 0:814475fdc553 53 int mbed_spi_write(unsigned char reg_addr,
yihui 0:814475fdc553 54 unsigned char length,
yihui 0:814475fdc553 55 unsigned char const *data);
yihui 0:814475fdc553 56 /**
yihui 0:814475fdc553 57 * @brief Read from a device.
yihui 0:814475fdc553 58 *
yihui 0:814475fdc553 59 * @param[in] reg_addr Slave register to be read from.
yihui 0:814475fdc553 60 * @param[in] length Number of bytes to read.
yihui 0:814475fdc553 61 * @param[out] data Data from register.
yihui 0:814475fdc553 62 *
yihui 0:814475fdc553 63 * @return 0 if successful.
yihui 0:814475fdc553 64 */
yihui 0:814475fdc553 65 int mbed_spi_read(unsigned char reg_addr,
yihui 0:814475fdc553 66 unsigned char length,
yihui 0:814475fdc553 67 unsigned char *data);
yihui 0:814475fdc553 68
yihui 0:814475fdc553 69 #ifdef __cplusplus
yihui 0:814475fdc553 70 }
yihui 0:814475fdc553 71 #endif
yihui 0:814475fdc553 72
yihui 0:814475fdc553 73 #endif /* _MBED_I2C_H_ */
yihui 0:814475fdc553 74
yihui 0:814475fdc553 75 /**
yihui 0:814475fdc553 76 * @}
yihui 0:814475fdc553 77 */