public void Dispose()
 {
     if (this._isDisposed)
     {
         return;
     }
     this._isDisposed = true;
     LibMpsse.Cleanup();
 }
        private void InitLibAndHandle()
        {
            if (_spiHandle != IntPtr.Zero)
            {
                return;
            }

            LibMpsse.Init();

            var result = CheckResult(LibMpsse_AccessToCppDll.SPI_OpenChannel(_ftdiMpsseChannelConfig.ChannelIndex, out _spiHandle));

            if (_spiHandle == IntPtr.Zero)
            {
                throw new SpiChannelNotConnectedException(FtdiMpsseSPIResult.InvalidHandle);
            }

            result        = CheckResult(LibMpsse_AccessToCppDll.SPI_InitChannel(_spiHandle, ref _spiConfig));
            _globalConfig = this._spiConfig;
        }