Esempio n. 1
0
        public CrcLengths GetCrcLength()
        {
            CrcLengths crcLength = CrcLengths.CrcDisabled;
            byte       config    = (byte)(ReadRegister(Constants.CONFIG) & (_BV(Constants.CRCO) | _BV(Constants.EN_CRC)));

            if ((config & _BV(Constants.EN_CRC)) == 1)
            {
                crcLength = (config & _BV(Constants.CRCO)) == 1 ? CrcLengths.Crc16Bit : CrcLengths.Crc8Bit;
            }

            return(crcLength);
        }
Esempio n. 2
0
        public void SetCrcLength(CrcLengths crcLength)
        {
            byte config = (byte)(ReadRegister(Constants.CONFIG) & ~(_BV(Constants.CRCO) | _BV(Constants.CRCO)));

            if (crcLength == CrcLengths.CrcDisabled)
            {
                // Do nothing, we turned it off above.
            }
            else if (crcLength == CrcLengths.Crc8Bit)
            {
                config |= _BV(Constants.EN_CRC);
            }
            else
            {
                config |= _BV(Constants.EN_CRC);
                config |= _BV(Constants.CRCO);
            }

            WriteRegister(Constants.CONFIG, config);
        }
Esempio n. 3
0
        public void SetCrcLength(CrcLengths crcLength)
        {
            byte config = (byte)(ReadRegister(Constants.CONFIG) & ~(BitValue(Constants.CRCO) | BitValue(Constants.CRCO)));
            if (crcLength == CrcLengths.CrcDisabled)
            {
                // Do nothing, we turned it off above. 
            }
            else if (crcLength == CrcLengths.Crc8Bit)
            {
                config |= BitValue(Constants.EN_CRC);
            }
            else
            {
                config |= BitValue(Constants.EN_CRC);
                config |= BitValue(Constants.CRCO);
            }

            WriteRegister(Constants.CONFIG, config);
        }