analogmodule.h

来自「good luck to everyone!」· C头文件 代码 · 共 62 行

H
62
字号
/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.							  */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
/*----------------------------------------------------------------------------*/

#ifndef ANALOG_MODULE_H_
#define ANALOG_MODULE_H_

#include "ChipObject.h"
#include "Module.h"

/**
 * Analog Module class.
 * Each module can independently sample its channels at a configurable rate.
 * There is a 64-bit hardware accumulator associated with channel 1 on each module.
 * The accumulator is attached to the output of the oversample and average engine so that the center
 * value can be specified in higher resolution resulting in less error.
 */
class AnalogModule: public Module
{ 
public:
	static const long kTimebase = 40000000; ///< 40 MHz clock
	static const long kDefaultOversampleBits = 0;
	static const long kDefaultAverageBits = 7;
	static const float kDefaultSampleRate = 50000.0;

	void SetSampleRate(float samplesPerSecond);
	float GetSampleRate();
	void SetAverageBits(UINT32 channel, UINT32 bits);
	UINT32 GetAverageBits(UINT32 channel);
	void SetOversampleBits(UINT32 channel, UINT32 bits);
	UINT32 GetOversampleBits(UINT32 channel);
	INT16 GetValue(UINT32 channel);
	INT32 GetAverageValue(UINT32 channel);
	float GetAverageVoltage(UINT32 channel);
	float GetVoltage(UINT32 channel);
	UINT32 GetLSBWeight(UINT32 channel);
	INT32 GetOffset(UINT32 channel);
	INT32 VoltsToValue(INT32 channel, float voltage);

	static UINT32 SlotToIndex(UINT32 slot);
	static AnalogModule* GetInstance(UINT32 slot);

protected:
	explicit AnalogModule(UINT32 slot);
	virtual ~AnalogModule();

private:
	static SEM_ID m_registerWindowSemaphore;

	UINT32 GetNumActiveChannels();
	UINT32 GetNumChannelsToActivate();
	void SetNumChannelsToActivate(UINT32 channels);

	tAI *m_module;
	bool m_sampleRateSet;
	UINT32 m_numChannelsToActivate;
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?