Mailinglist Archive: opensuse-programming-de (158 mails)

< Previous Next >
Re: USB ansteuern!
  • From: Jan Hendrik Berlin <j.h.berlin@xxxxxxxxxxxxxxx>
  • Date: Wed, 14 May 2003 16:35:35 +0200
  • Message-id: <200305141633.09298.j.h.berlin@xxxxxxxxxxxxxxx>
Hier ein Programm für den Chip, welches aber für Windows geschrieben ist!
Vieleicht kennt jemand die Befehle für Linux!!

Tux007//
// ioblink.cpp - Blinking LEDs sample
//

#include "stdafx.h"

int main(int argc, char* argv[])
{
IOWKIT_HANDLE ioHandle;
int i, bits, nWritten;
IOWKIT_REPORT rep;

// Open device
ioHandle = IowKitOpenDevice();
// Check for failure
if (ioHandle == NULL) {
printf("Failed to open device\n");
goto out;
}
// Init report
// Report ID 0 is for writing to 32 input/output pins
rep.ReportID = 0;
printf("Blinking LEDs...\n");
// Blinking'
for (i = 0; i < 100; i++) {
// Generate random 8 bits
bits = (rand() & 1) << 7;
bits |= (rand() & 1) << 6;
bits |= (rand() & 1) << 5;
bits |= (rand() & 1) << 4;
bits |= (rand() & 1) << 3;
bits |= (rand() & 1) << 2;
bits |= (rand() & 1) << 1;
bits |= (rand() & 1);
// Shift them to high 32 bits
rep.Value = bits << 24;
// Write to IO-Warrior
nWritten = IowKitWrite(ioHandle, 0, (PCHAR) &rep, sizeof(rep));
if (nWritten != 5) {
printf("No write, err %d %d\n", nWritten, GetLastError());
}
// Sleep for 25ms
Sleep(25);
}
printf("Blinking complete\n");
// All ones is off
rep.Value = ~0UL;
// Set LEDs off
IowKitWrite(ioHandle, 0, (PCHAR) &rep, sizeof(rep));
// Close device
IowKitCloseDevice(ioHandle);
out:

return 0;
}
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#if !defined(AFX_STDAFX_H__DC6C3DDD_FDE5_4A3C_9766_2330E922A0DF__INCLUDED_)
#define AFX_STDAFX_H__DC6C3DDD_FDE5_4A3C_9766_2330E922A0DF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include "iowkit.h"

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__DC6C3DDD_FDE5_4A3C_9766_2330E922A0DF__INCLUDED_)
// stdafx.cpp : source file that includes just the standard includes
// ioblink.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
< Previous Next >
Follow Ups