Commit 141664a1 authored by Lucas Russo's avatar Lucas Russo

examples/fmc130m_4ch_ctl.c: add ADC LTC2208 functions

This closes #83 github issue
parent 9bc86782
......@@ -29,6 +29,10 @@ void print_help (char *program_name)
"\t-pll_status PLL Lock status\n"
"\t-trig_dir <dir> Trigger direction\n"
"\t-clk_sel <sel = [0(FMC front panel)|1(FMC pin)]> Clock selection\n"
"\t-adc_rand <rand = [0|1]> ADC RAND\n"
"\t-adc_dith <dith = [0|1]> ADC DITH\n"
"\t-adc_shdn <shdn = [0|1]> ADC SHDN\n"
"\t-adc_pga <pga = [0|1]> ADC PGA\n"
, program_name);
}
......@@ -40,6 +44,10 @@ int main (int argc, char *argv [])
char *bpm_number_str = NULL;
char *trig_dir_str = NULL;
char *clk_sel_str = NULL;
char *adc_rand_str = NULL;
char *adc_dith_str = NULL;
char *adc_shdn_str = NULL;
char *adc_pga_str = NULL;
uint32_t get_pll_status = 0;
char **str_p = NULL;
......@@ -83,6 +91,18 @@ int main (int argc, char *argv [])
else if (streq (argv[i], "-clk_sel")) {
str_p = &clk_sel_str;
}
else if (streq (argv[i], "-adc_rand")) {
str_p = &adc_rand_str;
}
else if (streq (argv[i], "-adc_dith")) {
str_p = &adc_dith_str;
}
else if (streq (argv[i], "-adc_shdn")) {
str_p = &adc_shdn_str;
}
else if (streq (argv[i], "-adc_pga")) {
str_p = &adc_pga_str;
}
/* Fallout for options with parameters */
else {
*str_p = strdup (argv[i]);
......@@ -161,6 +181,58 @@ int main (int argc, char *argv [])
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_fmc_clk_sel was successfully executed\n");
}
uint32_t adc_rand = 0;
if (adc_rand_str != NULL) {
adc_rand = strtoul (adc_rand_str, NULL, 10);
fprintf (stdout, "[client:fmc130m_4ch]: adc_rand = %u\n", adc_rand);
err = bpm_set_adc_rand (bpm_client, service, adc_rand);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:fmc130m_4ch]: bpm_set_adc_rand failed\n");
goto err_bpm_exit;
}
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_adc_rand was successfully executed\n");
}
uint32_t adc_dith = 0;
if (adc_dith_str != NULL) {
adc_dith = strtoul (adc_dith_str, NULL, 10);
fprintf (stdout, "[client:fmc130m_4ch]: adc_dith = %u\n", adc_dith);
err = bpm_set_adc_dith (bpm_client, service, adc_dith);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:fmc130m_4ch]: bpm_set_adc_dith failed\n");
goto err_bpm_exit;
}
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_adc_dith was successfully executed\n");
}
uint32_t adc_shdn = 0;
if (adc_shdn_str != NULL) {
adc_shdn = strtoul (adc_shdn_str, NULL, 10);
fprintf (stdout, "[client:fmc130m_4ch]: adc_shdn = %u\n", adc_shdn);
err = bpm_set_adc_shdn (bpm_client, service, adc_shdn);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:fmc130m_4ch]: bpm_set_adc_shdn failed\n");
goto err_bpm_exit;
}
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_adc_shdn was successfully executed\n");
}
uint32_t adc_pga = 0;
if (adc_pga_str != NULL) {
adc_pga = strtoul (adc_pga_str, NULL, 10);
fprintf (stdout, "[client:fmc130m_4ch]: adc_pga = %u\n", adc_pga);
err = bpm_set_adc_pga (bpm_client, service, adc_pga);
if (err != BPM_CLIENT_SUCCESS){
fprintf (stderr, "[client:fmc130m_4ch]: bpm_set_adc_pga failed\n");
goto err_bpm_exit;
}
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_adc_pga was successfully executed\n");
}
if (get_pll_status) {
uint32_t pll_status = 0;
bpm_client_err_e err = bpm_get_fmc_pll_status (bpm_client, service, &pll_status);
......@@ -174,9 +246,18 @@ int main (int argc, char *argv [])
err_bpm_exit:
bpm_client_destroy (&bpm_client);
str_p = &clk_sel_str;
str_p = &adc_pga_str;
free (*str_p);
adc_pga_str = NULL;
str_p = &adc_shdn_str;
free (*str_p);
adc_shdn_str = NULL;
str_p = &adc_dith_str;
free (*str_p);
adc_dith_str = NULL;
str_p = &adc_rand_str;
free (*str_p);
clk_sel_str = NULL;
adc_rand_str = NULL;
str_p = &trig_dir_str;
free (*str_p);
trig_dir_str = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment