view include/ClockSynchronizer.h @ 147:e9a2f31dff7b ClockSync

Something weird happened when pllP=8, so I set pllP=7, which reduces (a bit) the clock adjustment precision
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 15 Sep 2015 02:01:15 +0100
parents e24c531220ee
children
line wrap: on
line source
/*
 * ClockSynchronizer.h
 *
 *  Created on: 26 Aug 2015
 *      Author: giulio
 */

#ifndef CLOCKSYNCHRONIZER_H_
#define CLOCKSYNCHRONIZER_H_

#include <BeagleRT.h>
#include <I2c_Codec.h>
#include <NetworkSend.h>
#include <native/timer.h>
extern I2c_Codec *gAudioCodec;

class ClockSynchronizer {
private:
	int localOffset;
	int remoteOffset;
	RTIME timeOffset;
	int localCounter;
	int remoteCounter;
	RTIME lastTime;
	void reset();
	static bool staticConstructed;
	static void staticConstructor();
	static float currentSamplingRate;
	static float targetSamplingRate;
	static bool threadRunning;
	static int threadWasRunning;
	static AuxiliaryTask setClockTask;
public:
	ClockSynchronizer();
	~ClockSynchronizer();
	void setup();
	void update(int aLocalCounter, int aRemoteCounter, RTIME aLastTime);
	void adjustClock();
	static void setClock();
};

#endif /* CLOCKSYNCHRONIZER_H_ */