You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __I2C_PORT_HEADERS__
  2. #define __I2C_PORT_HEADERS__
  3. #include <stdio.h>
  4. #include <unistd.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <unistd.h>
  8. #include <fcntl.h>
  9. #include <sys/ioctl.h>
  10. #include <linux/i2c.h>
  11. #include <linux/i2c-dev.h>
  12. #undef _LINUX_I2C_DEV_H
  13. #include "../../data/transport/transportBus.h"
  14. #define I2C_PAGE_BYTES 128 //64
  15. class i2cPort {
  16. private:
  17. int m_nFID;
  18. basicLogCollection * m_pLog;
  19. uint8_t m_bAddress;
  20. uint8_t m_bRegAddrBytes;
  21. int _write( int fd, int device_addr, uint16_t offset, const char* data, int data_len );
  22. int _read( int fd, int device_addr, uint16_t offset, char* data, int data_len );
  23. public:
  24. explicit i2cPort( CSTR DevicePath, uint8_t DevBusAddr, int Speed = 0, uint8_t RegAddrBytes = 1 );
  25. virtual ~i2cPort();
  26. bool readMZ( uint16_t offset, uint8_t *buffer, int len );
  27. bool writeMZ( uint16_t offset, uint8_t *buffer, int len );
  28. uint8_t read8( uint16_t offset );
  29. bool write8( uint16_t offset, uint8_t byte );
  30. };
  31. #endif