Shop OBEX P1 Docs P2 Docs Learn Events
Programing FT432H using C# — Parallax Forums

Programing FT432H using C#

JasonJasonJasonJason Posts: 1
edited 2011-11-12 13:03 in General Discussion
Hi
I am not sure that this is the forum for my question, but i try...
I have FT4232H mini module I am simply try switch on LED connect to Channel B (D6--> GPIOL2)
I know to verify the chip, I know to open the port but, I do not know to write '1' and switch the LED on
I am using C#
here my code:
[code][using
System;

using
System.Collections.Generic;

using
System.ComponentModel;

using
System.Data;

using
System.Drawing;

using
System.Linq;

using
System.Text;

using
System.Windows.Forms;

using
System.Threading;

using
DWORD = System.UInt32;


using
FTD2XX_NET;

using
FT_HANDLE = System.UInt32;


namespace
LedOnOff

{


publicpartialclassForm1 : Form

{


public Form1()

{

InitializeComponent();



//



// Variables


//






FTDI.FT_STATUS ftStatus = FTDI.FT_STATUS.FT_OK; //Result of each D2XX call


FT_HANDLE ftHandle; // Handle of the FTDI device



FTDI myFtdiDevice = newFTDI();



UInt32 dwNumDevs = 0; // The number of devices


UInt32 ftdiDeviceCount = 0;


DWORD uiDevIndex = 0xF; // The device in the list that we'll use


Byte[] byOutputBuffer; //http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx

byOutputBuffer =
newByte[8]; // Buffer to hold MPSSE commands and data to be sent to the FT2232H



Byte[] byInputBuffer; //http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx

byInputBuffer =
newByte[8]; // Buffer to hold data read from the FT2232H



DWORD dwCount = 0; // General loop index


DWORD dwNumBytesToSend = 0; // Index to the output buffer


DWORD dwNumBytesSent = 0; // Count of actual bytes sent - used with FT_Write


DWORD dwNumBytesToRead = 0; // Number of bytes available to read


// in the driver's input buffer


DWORD dwNumBytesRead = 0; // Count of actual bytes read - used with FT_Read


DWORD dwClockDivisor = 0x05DB; // Value of clock divisor, SCL Frequency = 60/((1+0x05DB)*2) (MHz) = 1Mhz



//



// Does an FTDI device exist?


//



ftStatus = myFtdiDevice.GetNumberOfDevices(
ref dwNumDevs);


if (ftStatus == FTDI.FT_STATUS.FT_OK) //Check status

{


//MessageBox.Show("Number of FTDI devices: " + dwNumDevs.ToString());



}



// If no devices available, return


if (dwNumDevs == 0)

{


// Wait for a key press


//MessageBox.Show("Failed to get number of devices (error " + ftStatus.ToString() + ")");

Status.Text =
"Not Connected";

}


else

{


//MessageBox.Show("device connected");

Status.Text =
"Connected";




// Determine the number of FTDI devices connected to the machine

ftStatus = myFtdiDevice.GetNumberOfDevices(
ref ftdiDeviceCount);


 


// Allocate storage for device info list


FTDI.FT_DEVICE_INFO_NODE[] ftdiDeviceList = newFTDI.FT_DEVICE_INFO_NODE[ftdiDeviceCount];



// Populate our device list

ftStatus = myFtdiDevice.GetDeviceList(ftdiDeviceList);



// Open the second port by serial number

ftStatus = myFtdiDevice.OpenBySerialNumber(ftdiDeviceList[1].SerialNumber);


if (ftStatus != FTDI.FT_STATUS.FT_OK)

{


// Wait for a key press


MessageBox.Show("Failed to open device (error " + ftStatus.ToString() + ")");


}


else

{


//Here I need to write to B6

}

}


}

}

}

 
/CODE]
Sign In or Register to comment.