kopia lustrzana https://github.com/cariboulabs/cariboulite
1. added channel definitions to main API
2. minor channel naming changes (enums) 3. frequency limits definitions in main APIpull/146/head
rodzic
9b008ac591
commit
70ba2bdf69
|
@ -3,7 +3,6 @@
|
|||
|
||||
static cariboulite_lib_version_st version = {0};
|
||||
static uint32_t serial_number = 0;
|
||||
static int serial_number_len = 0;
|
||||
|
||||
int main ()
|
||||
{
|
||||
|
@ -12,7 +11,7 @@ int main ()
|
|||
|
||||
printf("Version: %02d.%02d.%02d\n", version.major_version, version.minor_version, version.revision);
|
||||
|
||||
cariboulite_get_sn(&serial_number, &serial_number_len);
|
||||
serial_number = cariboulite_get_sn();
|
||||
|
||||
printf("Serial Number: %08X\n", serial_number);
|
||||
|
||||
|
|
|
@ -87,13 +87,123 @@ void cariboulite_get_lib_version(cariboulite_lib_version_st* v)
|
|||
}
|
||||
|
||||
//=============================================================================
|
||||
int cariboulite_get_sn(uint32_t* serial_number, int *count)
|
||||
unsigned int cariboulite_get_sn()
|
||||
{
|
||||
return cariboulite_get_serial_number(&sys, serial_number, count);
|
||||
uint32_t sn = 0;
|
||||
int count = 0;
|
||||
cariboulite_get_serial_number(&sys, &sn, &count);
|
||||
return sn;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
cariboulite_radio_state_st* cariboulite_get_radio(cariboulite_channel_en type)
|
||||
cariboulite_radio_state_st* cariboulite_get_radio(cariboulite_channel_en ch)
|
||||
{
|
||||
return cariboulite_get_radio_handle(&sys, type);
|
||||
return cariboulite_get_radio_handle(&sys, ch);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
cariboulite_version_en cariboulite_get_version()
|
||||
{
|
||||
system_type_en type = cariboulite_get_system_type(&sys);
|
||||
switch(type)
|
||||
{
|
||||
case cariboulite_full: return cariboulite_full; break;
|
||||
case cariboulite_ism: return cariboulite_ism; break;
|
||||
case system_type_unknown:
|
||||
default: return cariboulite_unknown; break;
|
||||
}
|
||||
return cariboulite_unknown;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
bool cariboulite_frequency_available(cariboulite_channel_en ch, float freq_hz)
|
||||
{
|
||||
if (ch == cariboulite_channel_s1g)
|
||||
{
|
||||
return (freq_hz >= CARIBOULITE_S1G_MIN1 && freq_hz <= CARIBOULITE_S1G_MAX1 ||
|
||||
freq_hz >= CARIBOULITE_S1G_MIN2 && freq_hz <= CARIBOULITE_S1G_MAX2);
|
||||
}
|
||||
else if (ch == cariboulite_channel_hif)
|
||||
{
|
||||
cariboulite_version_en ver = cariboulite_get_version();
|
||||
if (ver == cariboulite_full)
|
||||
{
|
||||
return (freq_hz >= CARIBOULITE_6G_MIN && freq_hz <= CARIBOULITE_6G_MAX);
|
||||
}
|
||||
else if (ver == cariboulite_ism)
|
||||
{
|
||||
return (freq_hz >= CARIBOULITE_2G4_MIN && freq_hz <= CARIBOULITE_2G4_MAX);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
int cariboulite_get_num_frequency_ranges(cariboulite_channel_en ch)
|
||||
{
|
||||
if (ch == cariboulite_channel_s1g) return 2;
|
||||
else if (ch == cariboulite_channel_hif) return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
int cariboulite_get_frequency_limits(cariboulite_channel_en ch, float *freq_low, float *freq_hi, int* num_ranges)
|
||||
{
|
||||
if (ch == cariboulite_channel_s1g)
|
||||
{
|
||||
freq_low[0] = CARIBOULITE_S1G_MIN1;
|
||||
freq_hi[0] = CARIBOULITE_S1G_MAX1;
|
||||
freq_low[1] = CARIBOULITE_S1G_MIN2;
|
||||
freq_hi[1] = CARIBOULITE_S1G_MAX2;
|
||||
if (num_ranges) *num_ranges = 2;
|
||||
}
|
||||
else if (ch == cariboulite_channel_hif)
|
||||
{
|
||||
cariboulite_version_en ver = cariboulite_get_version();
|
||||
if (ver == cariboulite_full)
|
||||
{
|
||||
freq_low[0] = CARIBOULITE_6G_MIN;
|
||||
freq_hi[0] = CARIBOULITE_6G_MAX;
|
||||
}
|
||||
else if (ver == cariboulite_ism)
|
||||
{
|
||||
freq_low[0] = CARIBOULITE_2G4_MIN;
|
||||
freq_hi[0] = CARIBOULITE_2G4_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
int cariboulite_get_channel_name(cariboulite_channel_en ch, char* name, size_t max_len)
|
||||
{
|
||||
if (ch == cariboulite_channel_s1g)
|
||||
{
|
||||
snprintf(name, max_len-1, "CaribouLite S1G");
|
||||
return 0;
|
||||
}
|
||||
else if (ch == cariboulite_channel_hif)
|
||||
{
|
||||
cariboulite_version_en ver = cariboulite_get_version();
|
||||
if (ver == cariboulite_full)
|
||||
{
|
||||
snprintf(name, max_len-1, "CaribouLite 6GHz");
|
||||
return 0;
|
||||
}
|
||||
else if (ver == cariboulite_ism)
|
||||
{
|
||||
snprintf(name, max_len-1, "CaribouLite 2.4GHz");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
|
@ -37,6 +37,16 @@ typedef enum
|
|||
cariboulite_log_level_none, /**< none - errors only*/
|
||||
} cariboulite_log_level_en;
|
||||
|
||||
/**
|
||||
* @brief System Type (version)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
cariboulite_unknown = 0,
|
||||
cariboulite_full = 1,
|
||||
cariboulite_ism = 2,
|
||||
} cariboulite_version_en;
|
||||
|
||||
/**
|
||||
* @brief custom signal handler
|
||||
*/
|
||||
|
@ -111,15 +121,9 @@ void cariboulite_get_lib_version(cariboulite_lib_version_st* v);
|
|||
/**
|
||||
* @brief Get board serial number
|
||||
*
|
||||
* Note - this 32bit serial number is a digest value of the UUID 128 bit that
|
||||
* is automatically generated for each board. It is basically the result of
|
||||
* "xor" operations on the UUID's parts.
|
||||
*
|
||||
* @param serial_number a 32bit storage to store the serial number (can be NULL - if not needed)
|
||||
* @param count the number of 32bit variables returned - always returns "1".
|
||||
* @return always 0
|
||||
* @return board serial number (32 bit)
|
||||
*/
|
||||
int cariboulite_get_sn(uint32_t* serial_number, int *count);
|
||||
unsigned int cariboulite_get_sn();
|
||||
|
||||
/**
|
||||
* @brief Getting the used radio handle
|
||||
|
@ -132,7 +136,64 @@ int cariboulite_get_sn(uint32_t* serial_number, int *count);
|
|||
* @param type the radio channel (6G/2.4G or ISM)
|
||||
* @return 0 (sucess), -1 (fail)
|
||||
*/
|
||||
cariboulite_radio_state_st* cariboulite_get_radio(cariboulite_channel_en type);
|
||||
cariboulite_radio_state_st* cariboulite_get_radio(cariboulite_channel_en ch);
|
||||
|
||||
/**
|
||||
* @brief Getting CaribouLite version
|
||||
*
|
||||
* Returns the version of the hardware - ISM / 6G / Unknown
|
||||
* ISM has two channels - 900MHz and 2.4 GHz
|
||||
* 6G has two channels - 900MHz and 30-6000MHz
|
||||
*
|
||||
* @return according to cariboulite_version_en
|
||||
*/
|
||||
cariboulite_version_en cariboulite_get_version(void);
|
||||
|
||||
/**
|
||||
* @brief Getting frequency availability
|
||||
*
|
||||
* Given a certain frequency (in Hz) checking if that frequency is available in the
|
||||
* connected hardware
|
||||
*
|
||||
* @return true / false
|
||||
*/
|
||||
bool cariboulite_frequency_available(cariboulite_channel_en ch, float freq_hz);
|
||||
|
||||
/**
|
||||
* @brief Getting the number frequency ranges
|
||||
*
|
||||
* Each channel has its frequency capabilities. in the ISM channel there are 2
|
||||
* ranges, while in the HiF there is a single range. This function returns the number
|
||||
* of available ranges. To get the actual limits use 'cariboulite_get_frequency_limits'
|
||||
*
|
||||
* @return number of ranges or -1 if the channel doesn't exist
|
||||
*/
|
||||
int cariboulite_get_num_frequency_ranges(cariboulite_channel_en ch);
|
||||
|
||||
/**
|
||||
* @brief Getting frequency ranges limits
|
||||
*
|
||||
* freq_low and freq_hi need to be pre-allocated according to 'cariboulite_get_num_frequency_ranges'
|
||||
* then all the minimum values will be in the freq_low list and the corresponding max values will be in
|
||||
* freq_hi.
|
||||
* num_ranges returns the number of written ranges
|
||||
*
|
||||
* @return 0 for success or -1 if channel is wrong
|
||||
*/
|
||||
int cariboulite_get_frequency_limits(cariboulite_channel_en ch, float *freq_low, float *freq_hi, int* num_ranges);
|
||||
|
||||
/**
|
||||
* @brief Get channel name
|
||||
*
|
||||
* Returns the string name of a channel
|
||||
*
|
||||
* @param ch the chosen channel
|
||||
* @param name a pre-allocated char array
|
||||
* @param max_len the size of the pre-allocated char array
|
||||
* @return 0 (success) or -1 (failed - when channel is incorrect)
|
||||
*/
|
||||
int cariboulite_radio_get_channel_name(cariboulite_channel_en ch, char* name, size_t max_len);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -54,7 +54,7 @@ int cariboulite_radio_dispose(cariboulite_radio_state_st* radio)
|
|||
radio->state = cariboulite_radio_state_cmd_trx_off;
|
||||
|
||||
// Type specific
|
||||
if (radio->type == cariboulite_channel_6g)
|
||||
if (radio->type == cariboulite_channel_hif)
|
||||
{
|
||||
caribou_fpga_set_io_ctrl_mode (&radio->sys->fpga, 0, caribou_fpga_io_ctrl_rfm_low_power);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ int cariboulite_radio_set_tx_power(cariboulite_radio_state_st* radio, int tx_pow
|
|||
if (tx_power_ctrl < 0) tx_power_ctrl = 0;
|
||||
if (tx_power_ctrl > 31) tx_power_ctrl = 31;
|
||||
}
|
||||
else if (radio->type == cariboulite_channel_6g)
|
||||
else if (radio->type == cariboulite_channel_hif)
|
||||
{
|
||||
if (tx_power_dbm < -12) tx_power_dbm = -12;
|
||||
if (tx_power_dbm > 12) tx_power_dbm = 12;
|
||||
|
@ -337,7 +337,7 @@ int cariboulite_radio_get_tx_power(cariboulite_radio_state_st* radio, int *tx_po
|
|||
{
|
||||
actual_model = -0.000546f*x*x*x + 0.014352f*x*x + 0.902754f*x - 13.954753f;
|
||||
}
|
||||
else if (radio->type == cariboulite_channel_6g)
|
||||
else if (radio->type == cariboulite_channel_hif)
|
||||
{
|
||||
actual_model = 0.000031f*x*x*x*x - 0.002344f*x*x*x + 0.040478f*x*x + 0.712209f*x - 11.168502;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ bool cariboulite_radio_wait_mixer_lock(cariboulite_radio_state_st* radio, int re
|
|||
}
|
||||
|
||||
// applicable only to the 6G channel
|
||||
if (radio->type != cariboulite_channel_6g)
|
||||
if (radio->type != cariboulite_channel_hif)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ bool cariboulite_radio_wait_modem_lock(cariboulite_radio_state_st* radio, int re
|
|||
bool cariboulite_radio_wait_for_lock( cariboulite_radio_state_st* radio, bool *mod, bool *mix, int retries)
|
||||
{
|
||||
bool mix_lock = true, mod_lock = true;
|
||||
if (radio->type == cariboulite_channel_6g && mix != NULL)
|
||||
if (radio->type == cariboulite_channel_hif && mix != NULL)
|
||||
{
|
||||
mix_lock = cariboulite_radio_wait_mixer_lock(radio, retries);
|
||||
*mix = mix_lock;
|
||||
|
@ -685,7 +685,7 @@ int cariboulite_radio_set_frequency(cariboulite_radio_state_st* radio,
|
|||
//--------------------------------------------------------------------------------
|
||||
// ISM 2.4 GHZ CONFIGURATION
|
||||
//--------------------------------------------------------------------------------
|
||||
else if (radio->type == cariboulite_channel_6g &&
|
||||
else if (radio->type == cariboulite_channel_hif &&
|
||||
radio->sys->board_info.numeric_product_id == system_type_cariboulite_ism)
|
||||
{
|
||||
if (FREQ_IN_ISM_24G_RANGE(f_rf))
|
||||
|
@ -716,7 +716,7 @@ int cariboulite_radio_set_frequency(cariboulite_radio_state_st* radio,
|
|||
//--------------------------------------------------------------------------------
|
||||
// FULL 30-6GHz CONFIGURATION
|
||||
//--------------------------------------------------------------------------------
|
||||
else if (radio->type == cariboulite_channel_6g &&
|
||||
else if (radio->type == cariboulite_channel_hif &&
|
||||
radio->sys->board_info.numeric_product_id == system_type_cariboulite_full)
|
||||
{
|
||||
// Changing the frequency may sometimes need to break RX / TX
|
||||
|
@ -971,7 +971,7 @@ int cariboulite_radio_activate_channel(cariboulite_radio_state_st* radio,
|
|||
// if its an LO frequency output from the mixer - no need for modem output
|
||||
// LO applicable only to the channel with the mixer
|
||||
if (radio->lo_output &&
|
||||
radio->type == cariboulite_channel_6g &&
|
||||
radio->type == cariboulite_channel_hif &&
|
||||
radio->sys->board_info.numeric_product_id == system_type_cariboulite_full)
|
||||
{
|
||||
// here we need to configure lo bypass on the mixer
|
||||
|
@ -1025,7 +1025,7 @@ int cariboulite_radio_activate_channel(cariboulite_radio_state_st* radio,
|
|||
//=========================================================================
|
||||
int cariboulite_radio_set_cw_outputs(cariboulite_radio_state_st* radio, bool lo_out, bool cw_out)
|
||||
{
|
||||
if (radio->lo_output && radio->type == cariboulite_channel_6g)
|
||||
if (radio->lo_output && radio->type == cariboulite_channel_hif)
|
||||
{
|
||||
radio->lo_output = lo_out;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef enum
|
|||
typedef enum
|
||||
{
|
||||
cariboulite_channel_s1g = 0,
|
||||
cariboulite_channel_6g = 1,
|
||||
cariboulite_channel_hif = 1,
|
||||
} cariboulite_channel_en;
|
||||
|
||||
typedef enum
|
||||
|
@ -621,6 +621,7 @@ int cariboulite_radio_write_samples(cariboulite_radio_state_st* radio,
|
|||
*/
|
||||
size_t cariboulite_radio_get_native_mtu_size_samples(cariboulite_radio_state_st* radio);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -389,7 +389,7 @@ int cariboulite_init_submodules (sys_st* sys)
|
|||
|
||||
// Initialize the two Radio High-Level devices
|
||||
cariboulite_radio_init(&sys->radio_low, sys, cariboulite_channel_s1g);
|
||||
cariboulite_radio_init(&sys->radio_high, sys, cariboulite_channel_6g);
|
||||
cariboulite_radio_init(&sys->radio_high, sys, cariboulite_channel_hif);
|
||||
|
||||
cariboulite_radio_set_rx_samp_cutoff(&sys->radio_low, cariboulite_radio_rx_sample_rate_4000khz, cariboulite_radio_rx_f_cut_half_fs);
|
||||
cariboulite_radio_set_tx_samp_cutoff(&sys->radio_low, cariboulite_radio_rx_sample_rate_4000khz, cariboulite_radio_rx_f_cut_half_fs);
|
||||
|
@ -415,6 +415,12 @@ cariboulite_init_submodules_fail:
|
|||
return -1;
|
||||
}
|
||||
|
||||
//=======================================================================================
|
||||
system_type_en cariboulite_get_system_type(sys_st* sys)
|
||||
{
|
||||
return sys->board_info.numeric_product_id;
|
||||
}
|
||||
|
||||
//=======================================================================================
|
||||
int cariboulite_release_submodules(sys_st* sys)
|
||||
{
|
||||
|
@ -545,7 +551,7 @@ int cariboulite_init_system_production(sys_st *sys)
|
|||
|
||||
// Initialize the two Radio High-Level devices
|
||||
cariboulite_radio_init(&sys->radio_low, sys, cariboulite_channel_s1g);
|
||||
cariboulite_radio_init(&sys->radio_high, sys, cariboulite_channel_6g);
|
||||
cariboulite_radio_init(&sys->radio_high, sys, cariboulite_channel_hif);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -259,6 +259,19 @@ int cariboulite_self_test(sys_st* sys, cariboulite_self_test_result_st* res);
|
|||
* @return 0 (sucess), -1 (fail)
|
||||
*/
|
||||
cariboulite_radio_state_st* cariboulite_get_radio_handle(sys_st* sys, cariboulite_channel_en type);
|
||||
|
||||
/**
|
||||
* @brief Getting CaribouLite Type
|
||||
*
|
||||
* Returns the version of the hardware - ISM / 6G / Unknown
|
||||
* ISM has two channels - 900MHz and 2.4 GHz
|
||||
* 6G has two channels - 900MHz and 6000MHz
|
||||
*
|
||||
* @return according to cariboulite_version_en
|
||||
*/
|
||||
system_type_en cariboulite_get_system_type(sys_st* sys);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -77,7 +77,7 @@ std::vector<std::string> Cariboulite::listAntennas( const int direction, const s
|
|||
//printf("listAntennas dir: %d, channel: %ld\n", direction, channel);
|
||||
std::vector<std::string> options;
|
||||
if (radio->type == cariboulite_channel_s1g) options.push_back( "TX/RX Sub1GHz" );
|
||||
else if (radio->type == cariboulite_channel_6g) options.push_back( "TX/RX 6GHz" );
|
||||
else if (radio->type == cariboulite_channel_hif) options.push_back( "TX/RX 6GHz" );
|
||||
|
||||
return(options);
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ std::string Cariboulite::getAntenna( const int direction, const size_t channel )
|
|||
{
|
||||
//printf("getAntenna dir: %d, channel: %ld\n", direction, channel);
|
||||
if (radio->type == cariboulite_channel_s1g) return "TX/RX Sub1GHz";
|
||||
else if (radio->type == cariboulite_channel_6g) return "TX/RX 6GHz";
|
||||
else if (radio->type == cariboulite_channel_hif) return "TX/RX 6GHz";
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -537,7 +537,7 @@ SoapySDR::RangeList Cariboulite::getFrequencyRange( const int direction, const s
|
|||
list.push_back(SoapySDR::Range( 779e6, 1020e6 ));
|
||||
return list;
|
||||
}
|
||||
else if (radio->type == cariboulite_channel_6g)
|
||||
else if (radio->type == cariboulite_channel_hif)
|
||||
{
|
||||
return (SoapySDR::RangeList( 1, SoapySDR::Range( 1e6, 6000e6 ) ) );
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ std::vector<std::string> Cariboulite::listSensors(const int direction, const siz
|
|||
if (direction == SOAPY_SDR_RX) lst.push_back( "RSSI" );
|
||||
if (direction == SOAPY_SDR_RX) lst.push_back( "ENERGY" );
|
||||
lst.push_back( "PLL_LOCK_MODEM" );
|
||||
if (channel == cariboulite_channel_6g)
|
||||
if (channel == cariboulite_channel_hif)
|
||||
{
|
||||
lst.push_back( "PLL_LOCK_MIXER" );
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ SoapySDR::ArgInfo Cariboulite::getSensorInfo(const int direction, const size_t c
|
|||
return info;
|
||||
}
|
||||
|
||||
if (channel == cariboulite_channel_6g && key == "PLL_LOCK_MIXER")
|
||||
if (channel == cariboulite_channel_hif && key == "PLL_LOCK_MIXER")
|
||||
{
|
||||
info.name = "PLL Lock Mixer";
|
||||
info.key = "PLL_MIXER";
|
||||
|
@ -93,7 +93,7 @@ Type Cariboulite::readSensor(const int direction, const size_t channel, const st
|
|||
return radio->modem_pll_locked;
|
||||
}
|
||||
|
||||
if (channel == cariboulite_channel_6g && key == "PLL_LOCK_MIXER")
|
||||
if (channel == cariboulite_channel_hif && key == "PLL_LOCK_MIXER")
|
||||
{
|
||||
return radio->lo_pll_locked;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue