pixy Libari 2
Dependents: PES PES1 PES4 PES3
PixyLinkI2C.h
- Committer:
- scholfa2
- Date:
- 2017-03-29
- Revision:
- 1:a57585d5e81b
- Parent:
- 0:ed8dc4531ac1
File content as of revision 1:a57585d5e81b:
#ifndef PIXYLINKI2C_H #define PIXYLINKI2C_H #include "I2C.h" #include "PixyLink.h" class PixyLinkI2C : public PixyLink, private I2C { public: PixyLinkI2C(PinName sda, PinName scl) : PixyLink(PIXY_DEFAULT_ADDR), I2C(sda, scl){ I2C::frequency(100000); }; virtual uint16_t getWord() { uint8_t data[2] = {0, 0}; I2C::read((int)m_addr, (char *)data, 2); return ((uint16_t)data[1] << 8) | data[0]; }; virtual uint8_t getByte() { uint8_t data = 0; I2C::read((int)m_addr, (char*)&data, 1); return data; }; virtual int8_t send(uint8_t *data, uint8_t len) { return I2C::write((int)m_addr, (char*)data, len); }; private: static const uint8_t PIXY_DEFAULT_ADDR = 0xAC; }; #endif //PIXYLINKI2C_H