Now you can download a copy of these docs so you can use them offline! Download now
DigitalModule.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 DIGITAL_MODULE_H_
8 #define DIGITAL_MODULE_H_
9 
10 #include "Module.h"
11 #include "ChipObject.h"
12 
13 class I2C;
14 
15 const uint32_t kExpectedLoopTiming = 260;
16 
17 class DigitalModule: public Module
18 {
19  friend class I2C;
20  friend class Module;
21 
22 protected:
23  explicit DigitalModule(uint8_t moduleNumber);
24  virtual ~DigitalModule();
25 
26 public:
27  void SetPWM(uint32_t channel, uint8_t value);
28  uint8_t GetPWM(uint32_t channel);
29  void SetPWMPeriodScale(uint32_t channel, uint32_t squelchMask);
30  void SetRelayForward(uint32_t channel, bool on);
31  void SetRelayReverse(uint32_t channel, bool on);
32  bool GetRelayForward(uint32_t channel);
33  uint8_t GetRelayForward();
34  bool GetRelayReverse(uint32_t channel);
35  uint8_t GetRelayReverse();
36  bool AllocateDIO(uint32_t channel, bool input);
37  void FreeDIO(uint32_t channel);
38  void SetDIO(uint32_t channel, short value);
39  bool GetDIO(uint32_t channel);
40  uint16_t GetDIO();
41  bool GetDIODirection(uint32_t channel);
42  uint16_t GetDIODirection();
43  void Pulse(uint32_t channel, float pulseLength);
44  bool IsPulsing(uint32_t channel);
45  bool IsPulsing();
46  uint32_t AllocateDO_PWM();
47  void FreeDO_PWM(uint32_t pwmGenerator);
48  void SetDO_PWMRate(float rate);
49  void SetDO_PWMDutyCycle(uint32_t pwmGenerator, float dutyCycle);
50  void SetDO_PWMOutputChannel(uint32_t pwmGenerator, uint32_t channel);
51  uint16_t GetLoopTiming();
52 
53  I2C* GetI2C(uint32_t address);
54 
55  static DigitalModule* GetInstance(uint8_t moduleNumber);
56  static uint8_t RemapDigitalChannel(uint32_t channel) { return 15 - channel; }; // TODO: Need channel validation
57  static uint8_t UnmapDigitalChannel(uint32_t channel) { return 15 - channel; }; // TODO: Need channel validation
58 
59 private:
60  SEM_ID m_digitalSemaphore;
61  SEM_ID m_relaySemaphore;
62  SEM_ID m_doPwmSemaphore;
63  tDIO *m_fpgaDIO;
64 };
65 
66 #endif
67 
void SetRelayReverse(uint32_t channel, bool on)
uint16_t GetLoopTiming()
uint8_t GetPWM(uint32_t channel)
uint8_t GetRelayForward()
void SetDIO(uint32_t channel, short value)
void SetRelayForward(uint32_t channel, bool on)
void Pulse(uint32_t channel, float pulseLength)
uint16_t GetDIO()
void SetDO_PWMOutputChannel(uint32_t pwmGenerator, uint32_t channel)
Definition: I2C.h:22
DigitalModule(uint8_t moduleNumber)
void FreeDIO(uint32_t channel)
void SetDO_PWMDutyCycle(uint32_t pwmGenerator, float dutyCycle)
bool AllocateDIO(uint32_t channel, bool input)
void SetDO_PWMRate(float rate)
uint32_t AllocateDO_PWM()
Definition: Module.h:15
void SetPWM(uint32_t channel, uint8_t value)
static DigitalModule * GetInstance(uint8_t moduleNumber)
I2C * GetI2C(uint32_t address)
uint16_t GetDIODirection()
void SetPWMPeriodScale(uint32_t channel, uint32_t squelchMask)
uint8_t GetRelayReverse()
void FreeDO_PWM(uint32_t pwmGenerator)

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