Pārlūkot izejas kodu

#212 wiringPiI2CRawWrite and wiringPiI2CRawRead

pull/228/head
mstroh76 pirms 6 mēnešiem
vecāks
revīzija
e728c9dfa3
2 mainītis faili ar 17 papildinājumiem un 4 dzēšanām
  1. +13
    -2
      wiringPi/wiringPiI2C.c
  2. +4
    -2
      wiringPi/wiringPiI2C.h

+ 13
- 2
wiringPi/wiringPiI2C.c Parādīt failu

@@ -47,6 +47,7 @@

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
@@ -153,7 +154,7 @@ int wiringPiI2CReadReg16 (int fd, int reg)
return data.word & 0xFFFF ;
}

int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values)
int wiringPiI2CReadBlockData (int fd, int reg, uint8_t *values, uint8_t size)
{
union i2c_smbus_data data;

@@ -169,6 +170,11 @@ int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values)
return data.block[0];
}

int wiringPiI2CRawRead (int fd, uint8_t *values, uint8_t size)
{
return(read(fd, values, size));
}

/*
* wiringPiI2CWrite:
* Simple device write
@@ -203,7 +209,7 @@ int wiringPiI2CWriteReg16 (int fd, int reg, int value)
return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_WORD_DATA, &data) ;
}

int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *values)
int wiringPiI2CWriteBlockData (int fd, int reg, const uint8_t *values, uint8_t size)
{
union i2c_smbus_data data;

@@ -215,6 +221,11 @@ int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *val
return i2c_smbus_access (fd, I2C_SMBUS_WRITE, reg, I2C_SMBUS_BLOCK_DATA, &data) ;
}

int wiringPiI2CRawWrite (int fd, const uint8_t *values, uint8_t size)
{
return(write(fd, values, size));
}

/*
* wiringPiI2CSetupInterface:
* Undocumented access to set the interface explicitly - might be used


+ 4
- 2
wiringPi/wiringPiI2C.h Parādīt failu

@@ -31,12 +31,14 @@ extern "C" {
extern int wiringPiI2CRead (int fd) ;
extern int wiringPiI2CReadReg8 (int fd, int reg) ;
extern int wiringPiI2CReadReg16 (int fd, int reg) ;
extern int wiringPiI2CReadBlockData (int fd, int reg, uint8_t size, uint8_t *values);
extern int wiringPiI2CReadBlockData (int fd, int reg, uint8_t *values, uint8_t size); //Interface 3.3
extern int wiringPiI2CRawRead (int fd, uint8_t *values, uint8_t size); //Interface 3.3

extern int wiringPiI2CWrite (int fd, int data) ;
extern int wiringPiI2CWriteReg8 (int fd, int reg, int data) ;
extern int wiringPiI2CWriteReg16 (int fd, int reg, int data) ;
extern int wiringPiI2CWriteBlockData (int fd, int reg, uint8_t size, const uint8_t *values);
extern int wiringPiI2CWriteBlockData (int fd, int reg, const uint8_t *values, uint8_t size); //Interface 3.3
extern int wiringPiI2CRawWrite (int fd, const uint8_t *values, uint8_t size); //Interface 3.3

extern int wiringPiI2CSetupInterface (const char *device, int devId) ;
extern int wiringPiI2CSetup (const int devId) ;


Notiek ielāde…
Atcelt
Saglabāt