WiFly Shield
#1
Posted 21 October 2010 - 11:52 AM
#2
Posted 21 October 2010 - 06:56 PM
using System; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace WirelessTester { public class Program { private static SPI _spi; private const byte LCR = 0x03 << 3; private const byte DLL = 0x00 << 3; private const byte DLM = 0x01 << 3; private const byte EFR = 0x02 << 3; private const byte FCR = 0x02 << 3; private const byte SPR = 0x07 << 3; private const byte RHR = 0x00 << 3; private const byte LSR = 0x05 << 3; private const byte THR = 0x00 << 3; private const byte DivL = 0x60;//0x50; private const byte DivM = 0x00; private const byte DataFormat = 0x03; private const byte Flow = 0x10; public static void Main() { // write your code here OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); SPI.Configuration config = new SPI.Configuration( Pins.GPIO_PIN_D10, false, 0, 0, false, true, 10000, SPI.SPI_module.SPI1); _spi = new SPI(config); Thread.Sleep(1000); _spi.Write(new byte[] { LCR, 0x80 }); _spi.Write(new byte[] { DLL, DivL }); _spi.Write(new byte[] { DLM, DivM }); _spi.Write(new byte[] { LCR, 0xBF }); _spi.Write(new byte[] { EFR, Flow }); _spi.Write(new byte[] { LCR, DataFormat }); _spi.Write(new byte[] { FCR, 0x06 }); _spi.Write(new byte[] { FCR, 0x01 }); SpiUartWriteChar('H'); char c = (char) SpiUartReadByte(SPR); Debug.Print(c.ToString()); //SpiUartWriteLine(""); //SpiUartWriteLine("exit"); //Thread.Sleep(500); SpiUartFlush(); SpiUartWrite("$$$"); Debug.Print(SpiUartReadLine()); Thread.Sleep(500); led.Write(true); SpiUartWriteLine("reboot"); Thread.Sleep(3000); led.Write(false); SpiUartWrite("$$$"); Debug.Print(SpiUartReadLine()); Thread.Sleep(500); SpiUartWriteLine("set w a 3"); Debug.Print(SpiUartReadLine()); Thread.Sleep(500); SpiUartWriteLine("set w p sdgvsfdsf"); Debug.Print(SpiUartReadLine()); Thread.Sleep(500); SpiUartWriteLine("set i l 80"); Debug.Print(SpiUartReadLine()); Thread.Sleep(500); Thread.Sleep(100); SpiUartFlush(); Thread.Sleep(100); SpiUartWriteLine("join ManParadise"); Thread.Sleep(10000); Debug.Print(SpiUartReadLine()); SpiUartWriteLine("show c"); Debug.Print("Setup done"); while(true) { string s = SpiUartReadLine(); if (s != "") Debug.Print(s); } } private static void SpiUartFlush() { int i = 0; while (i < 1000) { if ((SpiUartReadByte(LSR) & 0x01) == 0x01) { SpiUartReadByte(RHR); } else { i++; } } } private static string SpiUartReadLine() { int i = 0; string data = ""; while(i < 1000) { if ((SpiUartReadByte(LSR) & 0x01) == 0x01) { byte b = SpiUartReadByte(RHR); //if (b == '\n' || b == 0xFF) // break; data += (char)b; } else { i++; } } return data; } private static void SpiUartWriteLine(string data_) { SpiUartWrite(data_ + "\n"); } private static void SpiUartWrite(string data_) { Debug.Print(data_); byte[] sendBuffer = new byte[data_.Length]; for (int i = 0; i < data_.Length; ++i) { sendBuffer[i] = (byte) data_[i]; } _spi.Write(new byte[] {THR, 0x01}); _spi.Write(sendBuffer); } private static void SpiUartWriteChar(char c_) { _spi.Write(new[] { SPR, (byte)c_ }); } private static byte SpiUartReadByte(byte addr_) { byte[] b = new byte[2]; _spi.WriteRead(new byte[] { (byte) (addr_ | 0x80) }, B); return b[1]; } } }
#3
Posted 21 October 2010 - 10:24 PM
#4
Posted 22 October 2010 - 05:10 PM
#5
Posted 24 October 2010 - 05:22 PM
* I know the SPI/Serial chip is outputting something because the activity light flashes.
* I know that the WiFly shield itself works because it works with my Arduino.
* I know that whatever activity I'm sending isn't working, because I can't get the chip to work!
I'm totally at a loss now really... I really want to make the shield work, but I just don't know what else to try. The current solution looks like I'll have to use the Arduino to act as a serial/WiFly bridge - a solution that takes up too much space, too much power and looks nasty!
Any help you guys can give would be massively appreciated.
Dan
#6
Posted 26 October 2010 - 09:10 AM
#7
Posted 26 October 2010 - 06:08 PM
#8
Posted 26 October 2010 - 07:47 PM
#9
Posted 04 November 2010 - 10:39 PM
#10
Posted 05 November 2010 - 01:07 AM
Contacted Sparkfun about availability and they think they'll have more shields ready in a week or two. Looking forward to getting this stuff running!
That's great news. We just got ours. Now to solder it together Then the fun/hard work begins...
Chris
#11
Posted 08 November 2010 - 04:01 PM
#12
Posted 08 November 2010 - 06:03 PM
Any luck so far?
For better or worse, it's going to be _quite_ the project. We're just starting to play with it. I'll post an update when we see first light on it...
Chris
#13
Posted 19 November 2010 - 03:50 PM
#14
Posted 22 November 2010 - 09:26 AM
For better or worse, it's going to be _quite_ the project. We're just starting to play with it. I'll post an update when we see first light on it...
Chris
Any update on this shield? Are the lights on?
Thanks,
Maurice Spronkers
#15
Posted 22 November 2010 - 05:25 PM
#16
Posted 22 November 2010 - 05:28 PM
Would it be safe to order one and know that it'll work with Netduino at some point?
We're at the "early experimental" phase right now. We'd love to support it. Working on it...
Chris
#17
Posted 24 November 2010 - 07:52 AM
#18
Posted 25 November 2010 - 11:09 PM
First, a word on the WiFly shield itself...
Power Requirements
The WiFly shield has its own power regulator (instead of using the 3.3V power regulator built into the Netduino). This may be due to the higher power requirements of the WiFly module (to prevent overloading the 3.3V power regulator on the Arduino).
The shield's power regulator feeds power off of the VIN line instead of the 5V pin. So this means that you need to provide external power to the Netduino when using this shield (or if you're up for modifying the shield, there are a number of options there too...removing the power regulator, current forwarding diodes, etc. etc.). A 7.5V-12V AC-DC power adapter, 9V battery, etc. should all work nicely.
SPI-to-UART bridge
Basically, there is a SPI-to-UART chip on the shield which converts SPI-based data to serial UART data...which is then sent to the WiFly module itself. If you hooked up a WiFly module to the Netduino itself directly (instead of through the shield), you could just use UART 2 (pins 2/3 with RTS/CTS)...but for the sake of compatibility we'll work with the SPI-to-UART bridge.
Driver
We've had some very preliminary success getting data to/from the WiFly module on the shield. There are a number of pieces to be built to create a good driver: SPI-to-UART bridge code, setup code, configuration code, communication code, etc.
From a performance standpoint, the best networking solution will be to use a Netduino Plus with a WiFi-to-Ethernet bridge. But let's see what we can do with WiFly (or the ZeroG module used on the AsyncLabs WiFi shields)...it would be awesome to build out a WiFi solution.
Chris
#19
Posted 26 November 2010 - 07:03 AM
#20
Posted 26 November 2010 - 07:11 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users