SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include "fcdhid.h"
Go to the source code of this file.
Functions | |
hid_device * | fcdOpen (uint16_t usVID, uint16_t usPID, int whichdongle) |
Open FCD device. More... | |
void | fcdClose (hid_device *phd) |
Close FCD HID device. More... | |
FCD_MODE_ENUM | fcdGetMode (hid_device *phd) |
Get FCD mode. More... | |
FCD_MODE_ENUM | fcdGetFwVerStr (hid_device *phd, char *str) |
Get FCD firmware version as string. More... | |
FCD_MODE_ENUM | fcdGetCaps (hid_device *phd, FCD_CAPS_STRUCT *fcd_caps) |
Get hardware and firmware dependent FCD capabilities. More... | |
FCD_MODE_ENUM | fcdGetCapsStr (hid_device *phd, char *caps_str) |
Get hardware and firmware dependent FCD capabilities as string. More... | |
FCD_MODE_ENUM | fcdAppReset (hid_device *phd) |
Reset FCD to bootloader mode. More... | |
FCD_MODE_ENUM | fcdAppSetFreqkHz (hid_device *phd, int nFreq) |
Set FCD frequency with kHz resolution. More... | |
FCD_MODE_ENUM | fcdAppSetFreq (hid_device *phd, int nFreq) |
Set FCD frequency with Hz resolution. More... | |
FCD_MODE_ENUM | fcdBlReset (hid_device *phd) |
Reset FCD to application mode. More... | |
FCD_MODE_ENUM | fcdBlErase (hid_device *phd) |
Erase firmware from FCD. More... | |
FCD_MODE_ENUM | fcdBlWriteFirmware (hid_device *phd, char *pc, int64_t n64Size) |
Write new firmware into the FCD. More... | |
FCD_MODE_ENUM | fcdBlVerifyFirmware (hid_device *phd, char *pc, int64_t n64Size) |
Verify firmware in FCd flash. More... | |
FCD_MODE_ENUM | fcdAppSetParam (hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len) |
Write FCD parameter (e.g. gain or filter) More... | |
FCD_MODE_ENUM | fcdAppGetParam (hid_device *phd, uint8_t u8Cmd, uint8_t *pu8Data, uint8_t u8len) |
Read FCD parameter (e.g. gain or filter) More... | |
FCD_MODE_ENUM fcdAppGetParam | ( | hid_device * | phd, |
uint8_t | u8Cmd, | ||
uint8_t * | pu8Data, | ||
uint8_t | u8len | ||
) |
Read FCD parameter (e.g. gain or filter)
u8Cmd | The command byte / parameter ID, see FCD_CMD_APP_GET_* |
pu8Data | TPointer to buffer where the parameter value(s) will be written |
u8len | Length of pu8Data in bytes |
This function can be used to read the value of a parameter in the FCD for which there is no high level API call. It gives access to the low level API of the FCD and the caller is expected to be aware of the various FCD commands, since they are required to be supplied as parameter to this function.
The return value can be used to determine the success or failure of the command execution:
Definition at line 884 of file fcdhid.c.
References FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
FCD_MODE_ENUM fcdAppReset | ( | hid_device * | phd | ) |
Reset FCD to bootloader mode.
This function is used to switch the FCD into bootloader mode in which various firmware operations can be performed.
FIXME: hid_read() will occasionally hang due to a pthread_cond_wait() never returning. It seems that the read_callback() in hid-libusb.c will never receive any data during the reconfiguration. Since the same logic works in the native windows application, it could be a libusb thing. Anyhow, since the value returned by this function is not used, we may as well just skip the hid_read() and return FME_NONE. Correct switch from APP to BL mode can be observed in /var/log/messages (linux) (when in bootloader mode the device version includes 'BL')
Definition at line 339 of file fcdhid.c.
References FCD_CMD_APP_RESET, FCD_MODE_NONE, and hid_write().
FCD_MODE_ENUM fcdAppSetFreq | ( | hid_device * | phd, |
int | nFreq | ||
) |
Set FCD frequency with Hz resolution.
nFreq | The new frequency in Hz. |
This function sets the frequency of the FCD with 1 Hz resolution. The parameter nFreq must already contain any necessary frequency correction.
Definition at line 450 of file fcdhid.c.
References FCD_CMD_APP_SET_FREQ_HZ, FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
Referenced by FCDProInput::set_center_freq(), and FCDProPlusInput::set_center_freq().
FCD_MODE_ENUM fcdAppSetFreqkHz | ( | hid_device * | phd, |
int | nFreq | ||
) |
Set FCD frequency with kHz resolution.
nFreq | The new frequency in kHz. |
This function sets the frequency of the FCD with 1 kHz resolution. The parameter nFreq must already contain any necessary frequency correction.
Definition at line 400 of file fcdhid.c.
References FCD_CMD_APP_SET_FREQ_KHZ, FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
FCD_MODE_ENUM fcdAppSetParam | ( | hid_device * | phd, |
uint8_t | u8Cmd, | ||
uint8_t * | pu8Data, | ||
uint8_t | u8len | ||
) |
Write FCD parameter (e.g. gain or filter)
u8Cmd | The command byte / parameter ID, see FCD_CMD_APP_SET_* |
pu8Data | The parameter value to be written |
u8len | Length of pu8Data in bytes |
This function can be used to set the value of a parameter in the FCD for which there is no high level API call. It gives access to the low level API of the FCD and the caller is expected to be aware of the various FCD commands, since they are required to be supplied as parameter to this function.
The return value can be used to determine the success or failure of the command execution:
Definition at line 826 of file fcdhid.c.
References FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
Referenced by FCDProInput::set_band(), FCDProPlusInput::set_bias_t(), FCDProInput::set_biasCurrent(), FCDProInput::set_gain1(), FCDProInput::set_gain2(), FCDProInput::set_gain3(), FCDProInput::set_gain4(), FCDProInput::set_gain5(), FCDProInput::set_gain6(), FCDProPlusInput::set_if_filter(), FCDProPlusInput::set_if_gain(), FCDProInput::set_ifFilter(), FCDProPlusInput::set_lna_gain(), FCDProInput::set_lnaEnhance(), FCDProInput::set_lnaGain(), FCDProPlusInput::set_mixer_gain(), FCDProInput::set_mixerFilter(), FCDProInput::set_mixerGain(), FCDProInput::set_mode(), FCDProInput::set_rcFilter(), FCDProPlusInput::set_rf_filter(), and FCDProInput::set_rfFilter().
FCD_MODE_ENUM fcdBlErase | ( | hid_device * | phd | ) |
Erase firmware from FCD.
This function deletes the firmware from the FCD. This is required before writing new firmware into the FCD.
Definition at line 559 of file fcdhid.c.
References FCD_CMD_BL_ERASE, FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
FCD_MODE_ENUM fcdBlReset | ( | hid_device * | phd | ) |
Reset FCD to application mode.
This function is used to switch the FCD from bootloader mode into application mode.
FIXME: hid_read() will hang due to a pthread_cond_wait() never returning. It seems that the read_callback() in hid-libusb.c will never receive any data during the reconfiguration. Since the same logic works in the native windows application, it could be a libusb thing. Anyhow, since the value returned by this function is not used, we may as well jsut skip the hid_read() and return FME_NONE. Correct switch from BL to APP mode can be observed in /var/log/messages (linux) (when in bootloader mode the device version includes 'BL')
Definition at line 499 of file fcdhid.c.
References FCD_CMD_BL_RESET, FCD_MODE_NONE, and hid_write().
FCD_MODE_ENUM fcdBlVerifyFirmware | ( | hid_device * | phd, |
char * | pc, | ||
int64_t | n64Size | ||
) |
Verify firmware in FCd flash.
pc | Pointer to firmware data to verify against. |
n64Size | Size of the data in pc. |
This function verifies the firmware currently in the FCd flash against the firmware image pointed to by pc. The function return FCD_MODE_BL if the verification is OK and FCD_MODE_APP otherwise.
Definition at line 708 of file fcdhid.c.
References FCD_CMD_BL_GET_BYTE_ADDR_RANGE, FCD_CMD_BL_READ_FLASH_BLOCK, FCD_CMD_BL_SET_BYTE_ADDR, FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
FCD_MODE_ENUM fcdBlWriteFirmware | ( | hid_device * | phd, |
char * | pc, | ||
int64_t | n64Size | ||
) |
Write new firmware into the FCD.
pc | Pointer to the new firmware data |
n64size | The number of bytes in the data |
This function is used to upload new firmware into the FCD flash.
Definition at line 606 of file fcdhid.c.
References FCD_CMD_BL_GET_BYTE_ADDR_RANGE, FCD_CMD_BL_SET_BYTE_ADDR, FCD_CMD_BL_WRITE_FLASH_BLOCK, FCD_MODE_APP, FCD_MODE_BL, hid_read(), and hid_write().
void fcdClose | ( | hid_device * | phd | ) |
Close FCD HID device.
Definition at line 78 of file fcdhid.c.
References hid_close().
Referenced by FCDProPlusInput::closeDevice(), and FCDProInput::closeDevice().
FCD_MODE_ENUM fcdGetCaps | ( | hid_device * | phd, |
FCD_CAPS_STRUCT * | fcd_caps | ||
) |
Get hardware and firmware dependent FCD capabilities.
fcd_caps | Pointer to an FCD_CAPS_STRUCT |
This function queries the FCD and extracts the hardware and firmware dependent capabilities. Currently these capabilities are:
Ref: http://uk.groups.yahoo.com/group/FCDevelopment/message/303
Definition at line 205 of file fcdhid.c.
References FCD_CMD_BL_QUERY, FCD_MODE_APP, FCD_MODE_BL, FCD_MODE_NONE, FCD_CAPS_STRUCT::hasBiasT, FCD_CAPS_STRUCT::hasCellBlock, hid_read(), and hid_write().
FCD_MODE_ENUM fcdGetCapsStr | ( | hid_device * | phd, |
char * | caps_str | ||
) |
Get hardware and firmware dependent FCD capabilities as string.
caps_str | Pointer to a pre-allocated string buffer where the info will be copied. |
This function queries the FCD and copies the returned string into the caps_str parameter. THe return buffer must be at least 28 characters. When the FCD is in application mode, the string returned by the query command is (starting at index 2): FCDAPP 18.08 Brd 1.0 No blk 1.0 means no bias tee, 1.1 means there is a bias tee 'No blk' means it is not cellular blocked.
Ref: http://uk.groups.yahoo.com/group/FCDevelopment/message/303
Definition at line 281 of file fcdhid.c.
References FCD_CMD_BL_QUERY, FCD_MODE_APP, FCD_MODE_BL, FCD_MODE_NONE, hid_read(), and hid_write().
FCD_MODE_ENUM fcdGetFwVerStr | ( | hid_device * | phd, |
char * | str | ||
) |
Get FCD firmware version as string.
str | The returned vesion number as a 0 terminated string (must be pre-allocated) |
Definition at line 140 of file fcdhid.c.
References FCD_CMD_BL_QUERY, FCD_MODE_APP, FCD_MODE_BL, FCD_MODE_NONE, hid_read(), and hid_write().
FCD_MODE_ENUM fcdGetMode | ( | hid_device * | phd | ) |
Get FCD mode.
Definition at line 88 of file fcdhid.c.
References FCD_CMD_BL_QUERY, FCD_MODE_APP, FCD_MODE_BL, FCD_MODE_NONE, hid_read(), and hid_write().
hid_device* fcdOpen | ( | uint16_t | usVID, |
uint16_t | usPID, | ||
int | whichdongle | ||
) |
Open FCD device.
This function looks for FCD devices connected to the computer and opens the first one found.
Definition at line 31 of file fcdhid.c.
References hid_enumerate(), hid_free_enumeration(), hid_open_path(), hid_device_info::next, and hid_device_info::path.
Referenced by FCDProPlusInput::openDevice(), and FCDProInput::openDevice().