public static void Main() { count = 0; oled.Inital(); Thread.Sleep(100); oled.DisplayString("***"); globalSPIDevice.Config = nrf24L01PConfig; _radio.Initialize(); //TX // _radio.Configure(new byte[] { 138, 138, 138 }, 76, NRFDataRate.DR1Mbps); // _radio.SetAddress(AddressSlot.One, new byte[] { 0, 0, 1 }); //RX _radio.Configure(new byte[] { 0xF0, 0xF0, 0xE1 }, 76, NRFDataRate.DR1Mbps); _radio.SetAddress(AddressSlot.One, new byte[] { 0, 0, 2 }); _radio.OnDataReceived += _radio_OnDataReceived; _radio.Enable(); string outputinfo = "Listening on: " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Zero, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.One, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Two, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Three, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Four, 3)) + " | " + ByteArrayToHexString(_radio.GetAddress(AddressSlot.Five, 3)); Debug.Print(outputinfo); //TX // _timer = new Timer(TimerFire, null, new TimeSpan(0, 0, 0, 2), new TimeSpan(0, 0, 0,5)); globalSPIDevice.Config = oledSpiConfig; oled.DisplayString(outputinfo); Thread.Sleep(50); globalSPIDevice.Config = nrf24L01PConfig; Thread.Sleep(Timeout.Infinite); /* * * globalSPIDevice.Config = oledSpiConfig; * oled.DisplayString("Receiving ---"); * Thread.Sleep(100); * globalSPIDevice.Config = nrf24L01PConfig; */ }
static void Main(string[] args) { SPI SPIport = new Microsoft.SPOT.Hardware.SPI(new Microsoft.SPOT.Hardware.SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 2000, SPI.SPI_module.SPI1)); OutputPort nCE = new OutputPort(Cpu.Pin.GPIO_Pin2, true); InterruptPort nINT = new InterruptPort(Cpu.Pin.GPIO_Pin4, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); NRF24L01Plus n = new NRF24L01Plus(); n.Initialize(SPIport, nCE, nINT); byte[] address = n.GetAddress(AddressSlot.Zero, 5); Console.WriteLine("First Address: " + ByteArrayToHexString(address)); byte[] b = new byte[] { 0x04, 0x09, 0x02, 0x03, 0x04 }; n.SetAddress(AddressSlot.Zero, b, false); address = n.GetAddress(AddressSlot.Zero, 5); Console.WriteLine("Second Address: " + ByteArrayToHexString(address)); nCE.Dispose(); nINT.Dispose(); }