Commit 6c9c3cd6 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/tools: add read parameter to wrs_pps_control pps

Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent aca42742
......@@ -9,6 +9,9 @@
#define PPSG_ADJUST_SEC 0x1
#define PPSG_ADJUST_NSEC 0x2
#define PPSG_PPS_OUT_ENABLE 0x1
#define PPSG_PPS_OUT_DISABLE 0x0
#define PPSG_PPS_IN_TERM_50OHM_ENABLE 0x1
#define PPSG_PPS_IN_TERM_50OHM_DISABLE 0x0
......@@ -24,6 +27,9 @@ int shw_pps_gen_busy(void);
/* Enables/disables PPS Generator PPS output */
int shw_pps_gen_enable_output(int enable);
/* Reads PPS Generator PPS output */
int shw_pps_gen_enable_output_read(void);
/* Reads the current time and stores at <seconds,nanoseconds>. */
void shw_pps_gen_read_time(uint64_t * seconds, uint32_t * nanoseconds);
......
......@@ -86,6 +86,15 @@ int shw_pps_gen_enable_output(int enable)
return 0;
}
/* Enables/disables PPS output */
int shw_pps_gen_enable_output_read(void)
{
uint32_t escr = ppsg_read(ESCR);
return escr & PPSG_ESCR_PPS_VALID ?
PPSG_PPS_OUT_ENABLE : PPSG_PPS_OUT_DISABLE;
}
void shw_pps_gen_read_time(uint64_t * seconds, uint32_t * nanoseconds)
{
uint32_t ns_cnt;
......
......@@ -6,9 +6,6 @@
#include <libwr/switch_hw.h>
#include <libwr/pps_gen.h>
#define PPS_ON 1
#define PPS_OFF 0
void help(char *prgname)
{
fprintf(stderr, "%s: Use: \"%s [<options>] <cmd>\n",
......@@ -18,7 +15,7 @@ void help(char *prgname)
" -h print help\n"
"\n"
" Commands are:\n"
" pps <on|off> - switch PPS output on/off.\n"
" pps <on|off|read> - switch PPS output on/off.\n"
" 50ohm-term-in <on|off|read> - on/off/read 50ohm termination for 1-PPS input\n");
exit(1);
}
......@@ -43,11 +40,20 @@ int main(int argc, char *argv[])
}
if (!strcmp(argv[2], "on")) {
assert_init(shw_fpga_mmap_init());
shw_pps_gen_enable_output(PPS_ON);
shw_pps_gen_enable_output(PPSG_PPS_OUT_ENABLE);
exit(0);
} else if (!strcmp(argv[2], "off")) {
assert_init(shw_fpga_mmap_init());
shw_pps_gen_enable_output(PPS_OFF);
shw_pps_gen_enable_output(PPSG_PPS_OUT_DISABLE);
exit(0);
} else if (!strcmp(argv[2], "read")) {
assert_init(shw_fpga_mmap_init());
if (shw_pps_gen_enable_output_read()
== PPSG_PPS_OUT_ENABLE) {
printf("PPS output on\n;");
} else {
printf("PPS output off\n;");
}
exit(0);
} else {
printf("Unknown parameter\n;");
......
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