Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of pixy by
PixyLinkI2C.h
00001 #ifndef TUIASI_PIXYLINKI2C_H 00002 #define TUIASI_PIXYLINKI2C_H 00003 00004 #include "I2C.h" 00005 #include "PixyLink.h" 00006 00007 class PixyLinkI2C : public PixyLink, private I2C 00008 { 00009 public: 00010 PixyLinkI2C(PinName sda, PinName scl) : 00011 PixyLink(PIXY_DEFAULT_ADDR), I2C(sda, scl) { 00012 }; 00013 00014 virtual uint16_t getWord() { 00015 uint8_t data[2] = {0, 0}; 00016 I2C::read((int)m_addr, (char *)data, 2); 00017 return ((uint16_t)data[1] << 8) | data[0]; 00018 }; 00019 00020 virtual uint8_t getByte() { 00021 uint8_t data = 0; 00022 I2C::read((int)m_addr, (char*)&data, 1); 00023 return data; 00024 }; 00025 00026 virtual int8_t send(uint8_t *data, uint8_t len) { 00027 return I2C::write((int)m_addr, (char*)data, len); 00028 }; 00029 00030 00031 private: 00032 static const uint8_t PIXY_DEFAULT_ADDR = 0x54; 00033 }; 00034 00035 #endif //TUIASI_PIXYLINKI2C_H
Generated on Fri Jul 22 2022 19:10:53 by
