Programming Information for WiNRADiO G526e/DSPS

The G526e/DSPS API is implemented as a 32-bit library G526DSPSapi.dll. It provides functions for whole communication with the G526e/DSPS mpodule. The API can be used by any 32-bit application under Windows XP and later.

How to use the G526e/DSPS API

  1. Load the G526DSPSapi.dll library and get the exported functions
  2. Use the GetDspCount to get the count of G526e/DSPS modules present.
  3. Call the OpenDsp function to obtain a pointer to G526DSPS interface object. This object contains methods for controlling the opened device.
  4. Get the configuration of currently opened device by calling the GetDeviceInfo method.
  5. Use InitializeDdc to initialize a DDC.
  6. Use GetSnapshot to get a snapshot of DDC or ADC samples.
  7. Use StartDdcStream to start a continuous stream of DDC samples.
  8. Use SetDdcParams to set bandwidth and center frequency for desired DDC stream.
  9. To close the currently open G526e/DSPS device call the Destroy method.
  10. Unload the G526DSPSapi.dll library from memory.


G526DSPSapi.dll exported functions


GetDspCount

Scan the system for G526e/DSPS devices.

C++ declaration

Parameters

None.

Return Value

The function returns the number of G526e/DSPS devices present in the system.

Remarks

Calling this method is optional, it is possible to call OpenDsp with zero as parameter to open the first G526e/DSPS device.

See Also

OpenDsp


OpenDsp

Opens a G526e/DSPS device if not reserved and returns a pointer to its interface.

C++ declaration

Parameters

DeviceIndex

Index of the G526e/DSPS device to open. This index can be from 0 to (GetDspCount()-1).

Return Value

If the function succeeds, the return value is the pointer to the opened G526e/DSPS device. The return value is NULL otherwise.

Remarks

Each device may be opened only once in the whole system. If the desired device is already opened by this or another process, the function returns NULL. Use Destroy to close the device.

See Also

GetDspCount
Destroy


G526DSPS interface members


GetDeviceInfo

Retrieves information about the device.

C++ declaration

Parameters

TG526DSP_Info *Info

Pointer to the TG526DSP_Info structure. The cbSize member must be initialized to sizeof(TG526DSP_Info) before the call.

Return Value

Nonzero if success. Otherwise zero (incorrectly installed drivers).

Remarks

The TG526DSP_Info data are read from the device once upon opening and are not changed until closing the device.

See Also

GetParams
GetStatus


SetParams

Sets internal parameters of the device.

C++ declaration

Parameters

TG526DSPS_Params *Params

Pointer to TG526DSPS_Params structure. The cbSize member must be initialized to sizeof(TG526DSPS_Params) before the call.

Return Value

Nonzero if the request was successfully sent to the device. Zero if a problem occured.

Remarks

None.

See Also

GetParams
GetDeviceInfo


GetParams

Retrieves internal parameters of the device.

C++ declaration

Parameters

TG526DSPS_Params *Params

Pointer to the TG526DSPS_Params structure. The cbSize member must be initialized to sizeof(TG526DSPS_Params) before the call. Upon return, the structure is filled by the device params.

BOOL Synchronous

If set to FALSE, the last known device parameters are returned. Otherwise the function waits for the device to answer the request.

Return Value

Returns nonzero value if successful and zero value otherwise.

Remarks

Regardless the Synchronous argument, the API sends the GetParams request to the device.
The device params are sent to the API also when calling GetStatus method.

See Also

SetParams
GetStatus


GetStatus

Retrieves the actual internal status of the device.

C++ declaration

Parameters

TG526DSP_Status *Status

Pointer to the TG526DSP_Status structure. The cbSize member must be initialized to sizeof(TG526DSP_Status).

BOOL Synchronous

If set to FALSE last known status is returned. Otherwise, the call blocks until the answer arrives from the device.

Return Value

Returns nonzero if the status was successfuly copied. Returns zero value if failed.

Remarks

The internal status is sent to the API also when calling GetParams

See Also

GetParams


GetDdcType

Get information about a DDC type.

C++ declaration

Parameters

DWORD DdcTypeIndex

Index of the DDC type to get information about. Use GetDeviceInfo to get the number of supported DDC types.

Return Value

Returns a pointer to TG526DSP_DDC_Type structure describing the specified DDC type. If the DDC type specified by the DdcTypeIndex parameter is not supported, the return value is NULL.

Remarks

None.

See Also

GetDeviceInfo
TG526DSP_DDC_Type


InitializeDdc

Initializes one of DDCs.

C++ declaration

Parameters

DWORD DdcIndex

Index of the DDC to initialize. Allowed values are from 0 to 3.

DWORD DdcType

The required DDC type. To get more information about a DDC type use GetDdcType

Return Value

Returns zero if DDC initialization fails. Returns nonzero if initialization succeeds.

Remarks

Streaming must be stopped and no snapshot must be pending for the selected DDC when initializing it. Use StopDdcStream to stop streaming and CancelSnapshot to cancel a pending snaphot.

See Also

SetDdcParams
StartDdcStream
StopDdcStream
CancelSnapshot


StartDdcStream

Starts a DDC stream.

C++ declaration

Parameters

DWORD DdcIndex

The index of the DDC stream. Allowed values are from 0 to 3.

TG526DSP_StreamCallback Callback

Pointer to the callback function. The API will use this function to pass sample buffers to the application.

void *UserData

User value which will be sent to the callback function together with sample data to help to identify the data.

DWORD IQSamplesPerBuffer

Number of samples to buffer before they are passed to the application.

Return Value

Returns nonzero if the command was succesfully sent to the device. Return zero if communication with the device failed.

Remarks

Use this function to start DDC streaming after the stream is initialized. The API will repeatedly call the callback function to pass the DDC data. Use StopDdcStream to stop streaming.

See Also

TG526DSP_StreamCallback
InitializeDdc
StopDdcStream


StopDdcStream

Stops a DDC stream.

C++ declaration

Parameters

DWORD DdcIndex

The index of the DDC stream. Allowed values are from 0 to 3.

Return Value

Returns nonzero if the command was succesfully sent to the device. Return zero if communication with the device failed.

Remarks

Use this function to stop DDC streaming for example when you want to change the DDC type using InitializeDdc

See Also

TG526dsp_StreamCallback
InitializeDdc
StartDdcStream


SetDdcParams

Sets a DDC stream parameters.

C++ declaration

Parameters

DWORD DdcIndex

The index of the DDC stream. Allowed values are from 0 to 3.

TG526DSP_DDC_Params *Params

The pointer to the TG526DSP_DDC_Params structure. The cbSize member must be initialized to sizeof(TG526DSP_DDC_Params) before the call.

Return Value

Returns nonzero if the command was successfuly sent to the device. Doesn't mean that the parameters are correct. Returns zero if communication with the device failed.

Remarks

After the stream is initialized, use this function to set its paramerers.

See Also

GetDdcParams
TG526DSP_StreamCallback
InitializeDdc
StartDdcStream
StopDdcStream


GetDdcParams

Retrieves the current params for a DDC stream.

C++ declaration

Parameters

DWORD DdcIndex

Index of the DDC stream. Allowed values are from 0 to 3.

TG526DSP_DDC_Params *Params

Pointer to the TG526DSP_DDC_Params structure. The cbSize member must be initialized to sizeof(TG526DSP_DDC_Params) before the call.

Return Value

Returns nonzero if successfuly sent the new parameters. Otherwise returns zero.

Remarks

If called immediatelly after SetDdcParams, it can return the previous params, because the device didn't confirm the new setting yet.

See Also

SetDdcParams
InitializeDdc


GetSnapshot

Retrieves a snapshot. This can either an IF snapshot (a buffer with IF samples at max resolution 100MHz, 16-bit) or a DDC snapshot (a buffer with samples from selected DDC).

C++ declaration

Parameters

DWORD DdcIndex

Index of the DDC stream. For DDC snapshot the allowed values are from 0 to 3, or DDC_INDEX_ADC for ADC snapshot.

TG526DSP_SnapshotCallback Callback

Pointer to the callback function which will be called after the buffer arrives from the device.

void *UserData

User supplied value to be passed to the callback function to help identify the data.

DWORD BufSize

The size of the buffer supplied, in Bytes.

void *Buffer

User supplied buffer to be filled by the snapshot samples. This buffer is returned in the callback function.

BYTE Priority

Snapshot data streaming speed. This parameter allows to set the priority of streaming of snapshot data to prevent loss of DDC stream data.

TG526dDSPS_Trigger_Params *Trigger

Pointer to a TG526DSPS_Trigger_Params structure that describes the trigger to use to start the snapshot. The default value of this parameter is NULL, so no trigger is used and snapshot starts imediately.

Return Value

Returns nonzero if successfuly sent the request to the device. Otherwise returns zero.

Remarks

This function initializes a transfer of one buffer. It doesn't automatically stream the IF data to the callback function. Only one snapshot can be active at a time. If there is already a snapshot pending this function returns zero.

See Also

CancelSnapshot
InitializeDdc
TG526DSP_SnapshotCallback


CancelSnapshot

Cancels a pending snapshot request.

C++ declaration

Parameters

None.

Return Value

None.

Remarks

This function cancels a pending snapshot request. If there is no snapshot request pending, it does nothing.

See Also

GetSnapshot
InitializeDdc
TG526DSP_SnapshotCallback


SetWideBand

Sets the device to wide band or narrow band operation.

C++ declaration

Parameters

BOOL Wide

If set to FALSE configures the device to narrow band operation, otherwise configures the device to wide band operation.

Return Value

Return nonzero if the function succeeds, zero if any error occurs.

Remarks

Switching the operation mode stops all DDC streams and cancels any pending snapshot requests and clears any DDC initalization. Before restarting DDC streaming, DDCs must be initialized.
If the current opration mode is the same as required by the Wide parameter, this function does nothing.

See Also

GetSnapshot
InitializeDdc
StartDdcStream


GetAdcLevel

Retrieves the ADC signal level.

C++ declaration

Parameters

BOOL Synchornous

Synchronous operation flag. If set to FALSE, the request is sent to device but the last known value is returned immediately. Otherwise it waits for the device answer and the new value is returned.

Return Value

Returns the ADC signal level.

Remarks

None.

See Also


EnableGpio

Initializes and enables the GPIO port for communication.

C++ declaration

Parameters

BOOL Enable

The desired GPIO mode. If set to FALSE, this function disables GPIO, otherwise it enables it.

Return Value

Returns zero if the function fails, otherwise return nonzero.

Remarks

This function enables or disables GPIO. GPIO must be enabled before it can be used for communication with the Gpio function.

See Also

Gpio


Gpio

Function for cummunication through the GPIO port.

C++ declaration

Parameters

BYTE Direction

The desired GPIO communication direction. If a bit of this parameter is set to 1 the corresponding bit of Value is written to the GPIO port, otherwise it is just read out. Only the lowest 6 bits of this parameter are used.

BYTE *Value

Pointer to a variable that holds the value to be written to the GPIO port. After the function return this variable holds the value read out from the GPIO port. Only the lowest 6 bits of the variable are used, the highest 2 bits are set to 0.

Return Value

Returns zero if the function fails, otherwise return nonzero.

Remarks

This function writes a 6-bit Value masked by the 6 bit Direction to the GPIO port, reads 6 bits from the GPIO port and stores them to the Value variable in a single call. The GPIO port must be enabled using EnableGpio before this function is used.

See Also

EnableGpio


SetLvdsMode

Set the mode of the LVDS output.

C++ declaration

Parameters

TG526DSPS_LVDSMode Mode

Desired mode of the LVDS output. Supported values are: G526_None - to disable LVDS output, G526_ADC - to output ADC data (IF samples) to LVDS, G526_DDC - to output DDC samples.

Return Value

Returns nonzero if successfuly sent the request to the device. Otherwise returns zero.

Remarks

None.

See Also

TG526DSPS_LVDSMode
InitializeDdc


BootFirmware

Load a new program and reboot the DSP and/or FPGA.

C++ declaration

Parameters

DWORD NumDspCores

Number of DSP cores to boot. Allowed values are 1 or 2.

void *DspBoot

Pointer to the DSP boot data in *.ldr format.

DWORD DspBootLen

Size of DSP boot data in bytes.

void *FpgaBoot

Pointer to the FPGA boot data in *.RBF format.

DWORD FpgaBootLen

Size of the FPGA boot data in bytes.

Return Value

Returns nonzero if successfuly sent the request to the device. Otherwise returns zero.

Remarks

This method is for internal purposes. Please email us for additional information if you would like to build firmware for your device.

See Also

OpenDsp
Destroy


Destroy

Closes the opened device and deletes the interface object from the memory.

C++ declaration

Parameters

Remarks

The interface object is invalid after using this function. Using its method raises access violation.

See Also

OpenDsp


List of exported functions from G526DSPSapi.dll.

List of methods published by G526DSPS interface.


Definition G526DSPS interface


class G526DSPS

{

public:

	virtual BOOL __stdcall GetDeviceInfo(TG526DSP_Info *Info)=0;

	virtual BOOL __stdcall SetParams(TG526DSPS_Params *Params, BOOL Synchronous)=0;

	virtual BOOL __stdcall GetParams(TG526DSPS_Params *Params, BOOL Synchronous)=0;

	virtual BOOL __stdcall GetStatus(TG526DSP_Status *Status, BOOL Synchronous)=0;



	virtual TG526DSP_DDC_Type *__stdcall GetDdcType(DWORD DdcTypeIndex)=0;

	virtual BOOL __stdcall InitializeDdc(DWORD DdcIndex, DWORD DdcType)=0;

	virtual BOOL __stdcall StartDdcStream(DWORD DdcIndex, TG526DSP_StreamCallback Callback, void *UserData, DWORD IQSamplesPerBuffer)=0;

	virtual BOOL __stdcall StopDdcStream(DWORD DdcIndex)=0;

	virtual BOOL __stdcall SetDdcParams(DWORD DdcIndex, TG526DSP_DDC_Params *Params, BOOL Synchronous)=0;

	virtual BOOL __stdcall GetDdcParams(DWORD DdcIndex, TG526DSP_DDC_Params *Params)=0;



	virtual BOOL __stdcall GetSnapshot(DWORD DdcIndex, TG526DSP_SnapshotCallback Callback, void *UserData, DWORD BufSize, void *Buffer, BYTE Priority, TG526DSPS_Trigger_Params *Trigger=NULL)=0;

	virtual void __stdcall CancelSnapshot(void)=0;



	virtual BOOL __stdcall SetWideBand(BOOL Wide)=0;	// narrow mode by default

	virtual WORD __stdcall GetAdcLevel(BOOL Synchronous)=0;   //TB



	virtual BOOL __stdcall EnableGpio(BOOL Enable)=0;

	virtual BOOL __stdcall Gpio(BYTE Direction, BYTE *Value)=0;



	virtual BOOL __stdcall SetLvdsMode(TG526DSPS_LVDS_Mode Mode)=0;

	virtual BOOL __stdcall BootFirmware(DWORD NumDspCores,void *DspBoot,DWORD DspBootLen,void *FpgaBoot,DWORD FpgaBootLen)=0;



	virtual void __stdcall Destroy()=0;

};


Definition TG526DSP_Info structure.


struct TG526DSP_Info

{

	DWORD cbSize;                 // sizeof(TG526DSP_Info)

	char SerialNumber[9];         // 8 chars with zero terminal

	DWORD BF_FW_Type;             // reserved, zero

	DWORD BF_FW_Version;          // version of BF FW

	DWORD FPGA_FW_Version;        // version of FPGA FW

	DWORD NarrowBandDdcTypeCount; // Number of narrow band DDC types

	DWORD WideBandDdcTypeCount;   // Number of wide band DDC types

};


Definition of TG526DSPS_Params structure


struct TG526DSPS_Params

{

	DWORD cbSize;		// sizeof(TG526DSP_ADC_Params)

	BOOL ExternalReference;

	BOOL Bypass;

	BOOL SelfTest;

	BOOL Gain;

	BOOL Dithering;

};


Definition of TG526DSP_Status structure


struct TG526DSP_Status

{

	DWORD cbSize;		// sizeof(TG526DSP_ADCSTATUS)

	BOOL PllLocked;

	BOOL OwenReady;

	signed char Temperature;

};



Definition of TG526DSP_DDC_Params structure


struct TG526DSP_DDC_Params 

{

	DWORD cbSize;        // sizeof(TG526DSP_DDCPARAMS)

	DWORD DdcFrequency;  // DDC frequency in Hz

};


Definition of TG526DSP_DDC_Type structure


struct TG526DSP_DDC_Type

{

	DWORD SamplingRate;

	DWORD SpectrumBandwidth;

};


Definition of TG526DSPS_Trigger_Params structure


struct TG526DSPS_Trigger_Params

{

  DWORD cbSize;

  TG526DSPS_Trigger Type;

  BOOL PolarityExtTrigger;

  BOOL Polarity1PPS;

  BOOL ClearArmAfterTrigger;

};


Definition of TG526DSP_TimeStamp structure


struct TG526DSP_TimeStamp

{

	DWORD SampleIndex;

	DWORD TimeStamp;

};


Definition of TG526DSPS_Trigger enumeration type


enum TG526DSPS_Trigger

{

	Disarm,

	swTrigger,

	swArmExtTrigger,

	swArm1PPstrigger,

	ExtArmLevel1PPStrigger,

	ExtArmEdge1PPStrigger

};


Definition of TG526DSPS_LVDS_Mode enumeration type


enum TG526DSPS_LVDS_Mode

{

	G526_None=0, 

	G526_ADC,

	G526_DDC

};


Definition of DDC_INDEX_ADC constant


#define DDC_INDEX_ADC    0xFFFFFFFF


Definition of TG526DSP_SnapshotCallback type


typedef void (__stdcall *TG526DSP_SnapshotCallback)(void *UserData, void *Buffer, DWORD SampleCount);


Definition of TG526DSP_StreamCallback type.


typedef void (__stdcall *TG526DSP_StreamCallback)(void *UserData, DWORD ddcIndex, TG526DSP_TimeStamp *ts, int *Buffer, DWORD IQSamplesCount);