Commit fda53d29 authored by Grzegorz Daniluk's avatar Grzegorz Daniluk

Merge branch 'adam-rubi-170612' into proposed_master

parents 7d366a33 4cd129da
......@@ -151,6 +151,18 @@ config SYSLOG
The user (or init script) must use "syslog <ipaddr> <macaddr>"
to enable it. The special "off" ipaddr disables syslog.
config PUTS_SYSLOG
depends on SYSLOG
boolean "Sent puts (i.e. printf) to syslog too"
help
This allows logging the various warning and error messages
that normally go to the console alone, where nobody is looking
in a deployed system. Output from interactive commands is
not sent to syslog, but self-timed diagnostic (stat, gui, verbose)
will reach syslog anyways, if an interactive user enables them.
Unfortunately, "stat" will reach syslog as several short strings,
and "gui" is full of escape sequences.
config SNMP
depends on IP && !HOST_PROCESS
default y
......@@ -349,6 +361,14 @@ config CMD_LL
on the master, because they are just sent to the slave
during the initial handshake
config DAC_LOG
depends on DEVELOPER && EMBEDDED_NODE
bool "Be able send DAC values through UDP"
help
If you want to see the dac output, input to the VCXO main
oscillator, enable this. You'll have a "daclog" shell command
to set ipaddress and mac of the target host. UDP port is 1050.
config FLASH_INIT
depends on DEVELOPER && LM32
default y
......
#include <wrc.h>
#include <wrpc.h>
#include <string.h>
#include <shell.h>
#include <lib/ipv4.h>
/* a tx-only socket: no queue is there */
static struct wrpc_socket __static_daclog_socket = {
.queue.buff = NULL,
.queue.size = 0,
};
static struct wrpc_socket *daclog_socket;
static struct wr_udp_addr daclog_addr;
unsigned char daclog_mac[6];
/* alternate between two buffers */
#define BSIZE 512
struct daclog_buf {
unsigned char hdr[UDP_END];
uint16_t data[BSIZE];
};
static struct daclog_buf buffers[2];
static int ready[2];
void spll_log_dac(int y);
void spll_log_dac(int y)
{
static int bindex, bcount;
buffers[bindex].data[bcount++] = y;
if (bcount == BSIZE) {
ready[bindex] = 1;
bindex = !bindex;
bcount = 0;
}
}
static void daclog_init(void)
{
daclog_socket = ptpd_netif_create_socket(&__static_daclog_socket, NULL,
PTPD_SOCK_UDP, 1050);
daclog_addr.sport = daclog_addr.dport = htons(1050);
}
static int configured;
static int daclog_poll(void)
{
struct wr_sockaddr addr;
int len = sizeof(struct daclog_buf);
struct daclog_buf *b = NULL;
if (!configured)
return 0;
if (ready[0]) {
b = buffers + 0;
ready[0] = 0;
} else if (ready[1]) {
b = buffers + 1;
ready[1] = 0;
}
if (!b)
return 0;
/* format and send */
getIP((void *)&daclog_addr.saddr); /* if we have no ip yet, 0 is ok */
fill_udp((void *)b, len, &daclog_addr);
memcpy(&addr.mac, daclog_mac, 6);
ptpd_netif_sendto(daclog_socket, &addr, b, len, 0);
return 1;
}
DEFINE_WRC_TASK(daclog) = {
.name = "daclog",
.init = daclog_init,
.job = daclog_poll,
};
static int cmd_daclog(const char *args[])
{
char b1[32], b2[32];
if (args[0] && !strcmp(args[0], "off")) {
configured = 0;
return 0;
}
if (!args[1]) {
pp_printf("use: daclog <ipaddr> <macaddr> (or just \"off\"\n");
return -1;
}
decode_ip(args[0], (void *)&daclog_addr.daddr);
decode_mac(args[1], daclog_mac);
pp_printf("Dac logger parameters: %s, %s, port 1050\n",
format_ip(b1, (void *)&daclog_addr.daddr),
format_mac(b2, daclog_mac));
configured = 1;
ready[0] = ready[1] = 0; /* try to ensure data ordering */
return 0;
}
DEFINE_WRC_COMMAND(daclog) = {
.name = "daclog",
.exec = cmd_daclog,
};
......@@ -19,10 +19,12 @@ obj-$(CONFIG_WR_NODE) += \
dev/pps_gen.o
obj-$(CONFIG_WR_SWITCH) += dev/timer-wrs.o dev/ad9516.o
obj-$(CONFIG_PUTS_SYSLOG) += dev/puts-syslog.o
obj-$(CONFIG_LEGACY_EEPROM) += dev/eeprom.o
obj-$(CONFIG_SDB_STORAGE) += dev/sdb-storage.o
obj-$(CONFIG_DAC_LOG) += dev/dac_log.o
obj-$(CONFIG_W1) += dev/w1.o dev/w1-hw.o dev/w1-shell.o
obj-$(CONFIG_W1) += dev/w1-temp.o dev/w1-eeprom.o
obj-$(CONFIG_W1) += dev/temp-w1.o
......
......@@ -31,8 +31,6 @@
#define RX_OOB_SIZE 3 /* as the number of FIFO data words */
#define ETH_HEADER_SIZE 14
// extracts the values of TS rising and falling edge counters from the descriptor header
#define EXPLODE_WR_TIMESTAMP(raw, rc, fc) \
......
#include <wrc.h>
#include <string.h>
#include <uart.h>
#include <shell.h>
#include <lib/ipv4.h>
int puts(const char *s)
{
char new_s[CONFIG_PRINT_BUFSIZE + 4];
int l, ret;
ret = uart_write_string(s);
l = strlen(s);
/* avoid shell-interation stuff */
if (shell_is_interacting)
return ret;
if (l < 2 || s[0] == '\e')
return ret;
if (!strncmp(s, "wrc#", 4))
return ret;
/* if not terminating with newline, add a trailing "...\n" */
strcpy(new_s, s);
if (s[l-1] != '\n') {
new_s[l++] = '.';
new_s[l++] = '.';
new_s[l++] = '.';
new_s[l++] = '\n';
new_s[l++] = '\0';
}
syslog_report(new_s);
return ret;
}
......@@ -26,12 +26,12 @@ int32_t sfp_in_db = 0;
char sfp_pn[SFP_PN_LEN];
int sfp_present(void)
static int sfp_present(void)
{
return !gpio_in(GPIO_SFP_DET);
}
int sfp_read_part_id(char *part_id)
static int sfp_read_part_id(char *part_id)
{
int i;
uint8_t data, sum;
......
......@@ -56,4 +56,4 @@ int uart_read_byte(void)
}
int puts(const char *s)
__attribute__((alias("uart_write_string")));
__attribute__((weak,alias("uart_write_string")));
......@@ -196,7 +196,6 @@ struct dump_info dump_info[] = {
DUMP_FIELD(int, mode),
DUMP_FIELD(int, seq_state),
DUMP_FIELD(int, dac_timeout),
DUMP_FIELD(int, default_dac_main),
DUMP_FIELD(int, delock_count),
DUMP_FIELD(uint32_t, irq_count),
DUMP_FIELD(int, mpll_shift_ps),
......@@ -205,7 +204,6 @@ struct dump_info dump_info[] = {
DUMP_FIELD(int, helper.tag_d0),
DUMP_FIELD(int, helper.ref_src),
DUMP_FIELD(int, helper.sample_n),
DUMP_FIELD(int, helper.delock_count),
/* FIXME: missing helper.pi etc.. */
DUMP_FIELD(int, ext.enabled),
DUMP_FIELD(int, ext.align_state),
......@@ -221,16 +219,11 @@ struct dump_info dump_info[] = {
DUMP_FIELD(int, mpll.tag_out),
DUMP_FIELD(int, mpll.tag_ref_d),
DUMP_FIELD(int, mpll.tag_out_d),
DUMP_FIELD(uint32_t, mpll.seq_ref),
DUMP_FIELD(int, mpll.seq_out),
DUMP_FIELD(int, mpll.match_state),
DUMP_FIELD(int, mpll.match_seq),
DUMP_FIELD(int, mpll.phase_shift_target),
DUMP_FIELD(int, mpll.phase_shift_current),
DUMP_FIELD(int, mpll.id_ref),
DUMP_FIELD(int, mpll.id_out),
DUMP_FIELD(int, mpll.sample_n),
DUMP_FIELD(int, mpll.delock_count),
DUMP_FIELD(int, mpll.dac_index),
DUMP_FIELD(int, mpll.enabled),
......
......@@ -6,9 +6,6 @@
#ifndef __ENDPOINT_H
#define __ENDPOINT_H
#define DMTD_AVG_SAMPLES 256
#define DMTD_MAX_PHASE 16384
#include <stdint.h>
typedef enum {
......
......@@ -11,7 +11,7 @@
/* Please increment WRPC_SHMEM_VERSION if you change any exported data
* structure */
#define WRPC_SHMEM_VERSION 1 /* first version */
#define WRPC_SHMEM_VERSION 2 /* removed some unused fields */
#ifndef __ASSEMBLY__
extern const char *build_revision;
......
......@@ -23,12 +23,6 @@ extern int32_t sfp_alpha;
extern int32_t sfp_deltaTx;
extern int32_t sfp_deltaRx;
/* Returns 1 if there's a SFP transceiver inserted in the socket. */
int sfp_present(void);
/* Reads the part ID of the SFP from its configuration EEPROM */
int sfp_read_part_id(char *part_id);
/* Match plugged SFP with a DB entry */
int sfp_match(void);
......
......@@ -36,6 +36,7 @@ void env_init(void);
int shell_exec(const char *buf);
int shell_interactive(void);
extern int shell_is_interacting;
void shell_boot_script(void);
......
......@@ -6,16 +6,14 @@
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <wrc.h>
#include <wrpc.h>
#include <string.h>
#include "endpoint.h"
#include "ipv4.h"
#include "ptpd_netif.h"
#ifndef htons
#define htons(x) x
#endif
static uint8_t __arp_queue[128];
static struct wrpc_socket __static_arp_socket = {
.queue.buff = __arp_queue,
......
......@@ -6,8 +6,9 @@
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include <string.h>
#include <wrc.h>
#include <wrpc.h>
#include <string.h>
#include "endpoint.h"
#include "ipv4.h"
......@@ -16,10 +17,6 @@
#include "hw/memlayout.h"
#include "hw/etherbone-config.h"
#ifndef htons
#define htons(x) x
#endif
enum ip_status ip_status = IP_TRAINING;
static uint8_t myIP[4];
......
......@@ -12,8 +12,9 @@
* Each OID is divided into the limb and twig part.
* The twig part can be handled as a group or a table
*/
#include <string.h>
#include <wrc.h>
#include <wrpc.h>
#include <string.h>
#include <minic.h>
#include <limits.h>
......@@ -30,10 +31,6 @@
#include "storage.h"
#ifndef htons
#define htons(x) x
#endif
#define ASN_BOOLEAN ((u_char)0x01)
#define ASN_INTEGER ((u_char)0x02)
#define ASN_OCTET_STR ((u_char)0x04)
......
......@@ -112,6 +112,7 @@ int syslog_poll(void)
extern struct pp_instance *ppi;
struct wr_servo_state *s;
static uint32_t prev_tics;
static int last_setp, worst_delta, bad_track_lost;
static int track_ok_count, prev_servo_state = -1;
if (IS_HOST_PROCESS)
......@@ -148,10 +149,15 @@ int syslog_poll(void)
goto send;
}
/*
* The following section is all about track-lost events
*/
if (!prev_tics)
prev_tics = now;
if (s && s->state == WR_TRACK_PHASE) /* monitor setpoint while ok */
last_setp = s->cur_setpoint;
if (s && s->state == WR_TRACK_PHASE &&
prev_servo_state != WR_TRACK_PHASE) {
/* we reached sync: log it */
......@@ -171,8 +177,33 @@ int syslog_poll(void)
"%i-th re-rtrack after %i.%03i s",
track_ok_count,
prev_tics / 1000, prev_tics % 1000);
/* Report if we didn't really loose time */
if (!bad_track_lost)
len += pp_sprintf(buf + len, " (max delta %i ps)",
worst_delta);
bad_track_lost = worst_delta = 0;
goto send;
}
if (s && s->state == WR_SYNC_PHASE && (s->flags & WR_FLAG_WAIT_HW)) {
/*
* Passing through SYNC_NSEC is a glimpse, and we won't notice.
* Check, rather if we are waiting beofre sync_phase.
*/
bad_track_lost = 1;
}
if (s && s->state != WR_TRACK_PHASE) {
int delta = s->cur_setpoint - last_setp;
/* "abs(x - y)" is not working, unexpectedly) */
if (delta < 0)
delta = - delta;
if (delta > worst_delta)
worst_delta = delta;
}
if (s && s->state != WR_TRACK_PHASE &&
prev_servo_state == WR_TRACK_PHASE) {
prev_servo_state = s->state;
......@@ -182,6 +213,9 @@ int syslog_poll(void)
goto send;
}
/*
* A section about temperature monitoring
*/
if (!next_temp_check) {
next_temp_check = now + 1000;
......
......@@ -15,6 +15,7 @@ void fill_udp(uint8_t * buf, int len, struct wr_udp_addr *uaddr)
{
unsigned short sum;
struct wr_udp_addr addr;
uint8_t oddb;
/* if there is no user-provided uaddr, we are replying */
if (!uaddr) {
......@@ -40,9 +41,12 @@ void fill_udp(uint8_t * buf, int len, struct wr_udp_addr *uaddr)
buf[UDP_CHECKSUM] = 0;
buf[UDP_CHECKSUM + 1] = 0;
buf[len] = '\0'; /* pad, in case the payload is odd */
/* pad, in case the payload is odd, but we can avoid the if */
oddb = buf[len];
buf[len] = '\0';
sum = ipv4_checksum((unsigned short *)(buf + UDP_VIRT_SADDR),
(len + 1 - UDP_VIRT_SADDR) / 2);
buf[len] = oddb;
if (sum == 0)
sum = 0xFFFF;
......
ppsi @ 31f08f19
Subproject commit 31c0e23bed047439419c5c8e04a3da1da5ed0f3a
Subproject commit 31f08f198ffad87d80e6545ffdb598b6278453e5
#include <wrc.h>
#include "shell.h"
static int cmd_uptime(const char *args[])
{
extern uint32_t uptime_sec;
pp_printf("%u\n", uptime_sec);
return 0;
}
DEFINE_WRC_COMMAND(uptime) = {
.name = "uptime",
.exec = cmd_uptime,
};
......@@ -21,7 +21,6 @@
#define SH_MAX_LINE_LEN 80
#define SH_MAX_ARGS 8
#define SH_ENVIRON_SIZE 256
/* interactive shell state definitions */
......@@ -43,6 +42,8 @@ static int cmd_pos = 0, cmd_len = 0;
static int state = SH_PROMPT;
static int current_key = 0;
int shell_is_interacting;
static int insert(char c)
{
if (cmd_len >= SH_MAX_LINE_LEN)
......@@ -117,9 +118,15 @@ static int _shell_exec(void)
int shell_exec(const char *cmd)
{
strncpy(cmd_buf, cmd, SH_MAX_LINE_LEN);
int i;
if (cmd != cmd_buf)
strncpy(cmd_buf, cmd, SH_MAX_LINE_LEN);
cmd_len = strlen(cmd_buf);
return _shell_exec();
shell_is_interacting = 1;
i = _shell_exec();
shell_is_interacting = 0;
return i;
}
void shell_init()
......@@ -131,6 +138,7 @@ void shell_init()
int shell_interactive()
{
int c;
switch (state) {
case SH_PROMPT:
pp_printf("wrc# ");
......@@ -286,7 +294,7 @@ void shell_boot_script(void)
if (!cmd_len)
break;
pp_printf("executing: %s\n", cmd_buf);
_shell_exec();
shell_exec(cmd_buf);
}
while (CONFIG_HAS_FLASH_INIT) {
......@@ -300,7 +308,7 @@ void shell_boot_script(void)
cmd_buf[cmd_len - 1] = 0;
pp_printf("executing: %s\n", cmd_buf);
_shell_exec();
shell_exec(cmd_buf);
next = 1;
}
......
......@@ -5,6 +5,7 @@ obj-$(CONFIG_WR_NODE) += \
shell/cmd_help.o \
shell/cmd_mac.o \
shell/cmd_ps.o \
shell/cmd_uptime.o \
shell/cmd_refresh.o
obj-$(CONFIG_EMBEDDED_NODE) += \
......
......@@ -37,20 +37,20 @@ int spll_n_chan_ref, spll_n_chan_out;
#define MAIN_CHANNEL (spll_n_chan_ref)
static const struct stringlist_entry seq_states [] =
{
{ SEQ_START_EXT, "start-ext" },
{ SEQ_WAIT_EXT, "wait-ext" },
{ SEQ_START_HELPER, "start-helper" },
{ SEQ_WAIT_HELPER, "wait-helper" },
{ SEQ_START_MAIN, "start-main" },
{ SEQ_WAIT_MAIN, "wait-main" },
{ SEQ_DISABLED, "disabled" },
{ SEQ_READY, "ready" },
{ SEQ_CLEAR_DACS, "clear-dacs" },
{ SEQ_WAIT_CLEAR_DACS, "wait-clear-dacs" },
{ 0, NULL }
static const char *seq_states[] =
{
[SEQ_START_EXT] = "start-ext",
[SEQ_WAIT_EXT] = "wait-ext",
[SEQ_START_HELPER] = "start-helper",
[SEQ_WAIT_HELPER] = "wait-helper",
[SEQ_START_MAIN] = "start-main",
[SEQ_WAIT_MAIN] = "wait-main",
[SEQ_DISABLED] = "disabled",
[SEQ_READY] = "ready",
[SEQ_CLEAR_DACS] = "clear-dacs",
[SEQ_WAIT_CLEAR_DACS] = "wait-clear-dacs",
};
#define SEQ_STATES_NR ARRAY_SIZE(seq_states)
volatile struct softpll_state softpll;
......@@ -481,11 +481,15 @@ void spll_get_num_channels(int *n_ref, int *n_out)
void spll_show_stats()
{
struct softpll_state *s = (struct softpll_state *)&softpll;
const char *statename = seq_states[s->seq_state];
if (s->seq_state >= SEQ_STATES_NR)
statename = "<Unknown>";
if (softpll.mode > 0)
pp_printf("softpll: irqs %d seq %s mode %d "
"alignment_state %d HL%d ML%d HY=%d MY=%d DelCnt=%d\n",
s->irq_count, stringlist_lookup(seq_states, s->seq_state),
s->irq_count, statename,
s->mode, s->ext.align_state,
s->helper.ld.locked, s->mpll.ld.locked,
s->helper.pi.y, s->mpll.pi.y,
......
......@@ -31,10 +31,6 @@
#define SPLL_AUX_ENABLED (1<<0) /* Locking the particular aux channel to the WR reference is enabled */
#define SPLL_AUX_LOCKED (1<<1) /* The particular aux clock is already locked to WR reference */
/* Phase detector types */
#define SPLL_PD_DDMTD 0
#define SPLL_PD_BANGBANG 1
/* Channels for spll_measure_frequency() */
#define SPLL_OSC_REF 0
#define SPLL_OSC_DMTD 1
......@@ -131,7 +127,6 @@ struct softpll_state {
int mode;
int seq_state;
int dac_timeout;
int default_dac_main;
int delock_count;
unsigned irq_count;
int32_t mpll_shift_ps;
......
......@@ -93,24 +93,6 @@ void ld_init(spll_lock_det_t *ld)
ld->lock_changed = 0;
}
void lowpass_init(spll_lowpass_t *lp, int alpha)
{
lp->y_d = 0x80000000;
lp->alpha = alpha;
}
int lowpass_update(spll_lowpass_t *lp, int x)
{
if (lp->y_d == 0x80000000) {
lp->y_d = x;
return x;
} else {
int scaled = (lp->alpha * (x - lp->y_d)) >> 15;
lp->y_d = lp->y_d + (scaled >> 1) + (scaled & 1);
return lp->y_d;
}
}
/* Enables/disables DDMTD tag generation on a given (channel).
Channels (0 ... splL_n_chan_ref - 1) are the reference channels
......@@ -142,40 +124,3 @@ void spll_enable_tagger(int channel, int enable)
pll_verbose("%s: ch %d, OCER 0x%x, RCER 0x%x\n", __FUNCTION__, channel, SPLL->OCER, SPLL->RCER);
}
void biquad_init(spll_biquad_t *bq, const int *coefs, int shift)
{
memset(bq, 0, sizeof(spll_biquad_t));
memcpy(bq->coefs, coefs, 5 * sizeof(int));
bq->shift = shift;
}
int biquad_update(spll_biquad_t *bq, int x)
{
register int y = 0;
y += bq->coefs[0] * x;
y += bq->coefs[1] * bq->xd[0];
y += bq->coefs[2] * bq->xd[1];
y -= bq->coefs[3] * bq->yd[0];
y -= bq->coefs[4] * bq->yd[1];
y >>= bq->shift;
bq->xd[1] = bq->xd[0];
bq->xd[0] = x;
bq->yd[1] = bq->yd[0];
bq->yd[0] = y;
return y;
}
const char *stringlist_lookup(const struct stringlist_entry *slist, int id)
{
int i;
for(i=0; slist[i].str; i++) {
if(slist[i].id == id)
return slist[i].str;
}
return "<unknown>";
}
......@@ -50,33 +50,6 @@ typedef struct {
int lock_changed;
} spll_lock_det_t;
/* simple, 1st-order lowpass filter */
typedef struct {
int alpha;
int y_d;
} spll_lowpass_t;
typedef struct {
int coefs[5]; /* Biquad coefficients: b0 b1 b2 a1 a2 */
int shift; /* bit shift for the coeffs / output */
int yd[2], xd[2]; /* I/O delay lines */
} spll_biquad_t;
/* long-term-average filter */
typedef struct {
int acc;
int n;
int window;
int pos;
int size;
int log[16];
} spll_lta_t;
struct stringlist_entry {
int id;
const char *str;
};
/* initializes the PI controller state. Currently almost a stub. */
void pi_init(spll_pi_t *pi);
......@@ -86,14 +59,7 @@ int pi_update(spll_pi_t *pi, int x);
void ld_init(spll_lock_det_t *ld);
int ld_update(spll_lock_det_t *ld, int y);
void lowpass_init(spll_lowpass_t *lp, int alpha);
int lowpass_update(spll_lowpass_t *lp, int x);
void spll_enable_tagger(int channel, int enable);
void biquad_init(spll_biquad_t *bq, const int *coefs, int shift);
int biquad_update(spll_biquad_t *bq, int x);
const char *stringlist_lookup(const struct stringlist_entry *slist, int id);
#endif // __SPLL_COMMON_H
......@@ -11,13 +11,6 @@
#include "softpll_ng.h"
const int helper_precomp_coefs [] =
{ /*b0*/ 60648,
/*b1*/ 60648,
/*b2*/ 0,
/*a1*/ 55760,
/*a2*/ 0};
void helper_init(struct spll_helper_state *s, int ref_channel)
{
......@@ -33,7 +26,6 @@ void helper_init(struct spll_helper_state *s, int ref_channel)
s->ld.lock_samples = 10000;
s->ld.delock_samples = 100;
s->ref_src = ref_channel;
s->delock_count = 0;
}
int helper_update(struct spll_helper_state *s, int tag,
......@@ -101,8 +93,6 @@ void helper_start(struct spll_helper_state *s)
pi_init((spll_pi_t *)&s->pi);
ld_init((spll_lock_det_t *)&s->ld);
biquad_init(&s->precomp, helper_precomp_coefs, 16);
spll_enable_tagger(s->ref_src, 1);
spll_debug(DBG_EVENT | DBG_HELPER, DBG_EVT_START, 1);
}
......
......@@ -31,10 +31,8 @@ struct spll_helper_state {
int p_setpoint, tag_d0;
int ref_src;
int sample_n;
int delock_count;
spll_pi_t pi;
spll_lock_det_t ld;
spll_biquad_t precomp;
};
void helper_init(struct spll_helper_state *s, int ref_channel);
......
......@@ -14,12 +14,14 @@
#define MPLL_TAG_WRAPAROUND 100000000
#define MATCH_NEXT_TAG 0
#define MATCH_WAIT_REF 1
#define MATCH_WAIT_OUT 2
#undef WITH_SEQUENCING
#ifdef CONFIG_DAC_LOG
extern void spll_log_dac(int y);
#else
static inline void spll_log_dac(int y) {}
#endif
void mpll_init(struct spll_main_state *s, int id_ref,
int id_out)
{
......@@ -37,7 +39,6 @@ void mpll_init(struct spll_main_state *s, int id_ref,
#else
#error "Please set CONFIG for wr switch or wr node"
#endif
s->delock_count = 0;
s->enabled = 0;
/* Freqency branch lock detection */
......@@ -63,9 +64,6 @@ void mpll_start(struct spll_main_state *s)
s->tag_out = -1;
s->tag_ref_d = -1;
s->tag_out_d = -1;
s->seq_ref = 0;
s->seq_out = 0;
s->match_state = MATCH_NEXT_TAG;
s->phase_shift_target = 0;
s->phase_shift_current = 0;
......@@ -138,6 +136,8 @@ int mpll_update(struct spll_main_state *s, int tag, int source)
y = pi_update((spll_pi_t *)&s->pi, err);
SPLL->DAC_MAIN = SPLL_DAC_MAIN_VALUE_W(y)
| SPLL_DAC_MAIN_DAC_SEL_W(s->dac_index);
if (s->dac_index == 0)
spll_log_dac(y);
spll_debug(DBG_MAIN | DBG_REF, s->tag_ref + s->adder_ref, 0);
spll_debug(DBG_MAIN | DBG_TAG, s->tag_out + s->adder_out, 0);
......
......@@ -23,16 +23,10 @@ struct spll_main_state {
int adder_ref, adder_out, tag_ref, tag_out, tag_ref_d, tag_out_d;
// tag sequencing stuff
uint32_t seq_ref, seq_out;
int match_state;
int match_seq;
int phase_shift_target;
int phase_shift_current;
int id_ref, id_out; /* IDs of the reference and the output channel */
int sample_n;
int delock_count;
int dac_index;
int enabled;
};
......
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