Skip to content
Snippets Groups Projects

FreeBSD PPS echo patch

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Lukas Senger
    ppsecho.patch 1.25 KiB
    --- sys/dev/ppbus/pps.c	2017-07-21 01:41:50.000000000 +0200
    +++ sys/dev/ppbus/pps.c	2018-05-18 21:43:59.705177000 +0200
    @@ -46,6 +46,7 @@ struct pps_data {
     	device_t ppbus;
     	int	busy;
     	struct callout timeout;
    +	struct callout timeout_pulse;
     	int	lastdata;
     
     	struct sx lock;
    @@ -132,6 +133,7 @@ ppsattach(device_t dev)
     
     	sx_init(&sc->lock, "pps");
     	ppb_init_callout(ppbus, &sc->timeout, 0);
    +	callout_init(&sc->timeout_pulse, 1);
     	sc->ppsdev = dev;
     	sc->ppbus = ppbus;
     	unit = device_get_unit(ppbus);
    @@ -297,6 +299,13 @@ ppshcpoll(void *arg)
     }
     
     static void
    +ppsintr_callout(void *arg)
    +{
    +	struct pps_data *sc = (struct pps_data *)arg;
    +	ppb_wctr(sc->ppbus, IRQENABLE);
    +}
    +
    +static void
     ppsintr(void *arg)
     {
     	struct pps_data *sc = (struct pps_data *)arg;
    @@ -306,11 +315,13 @@ ppsintr(void *arg)
     	if (!(ppb_rstr(sc->ppbus) & nACK))
     		return;
     
    -	if (sc->pps[0].ppsparam.mode & PPS_ECHOASSERT)
    +	if (sc->pps[0].ppsparam.mode & PPS_ECHOASSERT) {
     		ppb_wctr(sc->ppbus, IRQENABLE | AUTOFEED);
    +	}
     	pps_event(&sc->pps[0], PPS_CAPTUREASSERT);
    -	if (sc->pps[0].ppsparam.mode & PPS_ECHOASSERT)
    -		ppb_wctr(sc->ppbus, IRQENABLE);
    +	if (sc->pps[0].ppsparam.mode & PPS_ECHOASSERT) {
    +		callout_reset(&sc->timeout_pulse, hz/5, ppsintr_callout, sc);
    +	}
     }
     
     static int
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment