AK8963
Embed:
(wiki syntax)
Show/hide line numbers
I2CdevAK8963.h
00001 //ported from arduino library: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 00002 //written by szymon gaertig (email: szymon@gaertig.com.pl), small correction by Aloïs Wolff 00003 // 00004 //Changelog: 00005 //2013-01-08 - first beta release 00006 //2013-02-18 - fixed a malloc with no free in ::readBytes 00007 00008 #ifndef I2Cdev_AK8963_h 00009 #define I2Cdev_AK8963_h 00010 00011 #include "mbed.h" 00012 00013 #ifndef I2C_SDA 00014 #define I2C_SDA p9 00015 #define I2C_SCL p10 00016 #endif 00017 00018 #include "MODI2C.h" 00019 00020 namespace AK8963I2C { 00021 00022 class I2Cdev { 00023 private: 00024 00025 Serial debugSerial; 00026 public: 00027 I2Cdev(); 00028 I2Cdev(PinName i2cSda, PinName i2cScl); 00029 I2Cdev(MODI2C i2c_); 00030 00031 int8_t readBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00032 int8_t readBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00033 int8_t readBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00034 int8_t readBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00035 int8_t readByte(uint8_t devAddr, uint8_t regAddr, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00036 int8_t readWord(uint8_t devAddr, uint8_t regAddr, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00037 int8_t readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00038 int8_t readWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data, uint16_t timeout=I2Cdev::readTimeout()); 00039 00040 bool writeBit(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint8_t data); 00041 bool writeBitW(uint8_t devAddr, uint8_t regAddr, uint8_t bitNum, uint16_t data); 00042 bool writeBits(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint8_t data); 00043 bool writeBitsW(uint8_t devAddr, uint8_t regAddr, uint8_t bitStart, uint8_t length, uint16_t data); 00044 bool writeByte(uint8_t devAddr, uint8_t regAddr, uint8_t data); 00045 bool writeWord(uint8_t devAddr, uint8_t regAddr, uint16_t data); 00046 bool writeBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data); 00047 bool writeWords(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint16_t *data); 00048 00049 void readBytes_nb(uint8_t devAddr, char *command, uint8_t length, uint8_t *data, uint32_t (*function)(uint32_t), void* param); 00050 00051 static uint16_t readTimeout(void); 00052 00053 MODI2C i2c; 00054 00055 char* allocbuffer(); 00056 void freebuffer(); 00057 00058 MemoryPool<char[14], 16> pool; 00059 Queue<char, 16> queue; 00060 }; 00061 00062 } 00063 00064 #endif
Generated on Wed Jul 13 2022 20:54:49 by 1.7.2