/// <summary> /// Initialization function for PL1167 /// /// </summary> /// <param name="ui8CS"></param> public void Initialize(string portName) { //init SPI busPirate = new BusPirate(new System.IO.Ports.SerialPort(portName, 115200)); busPirate.Open(); spiConnection = new Spi(busPirate); spiConnection.EnterMode(); spiConnection.SpeedMode = Spi.Speed.s250khz; spiConnection.ConfigProtocol(true, false, true, true); //Enable Power, PullUps // sample on END. Middle gives incorrect value spiConnection.ConfigPins(true, false, false, true); Thread.Sleep(1000); //Init PL1167 #if PL1167_EXPLICIT_RESET //spiConnection.AUX = true; //Thread.Sleep(50); spiConnection.AUX = false; Thread.Sleep(50); spiConnection.AUX = true; #endif // Delay for oscillator locking Thread.Sleep(10);//10 //pinMode(PL1167_PKT_PIN, INPUT); //attachInterrupt(0, vfISR, RISING); // Initialize Arduino interrupt InitRadioModule(); // Initialize registers of PL1167 Thread.Sleep(50); SetRadioChannel(channel); // Set RF channel ResetFIFOPointerReg(C_RXFIFOPOINTER); SetRXMode(); }
public PicProgrammer(SerialPort sp, bool LVP) { bp = new BusPirate(sp); bp.Open(); hw = new RawWire(bp); hw.EnterMode(); hw.ConfigProtocol(false, false, true); hw.ConfigPins(true, true, false, false); hw.HighSpeed = true; this.lvp = LVP; }
public PicProgrammer(SerialPort sp, bool LVP) { bp = new BusPirate(sp); bp.Open(); hw = new RawWire(bp); hw.EnterMode(); var ActiveOut = true; hw.ConfigProtocol(activeOutput: ActiveOut, threeWire: false, LSBfirst: true); hw.ConfigPins(power: true, pullups: !ActiveOut, aux: false, cs: true); hw.SpeedMode = RawWire.Speed.s400khz; this.lvp = LVP; }
private void Connect(object sender, EventArgs e) { butConnect.Enabled = false; try { //Connect to Bus Pirate sp = new SerialPort(); sp.PortName = comboSerial.SelectedItem.ToString(); bp = new BusPirate(sp); bp.Open(); i2c = new I2C(bp); i2c.EnterMode(); Thread.Sleep(200); //Setup 48 GPIOS! GPIOSetup(); //Setup MCP23017s PortExpanders[0] = new MCP23017((byte)Convert.ToInt32(comboU8Addr.SelectedItem)); PortExpanders[1] = new MCP23017((byte)Convert.ToInt32(comboU9Addr.SelectedItem)); PortExpanders[2] = new MCP23017((byte)Convert.ToInt32(comboU12Addr.SelectedItem)); foreach (GPIO g in GPIOs) PortExpanders[(int)g.PortExpander].Pins[g.Pin] = g.ToMCP23017Pin(); for (int i = 0; i < 3; i++) PortExpanders[i].Setup(i2c); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Stop); Disconnect(sender, e); return; } Connected = true; lblStatus.Text = "CONNECTED"; lblStatus.ForeColor = Color.Green; }