Now you can download a copy of these docs so you can use them offline! Download now
InterruptableSensorBase.cpp
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 #include "InterruptableSensorBase.h"
8 #include "Utility.h"
9 
10 InterruptableSensorBase::InterruptableSensorBase()
11 {
12  m_manager = NULL;
13  m_interrupt = NULL;
14 }
15 
16 InterruptableSensorBase::~InterruptableSensorBase()
17 {
18 
19 }
20 
21 void InterruptableSensorBase::AllocateInterrupts(bool watcher)
22 {
23  wpi_assert(m_interrupt == NULL);
24  wpi_assert(m_manager == NULL);
25  // Expects the calling leaf class to allocate an interrupt index.
26  tRioStatusCode localStatus = NiFpga_Status_Success;
27  m_interrupt = tInterrupt::create(m_interruptIndex, &localStatus);
28  m_interrupt->writeConfig_WaitForAck(false, &localStatus);
29  m_manager = new tInterruptManager(1 << m_interruptIndex, watcher, &localStatus);
30  wpi_setError(localStatus);
31 }
32 
38 {
39  wpi_assert(m_manager != NULL);
40  wpi_assert(m_interrupt != NULL);
41  delete m_interrupt;
42  delete m_manager;
43  m_interrupt = NULL;
44  m_manager = NULL;
45 }
46 
52 {
53  wpi_assert(m_manager != NULL);
54  wpi_assert(m_interrupt != NULL);
55  tRioStatusCode localStatus = NiFpga_Status_Success;
56  m_manager->watch((int32_t)(timeout * 1e3), &localStatus);
57  wpi_setError(localStatus);
58 }
59 
66 {
67  wpi_assert(m_manager != NULL);
68  wpi_assert(m_interrupt != NULL);
69  tRioStatusCode localStatus = NiFpga_Status_Success;
70  m_manager->enable(&localStatus);
71  wpi_setError(localStatus);
72 }
73 
78 {
79  wpi_assert(m_manager != NULL);
80  wpi_assert(m_interrupt != NULL);
81  tRioStatusCode localStatus = NiFpga_Status_Success;
82  m_manager->disable(&localStatus);
83  wpi_setError(localStatus);
84 }
85 
92 {
93  wpi_assert(m_interrupt != NULL);
94  tRioStatusCode localStatus = NiFpga_Status_Success;
95  uint32_t timestamp = m_interrupt->readTimeStamp(&localStatus);
96  wpi_setError(localStatus);
97  return timestamp * 1e-6;
98 }
virtual void DisableInterrupts()
Disable, but don't deallocate.
virtual void CancelInterrupts()
Free up the underlying chipobject functions.
virtual void WaitForInterrupt(float timeout)
Synchronus version.
virtual double ReadInterruptTimestamp()
Return the timestamp for the interrupt that occurred.
virtual void EnableInterrupts()
Enable interrupts - after finishing setup.

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