/// <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); }
/// <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); }