static void SetupWiFi7Click_SC20100_MicroBus1() { var enablePin = GpioController.GetDefault().OpenPin(SC20100.GpioPin.PA8); enablePin.SetDriveMode(GpioPinDriveMode.Output); enablePin.Write(GpioPinValue.High); SpiNetworkCommunicationInterfaceSettings networkCommunicationInterfaceSettings = new SpiNetworkCommunicationInterfaceSettings(); var cs = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PD15); var settings = new GHIElectronics.TinyCLR.Devices.Spi.SpiConnectionSettings() { ChipSelectLine = cs, ClockFrequency = 4000000, Mode = GHIElectronics.TinyCLR.Devices.Spi.SpiMode.Mode0, ChipSelectType = GHIElectronics.TinyCLR.Devices.Spi.SpiChipSelectType.Gpio, ChipSelectHoldTime = TimeSpan.FromTicks(10), ChipSelectSetupTime = TimeSpan.FromTicks(10) }; networkCommunicationInterfaceSettings.SpiApiName = GHIElectronics.TinyCLR.Pins.SC20100.SpiBus.Spi3; networkCommunicationInterfaceSettings.GpioApiName = GHIElectronics.TinyCLR.Pins.SC20100.GpioPin.Id; networkCommunicationInterfaceSettings.SpiSettings = settings; networkCommunicationInterfaceSettings.InterruptPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20100.GpioPin.PB12); networkCommunicationInterfaceSettings.InterruptEdge = GpioPinEdge.FallingEdge; networkCommunicationInterfaceSettings.InterruptDriveMode = GpioPinDriveMode.InputPullUp; networkCommunicationInterfaceSettings.ResetPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20100.GpioPin.PB13); networkCommunicationInterfaceSettings.ResetActiveState = GpioPinValue.Low; var networkController = NetworkController.FromName ("GHIElectronics.TinyCLR.NativeApis.ATWINC15xx.NetworkController"); WiFiNetworkInterfaceSettings networkInterfaceSetting = new WiFiNetworkInterfaceSettings() { Ssid = wiFiSSID_1, Password = wiFiKey_1, }; networkInterfaceSetting.Address = new IPAddress(new byte[] { 192, 168, 1, 122 }); networkInterfaceSetting.SubnetMask = new IPAddress(new byte[] { 255, 255, 255, 0 }); networkInterfaceSetting.GatewayAddress = new IPAddress(new byte[] { 192, 168, 1, 1 }); networkInterfaceSetting.DnsAddresses = new IPAddress[] { new IPAddress(new byte[] { 75, 75, 75, 75 }), new IPAddress(new byte[] { 75, 75, 75, 76 }) }; //networkInterfaceSetting.MacAddress = new byte[] { 0x00, 0x4, 0x00, 0x00, 0x00, 0x00 }; networkInterfaceSetting.MacAddress = new byte[] { 0x4A, 0x28, 0x05, 0x2A, 0xA4, 0x0F }; networkInterfaceSetting.DhcpEnable = true; networkInterfaceSetting.DhcpEnable = true; networkInterfaceSetting.TlsEntropy = new byte[] { 1, 2, 3, 4 }; networkController.SetInterfaceSettings(networkInterfaceSetting); networkController.SetCommunicationInterfaceSettings (networkCommunicationInterfaceSettings); networkController.SetAsDefaultController(); networkController.NetworkAddressChanged += NetworkController_NetworkAddressChanged; networkController.NetworkLinkConnectedChanged += NetworkController_NetworkLinkConnectedChanged; networkController.Enable(); while (linkReady == false) { ; } // Network is ready to used }
private static void SetupEnc28_SC20260D_MicroBus1() { networkController = NetworkController.FromName ("GHIElectronics.TinyCLR.NativeApis.ENC28J60.NetworkController"); var networkInterfaceSetting = new EthernetNetworkInterfaceSettings(); var networkCommunicationInterfaceSettings = new SpiNetworkCommunicationInterfaceSettings(); var cs = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PG12); var settings = new GHIElectronics.TinyCLR.Devices.Spi.SpiConnectionSettings() { ChipSelectLine = cs, ClockFrequency = 4000000, Mode = GHIElectronics.TinyCLR.Devices.Spi.SpiMode.Mode0, ChipSelectType = GHIElectronics.TinyCLR.Devices.Spi.SpiChipSelectType.Gpio, ChipSelectHoldTime = TimeSpan.FromTicks(10), ChipSelectSetupTime = TimeSpan.FromTicks(10) }; networkCommunicationInterfaceSettings.SpiApiName = GHIElectronics.TinyCLR.Pins.SC20260.SpiBus.Spi3; networkCommunicationInterfaceSettings.GpioApiName = GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.Id; networkCommunicationInterfaceSettings.SpiSettings = settings; networkCommunicationInterfaceSettings.InterruptPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PG6); networkCommunicationInterfaceSettings.InterruptEdge = GpioPinEdge.FallingEdge; networkCommunicationInterfaceSettings.InterruptDriveMode = GpioPinDriveMode.InputPullUp; networkCommunicationInterfaceSettings.ResetPin = GHIElectronics.TinyCLR.Devices.Gpio.GpioController.GetDefault(). OpenPin(GHIElectronics.TinyCLR.Pins.SC20260.GpioPin.PI8); networkCommunicationInterfaceSettings.ResetActiveState = GpioPinValue.Low; networkInterfaceSetting.Address = new IPAddress(new byte[] { 192, 168, 1, 122 }); networkInterfaceSetting.SubnetMask = new IPAddress(new byte[] { 255, 255, 255, 0 }); networkInterfaceSetting.GatewayAddress = new IPAddress(new byte[] { 192, 168, 1, 1 }); networkInterfaceSetting.DnsAddresses = new IPAddress[] { new IPAddress(new byte[] { 75, 75, 75, 75 }), new IPAddress(new byte[] { 75, 75, 75, 76 }) }; networkInterfaceSetting.MacAddress = new byte[] { 0x00, 0x4, 0x00, 0x00, 0x00, 0x00 }; networkInterfaceSetting.DhcpEnable = true; networkInterfaceSetting.DhcpEnable = true; networkInterfaceSetting.TlsEntropy = new byte[] { 0, 1, 2, 3 }; networkController.SetInterfaceSettings(networkInterfaceSetting); networkController.SetCommunicationInterfaceSettings (networkCommunicationInterfaceSettings); networkController.SetAsDefaultController(); networkController.NetworkAddressChanged += NetworkController_NetworkAddressChanged; networkController.NetworkLinkConnectedChanged += NetworkController_NetworkLinkConnectedChanged; networkController.Enable(); while (linkReady == false) { ; } System.Diagnostics.Debug.WriteLine("Network is ready to use"); }