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.
52 lines
1.4 KiB
52 lines
1.4 KiB
#ifndef _I2C_CH1_PIMPL_H_
|
|
#define _I2C_CH1_PIMPL_H_
|
|
|
|
#include <stdint.h>
|
|
#include <unistd.h>
|
|
#include <cstdio>
|
|
#include <ostream>
|
|
#include <iostream>
|
|
|
|
#include <linux/i2c-dev.h>
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
|
|
#define PORT_I2C "/dev/i2c-1"
|
|
#include "../../systems/systemCall.h"
|
|
#include "../../management/errorHandling.h"
|
|
|
|
#include "i2c.hpp"
|
|
|
|
class i2c_ch1_pImpL
|
|
{
|
|
public:
|
|
i2c_ch1_pImpL(const uint8_t& mode, ErrorHandler* err); // Mode : Master or Slave
|
|
uint8_t readByte(const uint8_t& address, const uint8_t& reg);
|
|
uint16_t readWord(const uint8_t& address, const uint8_t& reg);
|
|
uint8_t writeByte(const uint8_t& address, const uint8_t& data);
|
|
uint8_t writeWord(const uint8_t& address, const uint8_t& reg, const uint8_t& data);
|
|
uint8_t writeWordWithReg(const uint8_t& address, const uint8_t& reg, const uint16_t& data); // retuns 0 when a sucsessful transation ocures
|
|
void writeBuffer(const uint8_t& address, const uint8_t* buff, const uint8_t& len);
|
|
|
|
private:
|
|
enum{
|
|
send_buffer_size = 32,
|
|
receive_buffer_size = 32;
|
|
}
|
|
ErrorHandler *errorHandling;
|
|
int16_t deviceDescriptor;
|
|
uint8_t device_address;
|
|
uint8_t device_reg;
|
|
uint8_t send_buffer[send_buffer_size];
|
|
uint8_t recieve_buffer[receive_buffer_size];
|
|
uint8_t blocks;
|
|
uint8_t channel;
|
|
uint8_t mode;
|
|
};
|
|
|
|
|
|
#endif // _I2C_CH1_PIMPL_H_
|