Skip to content

Commit

Permalink
Merge pull request #25 from Alexmac22347/master
Browse files Browse the repository at this point in the history
allowed both ports to be controlled at the same time
  • Loading branch information
kekiefer committed Mar 26, 2016
2 parents a664400 + be059eb commit 76a1f43
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions software/raspberrypi_libs/leptonSDKEmb32PUB/raspi_I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include "LEPTON_Macros.h"
#include "raspi_I2C.h"
#include "LEPTON_I2C_Reg.h"
#include <stdio.h>
#include <stdlib.h>

#include <fcntl.h>
Expand All @@ -69,7 +68,9 @@
/** LOCAL DEFINES **/
/******************************************************************************/
//Raspi handle;
int leptonDevice;
int leptonDevice0;
int leptonDevice1;

const LEP_INT32 ADDRESS_SIZE_BYTES = 2;
const LEP_INT32 VALUE_SIZE_BYTES = 2;
float clk_rate;
Expand Down Expand Up @@ -132,11 +133,16 @@ LEP_RESULT DEV_I2C_MasterInit(LEP_UINT16 portID,
//aa_target_power(handle, AA_TARGET_POWER_BOTH);

//do it live!

int leptonDevice;
if(portID) {
leptonDevice = open("/dev/i2c-1", O_RDWR);
} else {
leptonDevice = open("/dev/i2c-0", O_RDWR);
}
leptonDevice1 = open("/dev/i2c-1", O_RDWR);
leptonDevice = leptonDevice1;
} else {
leptonDevice0 = open("/dev/i2c-0", O_RDWR);
leptonDevice = leptonDevice0;
}

if(leptonDevice < 0) {
//we have problem connecting
result = LEP_ERROR;
Expand Down Expand Up @@ -212,7 +218,12 @@ LEP_RESULT DEV_I2C_MasterReadData(LEP_UINT16 portID, // User-defi

//DONE: here we do a raspi raspi_i2c_write_read
//this means writing the register, then reading bytes!

int leptonDevice;
if(portID) {
leptonDevice = leptonDevice1;
} else {
leptonDevice = leptonDevice0;
}

int writeValue = write(leptonDevice, txdata, bytesToWrite);
if(writeValue < 0) {
Expand Down Expand Up @@ -289,7 +300,13 @@ LEP_RESULT DEV_I2C_MasterWriteData(LEP_UINT16 portID, // User-defi

//DONE: here we do raspi_i2c_write_ext
//raspi_result = aa_i2c_write_ext(handle, deviceAddress, AA_I2C_NO_FLAGS, bytesToWrite, (LEP_UINT8*)txdata, (u16*)&bytesActuallyWritten);


int leptonDevice;
if(portID) {
leptonDevice = leptonDevice1;
} else {
leptonDevice = leptonDevice0;
}

bytesActuallyWritten = write(leptonDevice, (LEP_UINT8*)txdata, bytesToWrite);

Expand Down

0 comments on commit 76a1f43

Please sign in to comment.