WPILib 2012
WPILibRoboticsLibraryforFRC
AnalogModule.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef ANALOG_MODULE_H_
00008 #define ANALOG_MODULE_H_
00009 
00010 #include "ChipObject.h"
00011 #include "Module.h"
00012 
00020 class AnalogModule: public Module
00021 { 
00022     friend class Module;
00023 
00024 public:
00025         static const long kTimebase = 40000000; 
00026         static const long kDefaultOversampleBits = 0;
00027         static const long kDefaultAverageBits = 7;
00028         static const float kDefaultSampleRate = 50000.0;
00029 
00030         void SetSampleRate(float samplesPerSecond);
00031         float GetSampleRate();
00032         void SetAverageBits(UINT32 channel, UINT32 bits);
00033         UINT32 GetAverageBits(UINT32 channel);
00034         void SetOversampleBits(UINT32 channel, UINT32 bits);
00035         UINT32 GetOversampleBits(UINT32 channel);
00036         INT16 GetValue(UINT32 channel);
00037         INT32 GetAverageValue(UINT32 channel);
00038         float GetAverageVoltage(UINT32 channel);
00039         float GetVoltage(UINT32 channel);
00040         UINT32 GetLSBWeight(UINT32 channel);
00041         INT32 GetOffset(UINT32 channel);
00042         INT32 VoltsToValue(INT32 channel, float voltage);
00043 
00044         static AnalogModule* GetInstance(UINT8 moduleNumber);
00045 
00046 protected:
00047         explicit AnalogModule(UINT8 moduleNumber);
00048         virtual ~AnalogModule();
00049 
00050 private:
00051         static SEM_ID m_registerWindowSemaphore;
00052 
00053         UINT32 GetNumActiveChannels();
00054         UINT32 GetNumChannelsToActivate();
00055         void SetNumChannelsToActivate(UINT32 channels);
00056 
00057         tAI *m_module;
00058         bool m_sampleRateSet;
00059         UINT32 m_numChannelsToActivate;
00060 };
00061 
00062 #endif
 All Classes Functions Variables