示例#1
0
        //private static uint EAPI_GPIO_BANK_MASK(uint GPIO_NUM)
        //{
        //    return (uint) (1 << (int)((GPIO_NUM) & 0x1F));
        //}
        //#define EAPI_GPIO_BANK_TEST_STATE(GPIO_NUM, TState, TValue) \ (((TValue>>((GPIO_NUM)&0x1F))&1)==(TState))

        internal GpioCapability GetGpioCapabilities()
        {
            uint inputCapabilityMask  = 0;
            uint outputCapabilityMask = 0;
            bool isUnsupported        = false;

            if (_gpioCapability != null)
            {
                return(_gpioCapability);
            }

            uint resultCode = EApiGPIOGetDirectionCaps(_eapiIdGpioBank00, ref inputCapabilityMask, ref outputCapabilityMask);

            if (_eApiStatusCodes.IsUnsupported(resultCode))
            {
                _logger.Warning(_eapiIdGpioBank00 + " EApiGPIOGetDirectionCaps is unsupported");
                isUnsupported = true;
            }
            if (!_eApiStatusCodes.IsSuccess(resultCode))
            {
                _logger.Warning("EApiGPIOGetDirectionCaps: " + _eApiStatusCodes.GetStatusStringFrom(resultCode));
                isUnsupported = true;
            }

            _gpioCapability = new GpioCapability(inputCapabilityMask, outputCapabilityMask, isUnsupported);
            _logger.Information("EApiGPIOGetDirectionCaps: " + _gpioCapability);
            return(_gpioCapability);
        }
示例#2
0
        internal I2CBusCapability GetBusCapabilities()
        {
            uint maxBlockLen = 0;
            uint resultCode  = EApiI2CGetBusCap((uint)Eapi_I2C_ID.EAPI_ID_I2C_EXTERNAL, ref maxBlockLen);

            if (_eApiStatusCodes.IsUnsupported(resultCode))
            {
                _logger.Warning("EApiI2CGetBusCap " + Eapi_I2C_ID.EAPI_ID_I2C_EXTERNAL + " is unsupported");
                return(new I2CBusCapability(maxBlockLen, true));
            }
            if (!_eApiStatusCodes.IsSuccess(resultCode))
            {
                throw new Exception("EApiI2CGetBusCap " + Eapi_I2C_ID.EAPI_ID_I2C_EXTERNAL + ": " +
                                    _eApiStatusCodes.GetStatusStringFrom(resultCode));
            }
            return(new I2CBusCapability(maxBlockLen));
        }
        internal uint GetBoardInformationOf(BoardInformationValueId boardInformationValueId)
        {
            uint value      = 0;
            uint resultCode = EApiBoardGetValue((uint)boardInformationValueId, ref value);

            if (_eApiStatusCodes.IsUnsupported(resultCode))
            {
                throw new NotSupportedException(boardInformationValueId.ToString());
            }

            if (!_eApiStatusCodes.IsSuccess(resultCode))
            {
                throw new Exception(_eApiStatusCodes.GetStatusStringFrom(resultCode));
            }

            if (boardInformationValueId == BoardInformationValueId.EAPI_ID_HWMON_CHIPSET_TEMP ||
                boardInformationValueId == BoardInformationValueId.EAPI_ID_HWMON_CPU_TEMP ||
                boardInformationValueId == BoardInformationValueId.EAPI_ID_HWMON_SYSTEM_TEMP)
            {
                return(EAPI_DECODE_CELCIUS(value));
            }
            return(value);
        }