Пример #1
0
        private void Dispose(bool disposing)
        {
            if (_ledRx != null)
            {
                _ledRx.Dispose();
            }
            if (_ledTx != null)
            {
                _ledTx.Dispose();
            }

            SetPower(false);

            if (_rxThread != null)
            {
                _rxThreadStop = true;
                _rxEvent.Set();
                _rxThread.Join();
            }

            if (_hal != null)
            {
                _hal.Dispose();
                _hal = null;
            }
        }
Пример #2
0
        private Led _ledTx;                // tx led

        /// <summary>
        /// Create and initialize a new driver instance with the specified configuration.
        /// </summary>
        /// <param name="pins">The configuration specified as chip pin settings</param>
        public CC2420(CC2420PinConfig pins, bool activityLeds)
        {
            bool Success = false;

            try
            {
                _hal          = new HALCC2420(pins);
                _activityLeds = activityLeds;
                if (_activityLeds)
                {
                    try
                    {
                        _ledRx = new Led(pins.LedRxPin.PinNumber);
                        _ledTx = new Led(pins.LedTxPin.PinNumber);
                    }
                    catch (Exception)
                    {
                        _activityLeds = false;
                        _ledRx        = _ledTx = null;
                    }
                }

                _enabled = false;

                _rxFrame      = new byte[1];
                _rxReadCmd    = new byte[2];
                _rxReadCmd[0] = ((int)HALCC2420.Reg.RXFIFO) | 0x40;

                _rxEvent      = new AutoResetEvent(false);
                _rxThreadStop = false;
                _rxThread     = new Thread(ReceiveThread);
#if RTEXTENSIONS
                _rxThread.Priority = ThreadPriority.Highest; // MAC is 150
#else
                _rxThread.Priority = (ThreadPriority)151000; // fake RT priority
#endif
                _rxThread.Start();

                _txFrame       = null;
                _txWriteCmd    = new byte[2];
                _txWriteCmd[0] = (byte)HALCC2420.Reg.TXFIFO;

                _channel   = HALCC2420.MinChannel;
                _rfPower   = -1; // dBm
                _rxEnabled = false;

                Success = true;
            }
            finally
            {
                if (!Success)
                {
                    Dispose(true);
                }
            }
        }
Пример #3
0
        private Led _ledTx;                // tx led

        /// <summary>
        /// Create and initialize a new driver instance with the specified configuration.
        /// </summary>
        /// <param name="pins">The configuration specified as chip pin settings</param>
        public CC2420(CC2420PinConfig pins, bool activityLeds)
        {
            bool Success = false;
            try
            {
                _hal = new HALCC2420(pins);
                _activityLeds = activityLeds;
                if (_activityLeds)
                {
                    try
                    {
                        _ledRx = new Led(pins.LedRxPin.PinNumber);
                        _ledTx = new Led(pins.LedTxPin.PinNumber);
                    }
                    catch (Exception)
                    {
                        _activityLeds = false;
                        _ledRx = _ledTx = null;
                    }
                }

                _enabled = false;

                _rxFrame = new byte[1];
                _rxReadCmd = new byte[2];
                _rxReadCmd[0] = ((int)HALCC2420.Reg.RXFIFO) | 0x40;

                _rxEvent = new AutoResetEvent(false);
                _rxThreadStop = false;
                _rxThread = new Thread(ReceiveThread);
#if RTEXTENSIONS
                _rxThread.Priority = ThreadPriority.Highest; // MAC is 150
#else
                _rxThread.Priority = (ThreadPriority)151000; // fake RT priority
#endif
                _rxThread.Start();

                _txFrame = null;
                _txWriteCmd = new byte[2];
                _txWriteCmd[0] = (byte)HALCC2420.Reg.TXFIFO;

                _channel = HALCC2420.MinChannel;
                _rfPower = -1; // dBm
                _rxEnabled = false;

                Success = true;
            }
            finally
            {
                if (!Success) Dispose(true);
            }
        }
Пример #4
0
        private void Dispose(bool disposing)
        {   
            SetPower(false);

            if (_rxThread != null)
            {
                _rxThreadStop = true;
                _rxEvent.Set();
                _rxThread.Join();
            }

            if (_hal != null)
            {
                _hal.Dispose();
                _hal = null;
            }
        }