Esempio n. 1
0
 public static void PingAll()
 {
     HALAccelerometer.Ping();
     HALAnalogAccumulator.Ping();
     HALAnalogGyro.Ping();
     HALAnalogInput.Ping();
     HALAnalogOutput.Ping();
     HALAnalogTrigger.Ping();
     HALCompressor.Ping();
     HALConstants.Ping();
     HALDIO.Ping();
     HALDriverStation.Ping();
     HALEncoder.Ping();
     HALI2C.Ping();
     HALInterrupts.Ping();
     HALNotifier.Ping();
     HALPDP.Ping();
     HALPorts.Ping();
     HALPower.Ping();
     HALPWM.Ping();
     HALRelay.Ping();
     HALSerialPort.Ping();
     HALSolenoid.Ping();
     HALSPI.Ping();
     HALThreads.Ping();
 }
Esempio n. 2
0
        /// <summary>
        /// Return the timestamp for the falling interrupt that occurred most recently.
        /// </summary>
        /// <returns>Timestamp in seconds since boot.</returns>
        /// <remarks>This is in the same time domain as GetClock(). The rising edge interrupt
        /// should be enabled with <see cref="SetUpSourceEdge"/></remarks>
        public double ReadFallingTimestanp()
        {
            if (Interrupt == 0)
            {
                throw new InvalidOperationException("The interrupt is not allocated.");
            }
            int    status    = 0;
            double timestamp = HALInterrupts.HAL_ReadInterruptFallingTimestamp(Interrupt, ref status);

            Utility.CheckStatus(status);
            return(timestamp);
        }
Esempio n. 3
0
        /// /// <summary>
        /// In synchronous mode, wait for the defined interrupt to occur.
        /// </summary>
        /// <param name="timeout">Timeout in seconds</param>
        /// /// <param name="ignorePrevious">If true, ignore previous interrupts that
        /// happened before this was called.</param>
        /// <returns>The <see cref="WaitResult"/> of the interrupt</returns>
        public WaitResult WaitForInterrupt(double timeout, bool ignorePrevious)
        {
            if (Interrupt == 0)
            {
                throw new InvalidOperationException("The interrupt is not allocated.");
            }
            int  status = 0;
            long value  = HALInterrupts.HAL_WaitForInterrupt(Interrupt, timeout, ignorePrevious, ref status);

            Utility.CheckStatus(status);
            return((WaitResult)value);
        }
Esempio n. 4
0
 /// <summary>
 /// Set which edge to trigger interrupts on.
 /// </summary>
 /// <param name="risingEdge">True to interrupt on the rising edge</param>
 /// <param name="fallingEdge">True to interrupt on the falling edge</param>
 public void SetUpSourceEdge(bool risingEdge, bool fallingEdge)
 {
     if (Interrupt != 0)
     {
         int status = 0;
         HALInterrupts.HAL_SetInterruptUpSourceEdge(Interrupt, risingEdge, fallingEdge, ref status);
         Utility.CheckStatus(status);
     }
     else
     {
         throw new InvalidOperationException("You must call RequestInterrupts before SetUpSourceEdge");
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Cancel interrupts on this device.
        /// </summary>
        /// <remarks>This deallocates all the structures and disables any interrupts.</remarks>
        public void CancelInterrupts()
        {
            if (Interrupt == 0)
            {
                throw new InvalidOperationException("The interrupt is not allocated.");
            }
            int status = 0;

            HALInterrupts.HAL_CleanInterrupts(Interrupt, ref status);
            Utility.CheckStatus(status);

            Interrupt = 0;
        }
Esempio n. 6
0
        /// <summary>
        /// Disable Interrupts without deallocating structures.
        /// </summary>
        public void DisableInterrupts()
        {
            if (Interrupt == 0)
            {
                throw new InvalidOperationException("The interrupt is not allocated.");
            }
            if (IsSynchronousInterrupt)
            {
                throw new InvalidOperationException("You do not need to enable synchronous interrupts");
            }
            int status = 0;

            HALInterrupts.HAL_DisableInterrupts(Interrupt, ref status);
            Utility.CheckStatus(status);
        }
Esempio n. 7
0
        /// <summary>
        /// Allocate the interrupt.
        /// </summary>
        /// <param name="watcher">True if the interrupt should be called in synchronous mode
        /// where the user program will have to explicitly wait for the interrupt
        /// to occur.</param>
        protected void AllocateInterrupts(bool watcher)
        {
            if (Interrupt != 0)
            {
                throw new AllocationException("The interrupt has already been allocated");
            }


            IsSynchronousInterrupt = watcher;

            int status = 0;

            Interrupt = HALInterrupts.HAL_InitializeInterrupts(watcher, ref status);
            Utility.CheckStatus(status);
        }
Esempio n. 8
0
        /// <summary>
        /// Requests one of the 8 interrupts synchronously on this input.
        /// </summary>
        /// <remarks>Request interrupts in synchronous mode where the user program will have to explicitly
        /// wait for the interrupt to occur using <see cref="WaitForInterrupt(double)">WaitForInterrupt</see>.
        /// The default is interrupt on rising edges only.</remarks>
        public void RequestInterrupts()
        {
            if (Interrupt != 0)
            {
                throw new AllocationException("The interrupt has already been allocated");
            }

            AllocateInterrupts(true);

            int status = 0;

            HALInterrupts.HAL_RequestInterrupts(Interrupt, PortHandleForRouting, (HALAnalogTriggerType)AnalogTriggerTypeForRouting, ref status);
            Utility.CheckStatus(status);
            SetUpSourceEdge(true, false);
        }
Esempio n. 9
0
        /// <summary>
        /// Requests one of the 8 interrupts asynchronously on this input.
        /// </summary>
        /// <remarks>Request interrupts in asynchronous mode where the user program interrupt handler will be
        /// called when an interrupt occurs. The default is interrupt on rising edges only.</remarks>
        /// <param name="handler">The callback that will be called whenever
        /// there is an interrupt on this device.</param>
        public void RequestInterrupts(Action handler)
        {
            m_function = (mask, t) => handler();
            if (Interrupt != 0)
            {
                throw new AllocationException("The interrupt has already been allocated");
            }
            AllocateInterrupts(false);

            m_param = null;

            int status = 0;

            HALInterrupts.HAL_RequestInterrupts(Interrupt, PortHandleForRouting, (HALAnalogTriggerType)AnalogTriggerTypeForRouting, ref status);
            Utility.CheckStatus(status);
            SetUpSourceEdge(true, false);
            HALInterrupts.HAL_AttachInterruptHandler(Interrupt, m_function, IntPtr.Zero, ref status);
            Utility.CheckStatus(status);
        }