We are having a terrible time trying to get the Zoom TMDSMEVM3530-L 1013403 Rev A development kit to communicate over I2C using Win CE 6.0.
The goal is to communicate with an ALS light sensor connected to I2C2. Our sensor is at address 0x39 over we are starting with the test ap.
We have successfully installed the Win CE 6.0 development system and the BSP for the OMAP bard. We are compiling code and loading the new code in the development board and we can see our code changes take effect.
We have tried to use the example test code called I2C2DriverTest for testing I2C2 and we are not seeing this code communicate on the bus either. We have a very nice Tektronix 3014 scope that allows us to monitor I2C traffic on a bus. All we see is communication to a device at address 0x48 each time we touch the display. I assume this is traffic from the display system. We are connected to high density breakout board connector J17 pin 57 for I2C2_CLK and connector J18 pin 60 for I2C2_DATA signals.
I am including a copy of the code we are testing for reference. You can see how we are trying to configure this port and we have a while loop set up so it will continue to read and write data. We see no data.
My feeling is that we must have an issue with the CreateFile routine or the DeviceIoControl which are both setting up the physical path to the device.
Has anyone else seen this issue or do you have any ideas what may be wrong?
// I2CDriverTestApp.cpp : Defines the entry point for the console application.
//
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <types.h>
#include <oal.h>
#include <oalex.h>
#include <ceddk.h>
#include <ceddkex.h>
#include <omap3430.h>
//#include <shellproc.h>
#include <ceddkex.h>
#include <initguid.h>
#include <omap3430_guid.h>
#include "..\..\..\public\common\oak\inc\windev.h"
#include <winioctl.h>
#include "stdafx.h"
//#include "..\..\..\Platform\LPD_OMAP35X_SOM\SRC\CSP\INC\I2C.h"
//#include <i2cproxy.h>
//#include <proxyapi.h>
//#include <twl.h>
//#include <twl4030.h>
//#define FILE_DEVICE_UNKNOWN 0x00000022 //#define CTL_CODE(DeviceType, Function, Method, Access) \ #define I2C_SUBADDRESS_MODE_8 1 //------------------------------------------------------------------------------ #define IOCTL_I2C_SET_SLAVE_ADDRESS 0x220800 //------------------------------------------------------------------------------ #define IOCTL_I2C_SET_SUBADDRESS_MODE 0x220804 int WINAPI BOOL result; hPort = CreateFile(TEXT("I2C2:"),GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,0,0); /*result = DeviceIoControl(hPort, IOCTL_I2C_SET_SUBADDRESS_MODE, &addrmode, while(1){ result = WriteFile(hPort, outdata, 6, &len, 0); _tprintf(_T("len %d\n"),len); _tprintf(_T("Out Data %d %d %d %d %d %d\n"),outdata[0],outdata[1],outdata[2],outdata[3],outdata[4],outdata[5]); SetFilePointer(hPort,0, NULL, FILE_BEGIN); result = ReadFile(hPort, indata, 6, &len, 0); _tprintf(_T("len %d\n"),len); _tprintf(_T("In Data %d %d %d %d %d %d\n"),indata[0],indata[1],indata[2],indata[3],indata[4],indata[5]); if((indata[0] == outdata[0]) && return 0;
//#include <ceddkex.h>
//#define FILE_ANY_ACCESS 0
#define METHOD_BUFFERED 0
// (((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method))
// CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
// CTL_CODE(FILE_DEVICE_UNKNOWN, 0x0201, METHOD_BUFFERED, FILE_ANY_ACCESS)
WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nCmdShow)
{
HANDLE hPort;
DWORD dwSlaveAddr = 0x50;
DWORD addrmode = I2C_SUBADDRESS_MODE_8;
unsigned char outdata[6] = {1,2,3,4,5,6};
unsigned char indata[6] = {0,0,0,0,0,0};
DWORD len = 6;
_tprintf(_T("Begin I2C2 Driver Test"));
// set slave address of i2c device
result = DeviceIoControl(hPort, IOCTL_I2C_SET_SLAVE_ADDRESS, &dwSlaveAddr,
sizeof(dwSlaveAddr), NULL, 0, NULL, NULL);
sizeof(addrmode), NULL, 0, NULL, NULL);*/
SetFilePointer(hPort, 0, NULL, FILE_BEGIN);
(indata[1] == outdata[1]) &&
(indata[2] == outdata[2]) &&
(indata[3] == outdata[3]) &&
(indata[4] == outdata[4]) &&
(indata[5] == outdata[5]))
{
_tprintf(_T("Test Success\n"));
}
else
{
_tprintf(_T("Test Failed\n"),len);
}
}//while
getchar();
}