From: Pavel Pisa Date: Tue, 17 Mar 2015 19:08:08 +0000 (+0100) Subject: RoCoN: add test commands to calibrate offsets of current ADCs. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/fpga/lx-cpu1/lx-rocon.git/commitdiff_plain/bc90b7da87c2888bcaeae98b1b7ff99df156e0c8 RoCoN: add test commands to calibrate offsets of current ADCs. Signed-off-by: Pavel Pisa --- diff --git a/sw/app/rocon/appl_tests.c b/sw/app/rocon/appl_tests.c index ed8df1a..42b0334 100644 --- a/sw/app/rocon/appl_tests.c +++ b/sw/app/rocon/appl_tests.c @@ -556,6 +556,12 @@ int cmd_do_testcuradc(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[] if (si_ulong(&ps, &pwm_chan_b, 0) < 0) return -CMDERR_BADPAR; + if (pwm_chan_a >= PXMCC_CURADC_CHANNELS) + return -CMDERR_BADPAR; + + if (pwm_chan_b >= PXMCC_CURADC_CHANNELS) + return -CMDERR_BADPAR; + si_skspace(&ps); if (*ps) { if (si_ulong(&ps, &pwm_b, 0) < 0) @@ -592,6 +598,34 @@ int cmd_do_testcuradc(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[] return 0; } +int cmd_do_curadc(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]) +{ + int chan; + volatile pxmcc_data_t *mcc_data = pxmc_rocon_mcc_data(); + volatile pxmcc_curadc_data_t *curadc; + int subcmd = (int)des->info[0]; + + for (chan = 0; chan < PXMCC_CURADC_CHANNELS; chan++) { + curadc = mcc_data->curadc + chan; + switch (subcmd) { + case 0: + printf("%s%ld", chan?",":"", (long)curadc->cur_val); + break; + case 1: + printf("%s%ld", chan?",":"", (long)curadc->siroladc_offs); + break; + case 2: + curadc->siroladc_offs += curadc->cur_val; + break; + } + } + + if (subcmd < 2) + printf("\n"); + + return 0; +} + cmd_des_t const cmd_des_test_memusage = {0, 0, "memusage", "report memory usage", cmd_do_test_memusage, { @@ -679,6 +713,21 @@ cmd_des_t const cmd_des_testcuradc = {0, 0, cmd_do_testcuradc, {(void *)0} }; +cmd_des_t const cmd_des_showcuradc = {0, 0, + "showcuradc", "print current ADC offsets", + cmd_do_curadc, {(void *)0} + }; + +cmd_des_t const cmd_des_showcuradcoffs = {0, 0, + "showcuradcoffs", "print current ADC offsets", + cmd_do_curadc, {(void *)1} + }; + +cmd_des_t const cmd_des_calcuradcoffs = {0, 0, + "calcuradcoffs", "calibrate current ADC offsets", + cmd_do_curadc, {(void *)2} + }; + cmd_des_t const *const cmd_appl_tests[] = { &cmd_des_test_memusage, @@ -699,5 +748,8 @@ cmd_des_t const *const cmd_appl_tests[] = &cmd_des_testtumblefw, &cmd_des_testtumblebus, &cmd_des_testcuradc, + &cmd_des_showcuradc, + &cmd_des_showcuradcoffs, + &cmd_des_calcuradcoffs, NULL };