CSSE4011_BLE_IMU IMU Seeed Tiny Ble
Dependencies: BLE_API_Tiny_BLE MPU6050-DMP-Seeed-Tiny-BLE mbed
mbed_i2c.h@2:44bc61abdf33, 2015-06-10 (annotated)
- Committer:
- flywind
- Date:
- Wed Jun 10 12:56:48 2015 +0000
- Revision:
- 2:44bc61abdf33
milestone working one , yaw pitch roll update in BLE sucessfull
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
flywind | 2:44bc61abdf33 | 1 | |
flywind | 2:44bc61abdf33 | 2 | /****************************************************************************** |
flywind | 2:44bc61abdf33 | 3 | * $Id: mbed_i2c.h $ |
flywind | 2:44bc61abdf33 | 4 | *****************************************************************************/ |
flywind | 2:44bc61abdf33 | 5 | /** |
flywind | 2:44bc61abdf33 | 6 | * @defgroup MBED_System_Layer MBED System Layer |
flywind | 2:44bc61abdf33 | 7 | * @brief MBED System Layer APIs. |
flywind | 2:44bc61abdf33 | 8 | * To interface with any platform, eMPL needs access to various |
flywind | 2:44bc61abdf33 | 9 | * system layer functions. |
flywind | 2:44bc61abdf33 | 10 | * |
flywind | 2:44bc61abdf33 | 11 | * @{ |
flywind | 2:44bc61abdf33 | 12 | * @file mbed_i2c.h |
flywind | 2:44bc61abdf33 | 13 | * @brief Serial communication functions needed by eMPL to |
flywind | 2:44bc61abdf33 | 14 | * communicate to the MPU devices. |
flywind | 2:44bc61abdf33 | 15 | * @details This driver assumes that eMPL is with a sub-master clock set |
flywind | 2:44bc61abdf33 | 16 | * to 20MHz. The following MBEDs are supported: |
flywind | 2:44bc61abdf33 | 17 | */ |
flywind | 2:44bc61abdf33 | 18 | #ifndef _MBED_I2C_H_ |
flywind | 2:44bc61abdf33 | 19 | #define _MBED_I2C_H_ |
flywind | 2:44bc61abdf33 | 20 | |
flywind | 2:44bc61abdf33 | 21 | #ifdef __cplusplus |
flywind | 2:44bc61abdf33 | 22 | extern "C" { |
flywind | 2:44bc61abdf33 | 23 | #endif |
flywind | 2:44bc61abdf33 | 24 | |
flywind | 2:44bc61abdf33 | 25 | #include "i2c_api.h" |
flywind | 2:44bc61abdf33 | 26 | |
flywind | 2:44bc61abdf33 | 27 | void mbed_i2c_init(PinName sda, PinName scl); |
flywind | 2:44bc61abdf33 | 28 | |
flywind | 2:44bc61abdf33 | 29 | /** |
flywind | 2:44bc61abdf33 | 30 | * @brief Set up the I2C port and configure the MBED as the master. |
flywind | 2:44bc61abdf33 | 31 | * @return 0 if successful. |
flywind | 2:44bc61abdf33 | 32 | */ |
flywind | 2:44bc61abdf33 | 33 | int mbed_i2c_enable(void); |
flywind | 2:44bc61abdf33 | 34 | /** |
flywind | 2:44bc61abdf33 | 35 | * @brief Disable I2C communication. |
flywind | 2:44bc61abdf33 | 36 | * This function will disable the I2C hardware and should be called prior to |
flywind | 2:44bc61abdf33 | 37 | * entering low-power mode. |
flywind | 2:44bc61abdf33 | 38 | * @return 0 if successful. |
flywind | 2:44bc61abdf33 | 39 | */ |
flywind | 2:44bc61abdf33 | 40 | int mbed_i2c_disable(void); |
flywind | 2:44bc61abdf33 | 41 | /** |
flywind | 2:44bc61abdf33 | 42 | * @brief Write to a device register. |
flywind | 2:44bc61abdf33 | 43 | * |
flywind | 2:44bc61abdf33 | 44 | * @param[in] slave_addr Slave address of device. |
flywind | 2:44bc61abdf33 | 45 | * @param[in] reg_addr Slave register to be written to. |
flywind | 2:44bc61abdf33 | 46 | * @param[in] length Number of bytes to write. |
flywind | 2:44bc61abdf33 | 47 | * @param[out] data Data to be written to register. |
flywind | 2:44bc61abdf33 | 48 | * |
flywind | 2:44bc61abdf33 | 49 | * @return 0 if successful. |
flywind | 2:44bc61abdf33 | 50 | */ |
flywind | 2:44bc61abdf33 | 51 | int mbed_i2c_write(unsigned char slave_addr, |
flywind | 2:44bc61abdf33 | 52 | unsigned char reg_addr, |
flywind | 2:44bc61abdf33 | 53 | unsigned char length, |
flywind | 2:44bc61abdf33 | 54 | unsigned char const *data); |
flywind | 2:44bc61abdf33 | 55 | /** |
flywind | 2:44bc61abdf33 | 56 | * @brief Read from a device. |
flywind | 2:44bc61abdf33 | 57 | * |
flywind | 2:44bc61abdf33 | 58 | * @param[in] slave_addr Slave address of device. |
flywind | 2:44bc61abdf33 | 59 | * @param[in] reg_addr Slave register to be read from. |
flywind | 2:44bc61abdf33 | 60 | * @param[in] length Number of bytes to read. |
flywind | 2:44bc61abdf33 | 61 | * @param[out] data Data from register. |
flywind | 2:44bc61abdf33 | 62 | * |
flywind | 2:44bc61abdf33 | 63 | * @return 0 if successful. |
flywind | 2:44bc61abdf33 | 64 | */ |
flywind | 2:44bc61abdf33 | 65 | int mbed_i2c_read(unsigned char slave_addr, |
flywind | 2:44bc61abdf33 | 66 | unsigned char reg_addr, |
flywind | 2:44bc61abdf33 | 67 | unsigned char length, |
flywind | 2:44bc61abdf33 | 68 | unsigned char *data); |
flywind | 2:44bc61abdf33 | 69 | |
flywind | 2:44bc61abdf33 | 70 | #ifdef __cplusplus |
flywind | 2:44bc61abdf33 | 71 | } |
flywind | 2:44bc61abdf33 | 72 | #endif |
flywind | 2:44bc61abdf33 | 73 | |
flywind | 2:44bc61abdf33 | 74 | #endif /* _MBED_I2C_H_ */ |
flywind | 2:44bc61abdf33 | 75 | |
flywind | 2:44bc61abdf33 | 76 | /** |
flywind | 2:44bc61abdf33 | 77 | * @} |
flywind | 2:44bc61abdf33 | 78 | */ |