public static CC2420PinConfig DefaultSAM9261()
        {
            CC2420PinConfig res = new CC2420PinConfig();

            res.ChipPower.PinNumber = (Cpu.Pin) 22;
            res.ChipPower.PinMode   = Port.ResistorMode.Disabled;
            res.ResetNPin.PinNumber = (Cpu.Pin) 21;
            res.ResetNPin.PinMode   = Port.ResistorMode.Disabled;
            res.FIFOPin.PinNumber   = (Cpu.Pin) 16;
            res.FIFOPin.PinMode     = Port.ResistorMode.Disabled;
            res.FIFOPPin.PinNumber  = (Cpu.Pin) 15;
            res.FIFOPPin.PinMode    = Port.ResistorMode.Disabled;
            res.CCAPin.PinNumber    = (Cpu.Pin) 8;
            res.CCAPin.PinMode      = Port.ResistorMode.Disabled;
            res.SFDPin.PinNumber    = (Cpu.Pin) 7;
            res.SFDPin.PinMode      = Port.ResistorMode.Disabled;
            res.CsNPin.PinNumber    = (Cpu.Pin) 4;
            res.CsNPin.PinMode      = Port.ResistorMode.Disabled;

            res.LedRxPin.PinNumber = (Cpu.Pin) 13;
            res.LedRxPin.PinMode   = Port.ResistorMode.Disabled;
            res.LedTxPin.PinNumber = (Cpu.Pin) 14;
            res.LedTxPin.PinMode   = Port.ResistorMode.Disabled;

            res.SPI_mod = SPI.SPI_module.SPI1;
            return(res);
        }
        public static CC2420PinConfig DefaultiMXS()
        {
            CC2420PinConfig res = new CC2420PinConfig();

            res.ChipPower.PinNumber = (Cpu.Pin) 48;
            res.ChipPower.PinMode   = Port.ResistorMode.Disabled;
            res.FIFOPin.PinNumber   = (Cpu.Pin) 40;
            res.FIFOPin.PinMode     = Port.ResistorMode.Disabled;
            res.FIFOPPin.PinNumber  = (Cpu.Pin) 63;
            res.FIFOPPin.PinMode    = Port.ResistorMode.Disabled;
            res.CCAPin.PinNumber    = (Cpu.Pin) 62;
            res.CCAPin.PinMode      = Port.ResistorMode.Disabled;
            res.SFDPin.PinNumber    = (Cpu.Pin) 60;
            res.SFDPin.PinMode      = Port.ResistorMode.Disabled;
            res.CsNPin.PinNumber    = (Cpu.Pin) 61;
            res.CsNPin.PinMode      = Port.ResistorMode.Disabled;
            res.ResetNPin.PinNumber = (Cpu.Pin) 44;
            res.ResetNPin.PinMode   = Port.ResistorMode.Disabled;

            res.LedRxPin.PinNumber = (Cpu.Pin) 41; /// VK_MENU: MC9328MXL_GPIO::c_Port_B_15
            res.LedRxPin.PinMode   = Port.ResistorMode.Disabled;
            res.LedTxPin.PinNumber = (Cpu.Pin) 49; /// VK_BACK: pin = MC9328MXL_GPIO::c_Port_B_17;
            res.LedTxPin.PinMode   = Port.ResistorMode.Disabled;

            res.SPI_mod = SPI.SPI_module.SPI1;
            return(res);
        }
        /// <summary>
        /// Get default configuration
        /// </summary>
        /// <returns>default configuration</returns>
        public static CC2420PinConfig Default()
        {
            CC2420PinConfig res = new CC2420PinConfig();

            res.ChipPower.PinNumber = CC2420Pins.GPIO_PORT_CC2420_VREG_EN;
            res.ChipPower.PinMode   = Port.ResistorMode.Disabled;
            res.FIFOPin.PinNumber   = CC2420Pins.GPIO_PORT_CC2420_FIFO;
            res.FIFOPin.PinMode     = Port.ResistorMode.Disabled;
            res.FIFOPPin.PinNumber  = CC2420Pins.GPIO_PORT_CC2420_FIFOP;
            res.FIFOPPin.PinMode    = Port.ResistorMode.Disabled;
            res.CCAPin.PinNumber    = CC2420Pins.GPIO_PORT_CC2420_CCA;
            res.CCAPin.PinMode      = Port.ResistorMode.Disabled;
            res.SFDPin.PinNumber    = CC2420Pins.GPIO_PORT_CC2420_SFD;
            res.SFDPin.PinMode      = Port.ResistorMode.Disabled;
            res.CsNPin.PinNumber    = CC2420Pins.GPIO_PORT_PIN_39;
            res.CsNPin.PinMode      = Port.ResistorMode.Disabled;
            res.ResetNPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_RESETN;
            res.ResetNPin.PinMode   = Port.ResistorMode.Disabled;
            res.LedRxPin.PinNumber  = CC2420Pins.GPIO_PORT_LED_RED;
            res.LedRxPin.PinMode    = Port.ResistorMode.Disabled;
            res.LedTxPin.PinNumber  = CC2420Pins.GPIO_PORT_LED_GREEN;
            res.LedTxPin.PinMode    = Port.ResistorMode.Disabled;
            res.SPI_mod             = SPI.SPI_module.SPI3;
            return(res);
        }
Exemple #4
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);
                }
            }
        }
Exemple #5
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);
            }
        }
Exemple #6
0
        private ushort _autoFCS;                   // automatic calculation of FCS
        #endregion

        #region Constructor/Destructor
        /// <summary>
        /// Create a new HALCC2420 object with configuration specified by a given CC2420PinConfig.
        /// </summary>
        /// <param name="pins">          The CC2420PinConfig for configuration     </param>
        internal HALCC2420(CC2420PinConfig pins)
        {
            bool Success = false;

            try
            {
                _spi = new SPI(new SPI.Configuration(pins.CsNPin.PinNumber,      // Chip select port
                                                     false,                      // Chip select active state
                                                     0,                          // Chip select setup time
                                                     0,                          // Chip select hold time
                                                     false,                      // Clock idle state
                                                     true,                       // Clock edge
                                                     8096,                       // Clock rate KHz (986KHz)
                                                     pins.SPI_mod                // SPI port connected to CC2420
                                                     )
                               );

                _fifoPort       = new InputPort(pins.FIFOPin.PinNumber, false, pins.FIFOPin.PinMode);
                _fifopInterrupt = new InterruptPort(pins.FIFOPPin.PinNumber,
                                                    false,
                                                    pins.FIFOPPin.PinMode,
                                                    Port.InterruptMode.InterruptEdgeHigh
                                                    );
                _sfdInterrupt = new InterruptPort(pins.SFDPin.PinNumber,
                                                  false,
                                                  pins.SFDPin.PinMode,
                                                  Port.InterruptMode.InterruptEdgeLow
                                                  );

                _ccaPort   = new InputPort(pins.CCAPin.PinNumber, false, pins.CCAPin.PinMode);
                _resetPort = new OutputPort(pins.ResetNPin.PinNumber, true);
                _powerPort = new OutputPort(pins.ChipPower.PinNumber, false);

                _addressFiltering = 0; //we start in promiscousmode
                _autoACK          = 0;
                _panCoord         = 0;
                _autoFCS          = 0;

                Success = true;
            }
            finally
            {
                if (!Success)
                {
                    Dispose(true);
                }
            }
        }
        public static CC2420PinConfig DefaultSAM9261()
        {
            CC2420PinConfig res = new CC2420PinConfig();
            res.ChipPower.PinNumber = (Cpu.Pin)22;
            res.ChipPower.PinMode = Port.ResistorMode.Disabled;
            res.ResetNPin.PinNumber = (Cpu.Pin)21;
            res.ResetNPin.PinMode = Port.ResistorMode.Disabled;
            res.FIFOPin.PinNumber = (Cpu.Pin)16;
            res.FIFOPin.PinMode = Port.ResistorMode.Disabled;
            res.FIFOPPin.PinNumber = (Cpu.Pin)15;
            res.FIFOPPin.PinMode = Port.ResistorMode.Disabled;
            res.CCAPin.PinNumber = (Cpu.Pin)8;
            res.CCAPin.PinMode = Port.ResistorMode.Disabled;
            res.SFDPin.PinNumber = (Cpu.Pin)7;
            res.SFDPin.PinMode = Port.ResistorMode.Disabled;
            res.CsNPin.PinNumber = (Cpu.Pin)4;
            res.CsNPin.PinMode = Port.ResistorMode.Disabled;

            res.LedRxPin.PinNumber = (Cpu.Pin)13;
            res.LedRxPin.PinMode = Port.ResistorMode.Disabled;
            res.LedTxPin.PinNumber = (Cpu.Pin)14;
            res.LedTxPin.PinMode = Port.ResistorMode.Disabled;

            res.SPI_mod = SPI.SPI_module.SPI1;
            return res;
        }
        public static CC2420PinConfig DefaultiMXS()
        {
            CC2420PinConfig res = new CC2420PinConfig();
            res.ChipPower.PinNumber = (Cpu.Pin)48;
            res.ChipPower.PinMode = Port.ResistorMode.Disabled;
            res.FIFOPin.PinNumber = (Cpu.Pin)40;
            res.FIFOPin.PinMode = Port.ResistorMode.Disabled;
            res.FIFOPPin.PinNumber = (Cpu.Pin)63;
            res.FIFOPPin.PinMode = Port.ResistorMode.Disabled;
            res.CCAPin.PinNumber = (Cpu.Pin)62;
            res.CCAPin.PinMode = Port.ResistorMode.Disabled;
            res.SFDPin.PinNumber = (Cpu.Pin)60;
            res.SFDPin.PinMode = Port.ResistorMode.Disabled;
            res.CsNPin.PinNumber = (Cpu.Pin)61;
            res.CsNPin.PinMode = Port.ResistorMode.Disabled;
            res.ResetNPin.PinNumber = (Cpu.Pin)44;
            res.ResetNPin.PinMode = Port.ResistorMode.Disabled;

            res.LedRxPin.PinNumber = (Cpu.Pin)41; /// VK_MENU: MC9328MXL_GPIO::c_Port_B_15
            res.LedRxPin.PinMode = Port.ResistorMode.Disabled;
            res.LedTxPin.PinNumber = (Cpu.Pin)49; /// VK_BACK: pin = MC9328MXL_GPIO::c_Port_B_17;
            res.LedTxPin.PinMode = Port.ResistorMode.Disabled;

            res.SPI_mod = SPI.SPI_module.SPI1;
            return res;
        }
 /// <summary>
 /// Get default configuration
 /// </summary>
 /// <returns>default configuration</returns>
 public static CC2420PinConfig Default()
 {
     CC2420PinConfig res = new CC2420PinConfig();
     res.ChipPower.PinNumber = CC2420Pins.GPIO_PORT_CC2420_VREG_EN;
     res.ChipPower.PinMode = Port.ResistorMode.Disabled;
     res.FIFOPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_FIFO;
     res.FIFOPin.PinMode = Port.ResistorMode.Disabled;
     res.FIFOPPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_FIFOP;
     res.FIFOPPin.PinMode = Port.ResistorMode.Disabled;
     res.CCAPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_CCA;
     res.CCAPin.PinMode = Port.ResistorMode.Disabled;
     res.SFDPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_SFD;
     res.SFDPin.PinMode = Port.ResistorMode.Disabled;
     res.CsNPin.PinNumber = CC2420Pins.GPIO_PORT_PIN_39;
     res.CsNPin.PinMode = Port.ResistorMode.Disabled;
     res.ResetNPin.PinNumber = CC2420Pins.GPIO_PORT_CC2420_RESETN;
     res.ResetNPin.PinMode = Port.ResistorMode.Disabled;
     res.LedRxPin.PinNumber = CC2420Pins.GPIO_PORT_LED_RED;
     res.LedRxPin.PinMode = Port.ResistorMode.Disabled;
     res.LedTxPin.PinNumber = CC2420Pins.GPIO_PORT_LED_GREEN;
     res.LedTxPin.PinMode = Port.ResistorMode.Disabled;
     res.SPI_mod = SPI.SPI_module.SPI3;
     return res;
 }
Exemple #10
0
        private ushort _autoFCS;                   // automatic calculation of FCS
        #endregion

        #region Constructor/Destructor
        /// <summary>
        /// Create a new HALCC2420 object with configuration specified by a given CC2420PinConfig.
        /// </summary>
        /// <param name="pins">          The CC2420PinConfig for configuration     </param>
        internal HALCC2420(CC2420PinConfig pins)
        {
            bool Success = false;

            try
            {
                _spi = new SPI(new SPI.Configuration(pins.CsNPin.PinNumber,      // Chip select port
                                                        false,                        // Chip select active state
                                                        0,                            // Chip select setup time
                                                        0,                            // Chip select hold time
                                                        false,                        // Clock idle state
                                                        true,                         // Clock edge
                                                        8096,                          // Clock rate KHz (986KHz)
                                                        pins.SPI_mod                // SPI port connected to CC2420
                                                     )
                               );

                _fifoPort = new InputPort(pins.FIFOPin.PinNumber, false, pins.FIFOPin.PinMode);
                _fifopInterrupt = new InterruptPort(pins.FIFOPPin.PinNumber,
                                                      false,
                                                      pins.FIFOPPin.PinMode,
                                                      Port.InterruptMode.InterruptEdgeHigh
                                                    );
                _sfdInterrupt = new InterruptPort(pins.SFDPin.PinNumber,
                                                      false,
                                                      pins.SFDPin.PinMode,
                                                      Port.InterruptMode.InterruptEdgeLow
                                                    );

                _ccaPort = new InputPort(pins.CCAPin.PinNumber, false, pins.CCAPin.PinMode);
                _resetPort = new OutputPort(pins.ResetNPin.PinNumber, true);
                _powerPort = new OutputPort(pins.ChipPower.PinNumber, false);

                _addressFiltering = 0; //we start in promiscousmode
                _autoACK = 0;
                _panCoord = 0;
                _autoFCS = 0;

                Success = true;
            }
            finally
            {
                if (!Success) Dispose(true);
            }
        }