Commit ac0b6773 authored by Lucas Russo's avatar Lucas Russo

examples/fmc130m_4ch_ctl.c: add more ADC control options

parent 4af176e4
......@@ -28,6 +28,11 @@ void print_help (char *program_name)
"\t-b <broker_endpoint> Broker endpoint\n"
"\t-pll_status PLL Lock status\n"
"\t-trig_dir <dir> Trigger direction\n"
"\t-trig_term <term> Trigger termination\n"
"\t-adc_rand <Rand enable = [0|1]> Enable ADC Rand\n"
"\t-adc_dith <Dith enable = [0|1]> Enable ADC Dith\n"
"\t-adc_shdn <SHDN enable = [0|1]> Enable ADC SHDN\n"
"\t-adc_rand <PGA enable = [0|1]> Enable ADC PGA\n"
, program_name);
}
......@@ -39,6 +44,10 @@ int main (int argc, char *argv [])
char *bpm_number_str = NULL;
char *trig_dir_str = NULL;
char *trig_term_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;
......@@ -82,6 +91,18 @@ int main (int argc, char *argv [])
else if (streq (argv[i], "-trig_term")) {
str_p = &trig_term_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]);
......@@ -160,6 +181,58 @@ int main (int argc, char *argv [])
fprintf (stdout, "[client:fmc130m_4ch]: bpm_set_trig_term 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);
......@@ -173,6 +246,18 @@ int main (int argc, char *argv [])
err_bpm_exit:
bpm_client_destroy (&bpm_client);
str_p = &adc_rand_str;
free (*str_p);
adc_rand_str = NULL;
str_p = &adc_dith_str;
free (*str_p);
adc_dith_str = NULL;
str_p = &adc_shdn_str;
free (*str_p);
adc_shdn_str = NULL;
str_p = &adc_pga_str;
free (*str_p);
adc_pga_str = NULL;
str_p = &trig_term_str;
free (*str_p);
trig_term_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