Exemplo n.º 1
0
 public void Serialize(XmlWriter writer)
 {
     writer.WriteStartElement("task");
     writer.WriteAttributeString("type", "ai");
     writer.WriteAttributeString("dev", Device.Name);
     writer.WriteAttributeString("rate", ClockRate.ToString());
     writer.WriteEndElement();
 }
Exemplo n.º 2
0
 public override int GetHashCode()
 {
     var result = MimeType.GetHashCode() ^ PayloadType.GetHashCode() ^ ClockRate.GetHashCode();
     if (Parameters != null)
     {
         result = Parameters.DeepGetHashCode() ^ result;
     }
     return result;
 }
Exemplo n.º 3
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = SlotId;
         result = (result * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         result = (result * 397) ^ ClockRate.GetHashCode();
         result = (result * 397) ^ ChannelCount.GetHashCode();
         result = (result * 397) ^ SamplesPerFrame.GetHashCode();
         result = (result * 397) ^ BitsPerSample.GetHashCode();
         return(result);
     }
 }
Exemplo n.º 4
0
        public static void Setup(
                                    Cpu.Pin chipSelect,
                                    SPI.SPI_module spiModule,
                                    ClockRate clockRate,
                                    BaudRate baudRateIndex)
        {
            #region SPI Init
            try
            {
                // Initialise SDI
                SPI.Configuration spiConfig = new SPI.Configuration(
                    chipSelect, // Chip select pin
                    false,      // Active state
                    10,         // Setup time (ms)
                    10,         // Hold time (ms)
                    false,      // Clock idle (low)
                    true,       // Edge (rising)
                    2048,       // Clock rate (KHz)
                    spiModule); // SPI module

                spiInterface = new SPI(spiConfig);
            }
            catch (Exception e)
            {
                throw new Exception("SPI Init Error (" + e.Message + ")", e);
            }
            #endregion

            #region SPI to WiFly UART Init
            // Initialise the WiFly shield SPI<->UART chip

            // Convert the enum to a baud rate
            int baudRate = 1200;
            int depth = Convert.ToInt32(baudRateIndex.ToString()) - (int)BaudRate.BaudRate_1200;
            for (int i = 0; i < depth; i++)
            {
                baudRate += baudRate;
            }

            // Make DLL and DLH accessible
            if (clockRate == ClockRate.Xtal_12Mhz)
            {
                // I doesn't look like a 12MHz clock can do 921600bps
                if (baudRate == 921600)
                    baudRate = 460800;

                int divisor = 12288000 / (baudRate * 16);
                WriteRegister(Register.LCR, 0x80);  // 0x80 to program baudrate
                WriteRegister(Register.DLH, (byte)((divisor & 0x0000ff00) >> 8));
                WriteRegister(Register.DLL, (byte)((divisor & 0x000000ff) >> 0));
            }
            else
            {
                int divisor = 14745600 / (baudRate * 16);
                WriteRegister(Register.LCR, 0x80);  // 0x80 to program baudrate
                WriteRegister(Register.DLH, (byte)((divisor & 0x0000ff00) >> 8));
                WriteRegister(Register.DLL, (byte)((divisor & 0x000000ff) >> 0));
            }

            // Make EFR accessible
            WriteRegister(Register.LCR, 0xBF);  // access EFR register

            // Enable CTS, RTS, and Enhanced functions (IER[7:4], FCR[5:4], and MCR[7:5])
            WriteRegister(Register.EFR, (1 << 7) | (1 << 6) | (1 << 4));

            // Finally setup LCR
            WriteRegister(Register.LCR, 0x03);  // no parity, 1 stop bit, 8 data bit
            WriteRegister(Register.FCR, 0x06);  // reset TX and RX FIFO
            WriteRegister(Register.FCR, 0x01);  // enable FIFO mode

            // Perform read/write test of scratchpad register to check if UART is working
            WriteRegister(Register.SPR, 0x55);
            byte data = ReadRegister(Register.SPR);
            if (data != 0x55)
                throw new IOException("Failed to init SPI<->UART chip");

            #endregion

            // Enter command mode
            try
            {
                EnterCommandMode();
            }
            catch (Exception e)
            {
                throw new IOException(e.ToString());
            }

            // Turn off WiFi auto-joining
            SendCommand("set wlan join 0");
            WaitForResponse("AOK");

            SendCommand("save");
            WaitForResponse("Storing in config");

            // "reboot" to a known state
            Debug.Print("Rebooting WiFly-GSX");
            SendCommand("reboot");
            WaitForResponse("*Reboot*");
            WaitForResponse("*READY*");

            // Back to command mode
            try
            {
                EnterCommandMode();
            }
            catch (Exception e)
            {
                throw new IOException(e.ToString());
            }

            FlushRX();

            // Grab the version
            SendCommand("ver");
            WaitForResponse("ver");
            string version = "";
            while ((version = ReadResponse()) == "")
                ;
            string[] tokens = version.Split(' ');
            string[] split = tokens[2].Split('.');

            firmwareVersion = new Version(Convert.ToInt32(split[0]), Convert.ToInt32(split[1].TrimEnd(',')));
            Debug.Print("WiFly firmware version: " + firmwareVersion.Major.ToString() + "." + firmwareVersion.Minor.ToString());

            // Exit command mode
            SendCommand("exit");
            WaitForResponse("EXIT");
        }
Exemplo n.º 5
0
 public ChannelConfig(ClockRate clockRate, byte latencyTimer, ChannelOptions options)
 {
     this.clockRate    = clockRate;
     this.latencyTimer = latencyTimer;
     this.options      = options;
 }