-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnalogModule.h
61 lines (51 loc) · 2 KB
/
AnalogModule.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*----------------------------------------------------------------------------*/
/* 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