/** * Unreserve the interrupt from FPGA and disable timer IRQ IO. * * @param[in] irqChannel A structure containing the registers and settings * for timer IRQ IO to modify. * @param[in] irqContext IRQ context under which you unreserve the IRQ. * @return the configuration status. */ int32_t Irq_UnregisterTimerIrq(MyRio_IrqTimer* irqChannel, NiFpga_IrqContext irqContext) { int32_t status; /* * Check if the specified IRQ resource is registered. */ status = Irq_CheckReserved(irqChannel->timerChannel, TIMERIRQNO); if (status == NiMyrio_Status_Success) { /* * Did not find the resource in the list. */ printf("You didn't register an interrupt with this IRQ number.\n"); return NiMyrio_Status_Success; } /* * Write the value to the IRQTIMERSETTIME register. */ status = NiFpga_WriteU32(myrio_session, irqChannel->timerWrite, 0); status = NiFpga_WriteBool(myrio_session, irqChannel->timerSet, NiFpga_True); /* * Check if there was an error writing to the IRQTIMERSETTIME register. * * If there was an error then print an error message to stdout and return configuration status. */ MyRio_ReturnStatusIfNotSuccess(status, "Could not write to IRQTIMERSETTIME register!") /* * Delete the reserved resource in the list. */ status = Irq_RemoveReserved(TIMERIRQNO); /* * Check if there was an error releasing the resource from list. * * If there was an error then print an error message to stdout. */ MyRio_ReturnStatusIfNotSuccess(status, "Could not release the irq resource!") /* * Unreserve an IRQ context obtained from Irq_ReserveIrqContext. * The returned NiFpga_Status value is stored for error checking. */ status = NiFpga_UnreserveIrqContext(myrio_session, irqContext); /* * Check if there was an error when unreserve an IRQ. * * If there was an error then print an error message to stdout and return configuration status. */ MyRio_ReturnStatusIfNotSuccess(status, "A required NiFpga_IrqContext was not unreserved.") return NiMyrio_Status_Success; }
/** * Unreserve the interrupt from FPGA, and disable the particular digital IRQ IO, * clear according channel value and IRQ number in the resource list. * So the IO can be configured in the next time. * * @param[in] irqChannel A struct containing the registers and settings * for a particular analog IRQ IO to modify. * @param[in] irqContext IRQ context with to unreserve. * @return the configuration status. */ int32_t Irq_UnregisterDiIrq(MyRio_IrqDi* irqChannel, NiFpga_IrqContext irqContext, uint8_t irqNumber) { int32_t status; uint8_t cnfgValue; /* * Limit the IRQ number within a range, * if the entered value is out of range, print an error message. */ if (irqNumber > IRQNO_MAX || irqNumber < IRQNO_MIN) { printf("The specified IRQ Number is out of range.\n"); return NiMyrio_Status_IrqNumberNotUsable; } /* * Check if the specified IRQ resource is registered. */ status = Irq_CheckReserved(irqChannel->dioChannel, irqNumber); if (status == NiMyrio_Status_Success) { /* * Did not find the resource in the list */ printf("You didn't register an interrupt with this IRQ number.\n"); return NiMyrio_Status_Success; } /* * Get the current value of the DI configure register. */ status = NiFpga_ReadU8(myrio_session, irqChannel->dioIrqEnable, &cnfgValue); /* * Check if there was an error reading from the DI configure register. * * If there was an error then print an error message to stdout and return configuration status. */ MyRio_ReturnStatusIfNotSuccess(status, "Could not read from the DI configure register!") /* * Disable the specified channel. */ if (irqChannel->dioChannel == Irq_Dio_A0) { /* * Clear the value of the masked bits in the DI configure register. This is * done so DI0 is disabled. */ cnfgValue = cnfgValue & (~Irq_Dio_A0_Enable); } else if (irqChannel->dioChannel == Irq_Dio_A1) { /* * Clear the value of the masked bits in the DI configure register. This is * done so DI1 is disabled. */ cnfgValue = cnfgValue & (~Irq_Dio_A1_Enable); } else if (irqChannel->dioChannel == Irq_Dio_A2) { /* * Clear the value of the masked bits in the DI configure register. This is * done so DI2 is disabled. */ cnfgValue = cnfgValue & (~Irq_Dio_A2_Enable); } else if (irqChannel->dioChannel == Irq_Dio_A3) { /* * Clear the value of the masked bits in the DI configure register. This is * done so DI3 is disabled. */ cnfgValue = cnfgValue & (~Irq_Dio_A3_Enable); } /* * Write the new value of the DI configure register to the device. */ status = NiFpga_WriteU8(myrio_session, irqChannel->dioIrqEnable, cnfgValue); /* * Check if there was an error writing to DI configure register. * * If there was an error then print an error message to stdout and return configuration status. */ MyRio_ReturnStatusIfNotSuccess(status, "Could not write to the AI configure register!") /* * Remove the reserved resource in the list. */ status = Irq_RemoveReserved(irqNumber); /* * Check if there was an error releasing the resource from list. * * If there was an error then print an error message to stdout. */ MyRio_ReturnStatusIfNotSuccess(status, "Could not release the irq resource!"); /* * Unreserve an IRQ context obtained from Irq_ReserveIrqContext. * The returned NiFpga_Status value is stored for error checking. */ status = NiFpga_UnreserveIrqContext(myrio_session, irqContext); /* * Check if there was an error when unreserve an IRQ. * * If there was an error then print an error message to stdout and return configuration status. */ MyRio_ReturnStatusIfNotSuccess(status, "A required NiFpga_IrqContext was not unreserved.") return NiMyrio_Status_Success; }
bool nifpga::UnreserveIrqContext(NiFpga_IrqContext context) { if (sessionOpen && sessionRunning) return HandleStatus(NiFpga_UnreserveIrqContext(sessionHandle, context)); return false; }