Skip to content
Snippets Groups Projects
Commit ac57e130 authored by mfenner's avatar mfenner
Browse files

HYT Communication working

parent b2ed27d9
No related branches found
No related tags found
No related merge requests found
......@@ -4,15 +4,15 @@
CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
RES = proghyt_private.res
RES =
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -lMPSSE -L. -g3 -fmessage-length=0
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
BIN = proghyt.exe
CXXFLAGS = $(CXXINCS) -ansi -traditional-cpp -fno-access-control -g3 -fmessage-length=0
CFLAGS = $(INCS) -ansi -traditional-cpp -fno-access-control -g3 -fmessage-length=0
CXXFLAGS = $(CXXINCS) -ansi -traditional-cpp -fno-access-control -O3 -g3 -fmessage-length=0
CFLAGS = $(INCS) -ansi -traditional-cpp -fno-access-control -O3 -g3 -fmessage-length=0
RM = rm -f
.PHONY: all all-before all-after clean clean-custom
......@@ -27,7 +27,4 @@ $(BIN): $(OBJ)
$(CPP) $(LINKOBJ) -o "proghyt.exe" $(LIBS)
main.o: main.c
$(CC) -c main.c -o main.o
proghyt_private.res: proghyt_private.rc
$(WINDRES) -i proghyt_private.rc --input-format=rc -o proghyt_private.res -O coff
$(CC) -c main.c -o main.o -O3
......@@ -48,7 +48,7 @@
encountered \n",__FILE__, __LINE__, __FUNCTION__);exit(1);}else{;}};
/* Application specific macro definations */
#define I2C_DEVICE_ADDRESS_HYT 0x50
#define I2C_DEVICE_ADDRESS_HYT 0x50 >> 1
#define I2C_WRITE_COMPLETION_RETRY 10
#define CHANNEL_TO_OPEN 0
......@@ -64,7 +64,7 @@ uint8 buffer[10];
void waitFor (unsigned int secs) {
unsigned int retTime = time(0) + secs; // Get finishing time.
unsigned long retTime = time(0) + secs; // Get finishing time.
while (time(0) < retTime); // Loop until it arrives.
}
......@@ -140,7 +140,7 @@ FT_STATUS read_hyt(uint8 slaveAddress, uint8 *data)
FT_STATUS status;
uint32 bytesToTransfer = 0;
uint32 bytesTransfered;
status |= I2C_DeviceRead(ftHandle, slaveAddress, 3, buffer, &bytesTransfered, I2C_TRANSFER_OPTIONS_START_BIT | I2C_TRANSFER_OPTIONS_STOP_BIT);
status = I2C_DeviceRead(ftHandle, slaveAddress, 3, buffer, &bytesTransfered, I2C_TRANSFER_OPTIONS_START_BIT | I2C_TRANSFER_OPTIONS_STOP_BIT);
APP_CHECK_STATUS(status);
*data = buffer[0];
return status;
......@@ -152,6 +152,7 @@ FT_STATUS read_hyt(uint8 slaveAddress, uint8 *data)
*
* This function reads a byte from a specified address within the 24LC024H EEPROM
*
* \param[in] slaveAddress Address of the I2C slave (EEPROM)
* \param[in] registerAddress Address of the memory location inside the slave from where the
* byte is to be read
......@@ -191,11 +192,11 @@ int main()
uint8 data;
int i,j;
#ifdef _MSC_VER
Init_libMPSSE();
#endif
channelConf.ClockRate = I2C_CLOCK_FAST_MODE;/*i.e. 400000 KHz*/
channelConf.LatencyTimer= 255;
channelConf.ClockRate = I2C_CLOCK_STANDARD_MODE;/*i.e. 100000 KHz*/
channelConf.LatencyTimer= 2;
//channelConf.Options = I2C_DISABLE_3PHASE_CLOCKING;
//channelConf.Options = I2C_ENABLE_DRIVE_ONLY_ZERO;
......@@ -232,27 +233,28 @@ int main()
printf("Setting GPIO Pin OFF.\r\n");
FT_WriteGPIO(ftHandle, 0x01, 0x00);
printf("%s\r\n",status);
printf("%d\r\n",status);
waitFor(1);
printf("Setting GPIO Pin ON.\r\n");
FT_WriteGPIO(ftHandle, 0x01, 0x01);
printf("%s\r\n",status);
//printf("%d\r\n",status);
printf("Starting Command Mode.\r\n");
//printf("Starting Command Mode.\r\n");
write_hyt(I2C_DEVICE_ADDRESS_HYT,0xA0,0x00,0x00);
printf("%s\r\n",status);
//printf("%d\r\n",status);
printf("Request I2C Address.\r\n");
//printf("Request I2C Address.\r\n");
write_hyt(I2C_DEVICE_ADDRESS_HYT,0x1C,0x00,0x00);
printf("%s\r\n",status);
//printf("%d\r\n",status);
printf("Reading I2C Address.\r\n");
//waitFor(1);
//printf("Reading I2C Address.\r\n");
read_hyt( I2C_DEVICE_ADDRESS_HYT, buffer);
printf("%X %X %X\r\n", buffer[0], buffer[1], buffer[2]);
printf("Leaving Command Mode.\r\n");
write_hyt(I2C_DEVICE_ADDRESS_HYT,0x80,0x00,0x00);
printf("%s\r\n",status);
printf("%d\r\n",status);
......@@ -260,9 +262,9 @@ int main()
status = I2C_CloseChannel(ftHandle);
}
#ifdef _MSC_VER
Cleanup_libMPSSE();
#endif
system("pause");
return 0;
}
......@@ -7,14 +7,14 @@ Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=proghyt_private.rc
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=
CppCompiler=_@@_
Linker=-lMPSSE_@@_-L._@@_
IsCpp=1
Icon=proghyt.ico
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
......@@ -27,7 +27,7 @@ CustomMakefile=Makefile.win
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=1101000000000001001000
CompilerSettings=1101000000001001001000
[Unit1]
FileName=main.c
......@@ -37,7 +37,7 @@ Compile=1
Link=1
Priority=1000
OverrideBuildCmd=1
BuildCmd=$(CC) -c main.c -o main.o
BuildCmd=$(CC) -c main.c -o main.o -O3
[VersionInfo]
Major=0
......
......@@ -16,7 +16,7 @@ Order=0,1
[Editor_0]
Open=1
Top=1
CursorCol=31
CursorRow=259
TopLine=216
CursorCol=33
CursorRow=238
TopLine=227
LeftChar=1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment