Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "iowkit.h"
struct _IOWKIT_SPECIAL_REPORT report;
ULONG dev_number;
int ex;
int reportz;
int i = 0;
int main(void){
IOWKIT_HANDLE ioHandle;
ioHandle = IowKitOpenDevice(); //open all IO Warriors which are connected
if (ioHandle != NULL)
{
printf("... success, access devices");
}
else
{
printf("... didn't open IoWarrior, handle error");
}
dev_number = IowKitGetNumDevs();
printf("\nFound %d devices",dev_number); //Gibt die Anzahl der gefundenen IO Warriors aus
printf("\nSPI enable"); //Spi aktivieren
report.ReportID = 0x08;
report.Bytes[0] = 0x01;
report.Bytes[1] = 0x03;
IowKitWrite(ioHandle, IOW_PIPE_SPECIAL_MODE, (char *) &report, sizeof(report));
printf("\nprogramming enable\n"); //Erstes Byte versenden
//memset(&report, 0, sizeof(report));
while(i<=5){
reportz = sizeof(report);
report.ReportID = 0x09;
report.Bytes[0] = 0x01;
report.Bytes[1] = 0x01;
report.Bytes[2] = 0x01;
report.Bytes[3] = 0x01;
report.Bytes[4] = 0x01;
report.Bytes[5] = 0x01;
report.Bytes[6] = 0x01;
IowKitWrite(ioHandle, IOW_PIPE_SPECIAL_MODE, (char *) &report, IOWKIT_SPECIAL_REPORT_SIZE);
IowKitRead(ioHandle, IOW_PIPE_SPECIAL_MODE, (char *) &report, IOWKIT_SPECIAL_REPORT_SIZE);
printf("\nread: %02X %02X %02X %02X %02X %02X %02X\n",report.Bytes[0],report.Bytes[1],report.Bytes[2],report.Bytes[3],report.Bytes[4],report.Bytes[5],report.Bytes[6]);
Sleep(500);
i++;
}
printf("\n%d",reportz);
IowKitCloseDevice(ioHandle);
scanf("%d",&ex);
return 0;
}
Vielen Danmk im Vorraus schonmal