Jump to content

    
Sign in to follow this  
pevtsov

Простейшее устройство c FT245BM

Recommended Posts

Я собрал плату, http://www.dlpdesign.com/images/bit-bang-usb.pdf (FIGURE 2).

Как мне зажечь LED'ы? Скачал Test Application v1.0 с этого же сайта, но ничего не добился... Ни c VCP, ни с D2XX :(

 

Спасибо.

Share this post


Link to post
Share on other sites

С помощью этого у меня получалось мигать LED'ами через FTD2XX.dll.

//---------------------------------------------------------------------------

 

#include <vcl.h>

#include <stdio.h>

#include <conio.h>

#include <math.h>

#pragma hdrstop

 

//---------------------------------------------------------------------------

#pragma argsused

 

#include "Ftd2xx.h"

 

int main(int argc, char* argv[])

{

FT_HANDLE ftHandle;

FT_STATUS ftStatus;

UCHAR Mask = 0xff;

UCHAR Enable = 1;

UCHAR lpBuffer[4];

DWORD dwBytesToWrite = 1;

DWORD *lpdwBytesWritten;

UCHAR cmd;

 

printf("+-------------------------+\n");

printf("! BitBang tester !\n");

printf("+-------------------------+\n");

ftStatus = FT_Open(0,&ftHandle);

if (ftStatus == FT_OK)

{

printf("! Open OK. !\n");

printf("+-------------------------+\n");

}

else

{

printf("Open failed!\n");

goto Exit;

}

ftStatus = FT_SetBitMode(ftHandle,Mask,Enable);

if (ftStatus == FT_OK)

{

printf("! BitBang mode is set. !\n");

printf("+-------------------------+\n");

printf(" Esc to exit.\n");

}

else

{

printf("Unable to set BitBang mode!\n");

goto Exit;

}

// Start test

for(UCHAR i = 0; 1; i++)

{

lpBuffer[0] = pow(2, i%8);

ftStatus = FT_Write (ftHandle, lpBuffer, dwBytesToWrite, lpdwBytesWritten);

Sleep(100);

if(kbhit())

{

cmd = getch();

switch(cmd)

{

case 0x1B:

goto Exit;

}

}

}

Exit:

return 0;

}

//---------------------------------------------------------------------------

Share this post


Link to post
Share on other sites

Cпасибо огромное! Рабоает! Мигает ;)

 

А для чтения не нужно ничего делать? Например, считать со свича...

Я пишу просто

ftStatus = FT_Read(ftHandle, lpBufferR, dwBytesToRead, &lpdwBytesRead);

и оно как-то не пашет...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this