From dd3ae945b5a538870c2dbe733b5b91b26f6b1b06 Mon Sep 17 00:00:00 2001
From: Alessandro Rubini <rubini@gnudd.com>
Date: Wed, 16 Oct 2013 13:52:51 +0200
Subject: [PATCH] softpll: run the PPS pulse as 10ms wide

This is a bigger change than expected, as the width was defined
in two places. So I moved the definition in <wrc.h>, whence everybody
picks it.

Signed-off-by: Alessandro Rubini <rubini@gnudd.com>
---
 dev/pps_gen.c        | 4 ----
 include/wrc.h        | 3 +++
 softpll/softpll_ng.c | 2 +-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/dev/pps_gen.c b/dev/pps_gen.c
index a20850d..5bc2bb8 100644
--- a/dev/pps_gen.c
+++ b/dev/pps_gen.c
@@ -19,10 +19,6 @@
 /* Warning: references to "UTC" in the registers DO NOT MEAN actual UTC time, it's just a plain second counter
 	 It doesn't care about leap seconds. */
 
-/* Default width (in 8ns units) of the pulses on the PPS output */
-
-#define PPS_WIDTH 100000
-
 #define ppsg_write(reg, val) \
 	*(volatile uint32_t *) (BASE_PPS_GEN + (offsetof(struct PPSG_WB, reg))) = (val)
 
diff --git a/include/wrc.h b/include/wrc.h
index ffaebbd..b33074b 100644
--- a/include/wrc.h
+++ b/include/wrc.h
@@ -24,6 +24,9 @@ void shell_init(void);
 int wrc_log_stats(uint8_t onetime);
 void wrc_debug_printf(int subsys, const char *fmt, ...);
 
+/* Default width (in 8ns units) of the pulses on the PPS output */
+#define PPS_WIDTH (10 * 1000 * 1000 / 8) /* 10ms */
+
 
 /* This is in the library, somewhere */
 extern int abs(int val);
diff --git a/softpll/softpll_ng.c b/softpll/softpll_ng.c
index 77ee4de..1928850 100644
--- a/softpll/softpll_ng.c
+++ b/softpll/softpll_ng.c
@@ -323,7 +323,7 @@ void spll_init(int mode, int slave_ref_channel, int align_pps)
 	SPLL->DEGLITCH_THR = 1000;
 
 	PPSG->ESCR = 0;
-	PPSG->CR = PPSG_CR_CNT_EN | PPSG_CR_CNT_RST | PPSG_CR_PWIDTH_W(100);
+	PPSG->CR = PPSG_CR_CNT_EN | PPSG_CR_CNT_RST | PPSG_CR_PWIDTH_W(PPS_WIDTH);
 
 	if(mode == SPLL_MODE_GRAND_MASTER)
 	{
-- 
GitLab