Now you can download a copy of these docs so you can use them offline! Download now
AnalogModule.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef ANALOG_MODULE_H_
8 #define ANALOG_MODULE_H_
9 
10 #include "ChipObject.h"
11 #include "Module.h"
12 
20 class AnalogModule: public Module
21 {
22  friend class Module;
23 
24 public:
25  static const long kTimebase = 40000000;
26  static const long kDefaultOversampleBits = 0;
27  static const long kDefaultAverageBits = 7;
28  static constexpr float kDefaultSampleRate = 50000.0;
29 
30  void SetSampleRate(float samplesPerSecond);
31  float GetSampleRate();
32  void SetAverageBits(uint32_t channel, uint32_t bits);
33  uint32_t GetAverageBits(uint32_t channel);
34  void SetOversampleBits(uint32_t channel, uint32_t bits);
35  uint32_t GetOversampleBits(uint32_t channel);
36  int16_t GetValue(uint32_t channel);
37  int32_t GetAverageValue(uint32_t channel);
38  float GetAverageVoltage(uint32_t channel);
39  float GetVoltage(uint32_t channel);
40  uint32_t GetLSBWeight(uint32_t channel);
41  int32_t GetOffset(uint32_t channel);
42  int32_t VoltsToValue(int32_t channel, float voltage);
43 
44  static AnalogModule* GetInstance(uint8_t moduleNumber);
45 
46 protected:
47  explicit AnalogModule(uint8_t moduleNumber);
48  virtual ~AnalogModule();
49 
50 private:
51  static SEM_ID m_registerWindowSemaphore;
52 
53  uint32_t GetNumActiveChannels();
54  uint32_t GetNumChannelsToActivate();
55  void SetNumChannelsToActivate(uint32_t channels);
56 
57  tAI *m_module;
58  bool m_sampleRateSet;
59  uint32_t m_numChannelsToActivate;
60 };
61 
62 #endif
int32_t GetOffset(uint32_t channel)
static const long kTimebase
40 MHz clock
Definition: AnalogModule.h:25
AnalogModule(uint8_t moduleNumber)
void SetSampleRate(float samplesPerSecond)
static AnalogModule * GetInstance(uint8_t moduleNumber)
void SetOversampleBits(uint32_t channel, uint32_t bits)
int16_t GetValue(uint32_t channel)
float GetAverageVoltage(uint32_t channel)
uint32_t GetLSBWeight(uint32_t channel)
uint32_t GetOversampleBits(uint32_t channel)
void SetAverageBits(uint32_t channel, uint32_t bits)
Definition: Module.h:15
virtual ~AnalogModule()
int32_t VoltsToValue(int32_t channel, float voltage)
float GetSampleRate()
int32_t GetAverageValue(uint32_t channel)
uint32_t GetAverageBits(uint32_t channel)
float GetVoltage(uint32_t channel)

Generated on Sat Apr 26 2014 12:26:45 for WPILibC++ by doxygen 1.8.6