I’ve been receiving a number of questions about the programming interface for the FCD.
Although the quadrature I/Q stream is over a standard USB stereo soundcard interface, in order to change the centre frequency there is an additional programming interface that uses the USB HID standard interface. Here’s an example to set the centre frequency of the dongle give the frequency in kHz:
static unsigned char HIDSetFreq(HANDLE hWrite,HANDLE hRead,int nFreq)
{
DWORD dwBytesWritten=0;
DWORD dwBytesRead=0;
unsigned char au8BufOut[65]; // endpoint size + 1
unsigned char au8BufIn[65]; // endpoint size + 1
au8BufOut[0]=0; // First byte is report ID. Ignored by HID Class
// firmware as only config'd for one report
au8BufOut[1]=100; // Command to Set Frequency on dongle
au8BufOut[2]=(unsigned char)nFreq;
au8BufOut[3]=(unsigned char)(nFreq>>8);
au8BufOut[4]=(unsigned char)(nFreq>>16);
WriteFile(hWrite,au8BufOut,65,&dwBytesWritten,0);
ReadFile(hRead,au8BufIn,65,&dwBytesRead,0);
return au8BufIn[2]; // au8BufIn[2]==1 if success.
}
The HID command output to the dongle is 64 bytes, as is the HID response input back into the host. You also need to prepend the buffers with one byte each for the HID report ID that’s not actually used, so 65 bytes total each.
In the output command buffer, after the unused HID report byte, the FCD command byte follows. The “SetFreq” command is 100. Following this is the 24 bit little endian integer frequency specified in kHz.
In response, the 65 bytes buffer includes a copy of the command (100 in this case) at index 1 and a boolean success/fail 1/0 response at index 2.
So far so good. But you need to open up input and output HID handles first to use this function! This is rather more fiddly, certainly in the Windows world. I have some example code here that demonstrates this: http://www.g6lvb.com/Fungle/FCHid002.zip
Howard
17 Responses to Dongle programming interface