示例#1
0
文件: Atmel.cs 项目: g3gg0/rx-fft
 // FIFO Functions
 public bool FIFOReset(bool state)
 {
     lock (Lock)
     {
         return(I2CDevice.I2CWriteByte(BusID, (byte)(state ? 0x28 : 0x29)));
     }
 }
示例#2
0
文件: VUHF_RX.cs 项目: g3gg0/rx-fft
        public bool OpenTuner()
        {
            if (DeviceTypeDisabled)
            {
                return(false);
            }

            if (!I2cDevice.I2CDeviceAck(BusID))
            {
                return(false);
            }

            byte[] buffer = new byte[32];
            if (!I2cDevice.I2CWriteByte(BusID, 211))
            {
                return(false);
            }
            if (!I2cDevice.I2CReadBytes(BusID, buffer))
            {
                return(false);
            }

            byte[] wordBuffer = new byte[4];

            /* read PFD - 4 byte LSB first */
            if (!I2cDevice.I2CWriteByte(BusID, 215))
            {
                return(false);
            }
            if (!I2cDevice.I2CReadBytes(BusID, wordBuffer))
            {
                return(false);
            }
            PFD = (wordBuffer[3] << 24) | (wordBuffer[2] << 16) | (wordBuffer[1] << 8) | wordBuffer[0];

            /* read Modulus - 1 byte */
            if (!I2cDevice.I2CWriteByte(BusID, 217))
            {
                return(false);
            }
            if (!I2cDevice.I2CReadByte(BusID, wordBuffer))
            {
                return(false);
            }
            Modulus = wordBuffer[0];

            /* enable LNA */
            if (!I2cDevice.I2CWriteByte(BusID, 229))
            {
                return(false);
            }

            /* disable ATT */
            if (!I2cDevice.I2CWriteBytes(BusID, new byte[] { 231, 0 }))
            {
                return(false);
            }

            if (PFD == 0)
            {
                PFD = 20000000;
            }

            if (Modulus == 0)
            {
                Modulus = 40;
            }

            long oldFreq = GetStartupFrequency();

            Init();
            SetFrequency(oldFreq);

            return(true);
        }