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.
I2C.h
00001 #ifndef _I2C_H_ 00002 #define _I2C_H_ 00003 00004 #include "BCM2835.h" 00005 00006 class I2C 00007 { 00008 public: 00009 I2C(); 00010 ~I2C(); 00011 uint8_t read(uint8_t address, char* buf, int len, bool repeat = false); 00012 uint8_t read(bool ack = true); 00013 int write(uint8_t address, const char* buf, int len, bool repeat = false); 00014 int write(uint8_t data); 00015 private: 00016 int _memfd; 00017 int _i2c_byte_wait_us; 00018 int _i2c_bytes_to_read; 00019 uint8_t _addr; 00020 00021 void setAddress(uint8_t address); 00022 void requestFrom(unsigned char address, int len); 00023 uint8_t read(char* buf); 00024 uint8_t read_repeat(char* buf, int len); 00025 int write(const char* buf, int len); 00026 int map_peripheral(struct bcm2835_peripheral* p); 00027 void unmap_peripheral(struct bcm2835_peripheral* p); 00028 void wait_i2c_done(); 00029 }; 00030 00031 #endif // _I2C_H_ 00032
Generated on Tue Dec 20 2022 12:16:32 by
1.7.2