public NativeI2CBus(Socket socket, ushort address, int clockRateKhz, Module module) { if (_device == null) _device = new Hardware.I2CDevice(new Hardware.I2CDevice.Configuration(0, 50)); _configuration = new Hardware.I2CDevice.Configuration(address, clockRateKhz); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <remarks>This automatically checks that the socket supports Type A, and reserves the pin used. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="socket">The socket.</param> /// <param name="pin">The analog input pin to use.</param> /// <param name="module">The module using the socket, which can be null if unspecified.</param> public AnalogInput(Socket socket, Socket.Pin pin, Module module) { socket.EnsureTypeIsSupported('A', module); socket.ReservePin(pin, module); Cpu.AnalogChannel channel = Cpu.AnalogChannel.ANALOG_NONE; switch (pin) { case Socket.Pin.Three: channel = socket.AnalogInput3; break; case Socket.Pin.Four: channel = socket.AnalogInput4; break; case Socket.Pin.Five: channel = socket.AnalogInput5; break; } // native implementation is preferred to an indirected one if (channel == Cpu.AnalogChannel.ANALOG_NONE && socket.AnalogInputIndirector != null) Interface = socket.AnalogInputIndirector(socket, pin, module); else Interface = new NativeAnalogInput(socket, pin, module, channel); }
void EthernetJ11DNetworkUp(Module.NetworkModule sender, Module.NetworkModule.NetworkState state) { string message = "Network up. IP: " + _ethernetJ11D.Interface.NetworkInterface.IPAddress; Debug.Print(message); _loggerDisplay.ShowMessage(message, 10, NetworkStatusYPosition); OnNetworkUp(EventArgs.Empty); }
/// <summary> /// Creates an instance of <see cref="PwmOutput" /> for the given socket and pin number. /// </summary> /// <remarks>This automatically checks that the socket supports Type P, and reserves the pin. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="socket">The socket that supports pulse width modulation (PWM) output.</param> /// <param name="pin">The pin on the socket that supports PWM.</param> /// <param name="invert">Whether to invert the output voltage.</param> /// <param name="module">The module using this PWM output interface, which can be null if unspecified.</param> /// <returns>An instance of <see cref="PwmOutput" /> for the given socket and pin number.</returns> public static PwmOutput Create(Socket socket, Socket.Pin pin, bool invert, Module module) { socket.EnsureTypeIsSupported('P', module); socket.ReservePin(pin, module); Cpu.PWMChannel channel = Cpu.PWMChannel.PWM_NONE; switch (pin) { case Socket.Pin.Seven: channel = socket.PWM7; break; case Socket.Pin.Eight: channel = socket.PWM8; break; case Socket.Pin.Nine: channel = socket.PWM9; break; } // native implementation is preferred to an indirected one if (channel == Cpu.PWMChannel.PWM_NONE && socket.PwmOutputIndirector != null) return socket.PwmOutputIndirector(socket, pin, invert, module); else return new NativePwmOutput(socket, pin, invert, module, channel); }
public NativeSpi(Socket socket, Socket.SocketInterfaces.SpiConfiguration configuration, Socket.SocketInterfaces.SpiSharing sharing, Cpu.Pin chipSelectPin, Module module, Microsoft.SPOT.Hardware.SPI.SPI_module spiModule) { _hardwareInstance = GetAndUseInstance(socket, sharing, module, spiModule); _chipSelectPin = chipSelectPin; _configuration = ToNativeConfiguration(configuration, chipSelectPin, spiModule); if (_hardwareInstance.Interface == null && _configuration != null) _hardwareInstance.Interface = new Microsoft.SPOT.Hardware.SPI(_configuration); }
public NativeSpi(Socket socket, SpiConfiguration configuration, SpiSharing sharing, Hardware.Cpu.Pin chipSelectPin, Hardware.Cpu.Pin busyPin, Module module, Hardware.SPI.SPI_module spiModule) { _hardwareInstance = GetAndUseInstance(socket, sharing, module, spiModule); _chipSelectPin = chipSelectPin; _busyPin = busyPin; _configuration = ToNativeConfiguration(configuration, chipSelectPin, busyPin, spiModule); if (_hardwareInstance.Interface == null && _configuration != null) _hardwareInstance.Interface = new Hardware.SPI(_configuration); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the digital input interface.</param> /// <param name="pin">The pin used by the digital input interface.</param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this digital input interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="module">The module using this interface, which can be null if unspecified.</param> public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module) { this.port = new InputPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode); if (this.port == null) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Input functionality. Please try a different socket."); } }
public NativeDigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Cpu.Pin cpuPin) { if (cpuPin == Cpu.Pin.GPIO_NONE) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalInput"); } _port = new InputPort(cpuPin, glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode); }
public NativeDigitalIO(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module, Hardware.Cpu.Pin cpuPin) { if (cpuPin == Hardware.Cpu.Pin.GPIO_NONE) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalIO"); } _port = new Hardware.TristatePort(cpuPin, initialState, glitchFilterMode == GlitchFilterMode.On, (Hardware.Port.ResistorMode)resistorMode); }
public NativeDigitalOutput(Socket socket, Socket.Pin pin, bool initialState, Module module, Cpu.Pin cpuPin) { if (cpuPin == Cpu.Pin.GPIO_NONE) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw Socket.InvalidSocketException.FunctionalityException(socket, "DigitalOutput"); } _port = new OutputPort(cpuPin, initialState); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the digital output interface.</param> /// <param name="pin">The pin used by the digital output interface.</param> /// <param name="initialState">The initial state to place on the digital output interface port.</param> /// <param name="module">The module using this interface (which can be null if unspecified).</param> public DigitalOutput(Socket socket, Socket.Pin pin, bool initialState, Module module) { this.port = new OutputPort(socket.ReservePin(pin, module), initialState); if (this.port == null) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Digital Output functionality. Please try a different socket."); } }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <remarks>This automatically checks that the socket supports Type I, and reserves the SDA and SCL pins. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="address">The address for the I2C device.</param> /// <param name="clockRateKhz">The clock rate, in kHz, used when communicating with the I2C device.</param> /// <param name="socket">The socket for this I2C device interface.</param> /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param> public I2CBus(Socket socket, ushort address, int clockRateKhz, Module module) { socket.EnsureTypeIsSupported('I', module); if (socket.I2CBusIndirector != null) Interface = socket.I2CBusIndirector(socket, address, clockRateKhz, module); else Interface = new NativeI2CBus(socket, address, clockRateKhz, module); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the digital input interface.</param> /// <param name="pin">The pin used by the digital input interface.</param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this digital input interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="module">The module using this interface, which can be null if unspecified.</param> public DigitalInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module) { Cpu.Pin reservedPin = socket.ReservePin(pin, module); // native implementation is preferred to an indirected one if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalInputIndirector != null) Interface = socket.DigitalInputIndirector(socket, pin, glitchFilterMode, resistorMode, module); else Interface = new NativeDigitalInput(socket, pin, glitchFilterMode, resistorMode, module, reservedPin); }
/// <summary> /// Creates an instance of <see cref="InterruptInput" /> for the given socket and pin number. /// </summary> /// <param name="socket">The socket for the interrupt input interface.</param> /// <param name="pin">The pin used by the interrupt input interface.</param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this interrupt input interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="interruptMode"> /// A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions /// for the interface port to generate an interrupt. /// </param> /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param> /// <returns>An instance of <see cref="InterruptInput" /> for the given socket and pin number.</returns> public static InterruptInput Create(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module) { Cpu.Pin reservedPin = socket.ReservePin(pin, module); // native implementation is preferred to an indirected one if (reservedPin == Cpu.Pin.GPIO_NONE && socket.InterruptIndirector != null) return socket.InterruptIndirector(socket, pin, glitchFilterMode, resistorMode, interruptMode, module); else return new NativeInterruptInput(socket, pin, glitchFilterMode, resistorMode, interruptMode, module, reservedPin); }
/// <summary> /// Creates an instance of <see cref="DigitalIO" /> for the given socket and pin number. /// </summary> /// <param name="socket">The socket for the digital input/output interface.</param> /// <param name="pin">The pin used by the digital input/output interface.</param> /// <param name="initialState"> /// The initial state to set on the digital input/output interface port. /// This value becomes effective as soon as the port is enabled as an output port. /// </param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this digital input/output interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the digital input/output interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="module">The module using this interface, which can be null if unspecified.</param> /// <returns>An instance of <see cref="DigitalIO" /> for the given socket and pin number.</returns> public static DigitalIO Create(Socket socket, Socket.Pin pin, bool initialState, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, Module module) { Cpu.Pin reservedPin = socket.ReservePin(pin, module); // native implementation is preferred to an indirected one if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalIOIndirector != null) return socket.DigitalIOIndirector(socket, pin, initialState, glitchFilterMode, resistorMode, module); else return new NativeDigitalIO(socket, pin, initialState, glitchFilterMode, resistorMode, module, reservedPin); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the digital output interface.</param> /// <param name="pin">The pin used by the digital output interface.</param> /// <param name="initialState">The initial state to place on the digital output interface port.</param> /// <param name="module">The module using this interface (which can be null if unspecified).</param> public DigitalOutput(Socket socket, Socket.Pin pin, bool initialState, Module module) { Cpu.Pin reservedPin = socket.ReservePin(pin, module); // native implementation is preferred to an indirected one if (reservedPin == Cpu.Pin.GPIO_NONE && socket.DigitalOutputIndirector != null) Interface = socket.DigitalOutputIndirector(socket, pin, initialState, module); else Interface = new NativeDigitalOutput(socket, pin, initialState, module, reservedPin); }
public NativeI2CBus(Socket socket, ushort address, int clockRateKhz, Module module) { if (_device == null) { socket.ReservePin(Socket.Pin.Eight, module); socket.ReservePin(Socket.Pin.Nine, module); _device = new I2CDevice(new I2CDevice.Configuration(0, 50)); } _configuration = new I2CDevice.Configuration(address, clockRateKhz); }
public NativeAnalogInput(Socket socket, Socket.Pin pin, Module module, Cpu.AnalogChannel channel) { if (channel == Cpu.AnalogChannel.ANALOG_NONE) { Socket.InvalidSocketException.ThrowIfOutOfRange(pin, Socket.Pin.Three, Socket.Pin.Five, "AnalogInput", module); // this is a mainboard error that should not happen (we already check for it in SocketInterfaces.RegisterSocket) but just in case... throw Socket.InvalidSocketException.FunctionalityException(socket, "AnalogInput"); } _channel = channel; _socket = socket; }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <param name="socket">The socket for the interrupt input interface.</param> /// <param name="pin">The pin used by the interrupt input interface.</param> /// <param name="glitchFilterMode"> /// A value from the <see cref="GlitchFilterMode"/> enumeration that specifies /// whether to enable the glitch filter on this interrupt input interface. /// </param> /// <param name="resistorMode"> /// A value from the <see cref="ResistorMode"/> enumeration that establishes a default state for the interrupt input interface. N.B. .NET Gadgeteer mainboards are only required to support ResistorMode.PullUp on interruptable GPIOs and are never required to support ResistorMode.PullDown; consider putting the resistor on the module itself. /// </param> /// <param name="interruptMode"> /// A value from the <see cref="InterruptMode"/> enumeration that establishes the requisite conditions /// for the interface port to generate an interrupt. /// </param> /// <param name="module">The module using this interrupt input interface, which can be null if unspecified.</param> public InterruptInput(Socket socket, Socket.Pin pin, GlitchFilterMode glitchFilterMode, ResistorMode resistorMode, InterruptMode interruptMode, Module module) { this.port = new InterruptPort(socket.ReservePin(pin, module), glitchFilterMode == GlitchFilterMode.On, (Port.ResistorMode)resistorMode, (Port.InterruptMode)interruptMode); if (this.port == null) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Interrupt Input functionality. Please try a different socket."); } this.SynchronousUnsafeEventInvocation = false; this.port.OnInterrupt += new NativeEventHandler(this._port_OnInterrupt); }
public NativeAnalogOutput(Socket socket, Socket.Pin pin, Module module, Hardware.Cpu.AnalogOutputChannel channel) { if (channel == Hardware.Cpu.AnalogOutputChannel.ANALOG_OUTPUT_NONE) { Socket.InvalidSocketException.ThrowIfOutOfRange(pin, Socket.Pin.Five, Socket.Pin.Five, "AnalogOutput", module); // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw Socket.InvalidSocketException.FunctionalityException(socket, "AnalogOutput"); } _channel = channel; _socket = socket; }
private SPI(Socket socket, Configuration conf, Sharing sharingMode, Cpu.Pin chipSelectPin, Module module) { SPIInstance si = SPIInstance.GetInstance(socket, module); if (si.Users == 0) { socket.ReservePin(Socket.Pin.Seven, module); socket.ReservePin(Socket.Pin.Eight, module); socket.ReservePin(Socket.Pin.Nine, module); } else { if (si.SharingMode != Sharing.Shared) { throw new Exception("SPI bus " + si + " is already reserved, cannot instantiate it again"); } if (sharingMode == Sharing.Exclusive) { throw new Exception("SPI bus " + si + " is already shared among " + si.Users + " users, cannot instantiate it for exclusive use"); } } this.spiInstance = si; lock (this.spiInstance) { si.Users++; si.SharingMode = sharingMode; if (conf != null) { this.spiConfig = new Microsoft.SPOT.Hardware.SPI.Configuration( (Cpu.Pin)chipSelectPin, conf.ChipSelectActiveState, conf.ChipSelectSetupTime, conf.ChipSelectHoldTime, conf.ClockIdleState, conf.ClockEdge, conf.ClockRateKHz, si.SPIModule); if (!si.IsInitialised) { si.SpotSPI = new Microsoft.SPOT.Hardware.SPI(this.spiConfig); si.IsInitialised = true; } this.spotSPI = si.SpotSPI; } } }
/// <summary> /// Creates an instance of <see cref="AnalogOutput" /> for the given socket and pin number. /// </summary> /// <remarks>This automatically checks that the socket supports Type O, and reserves the pin. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="socket">The analog output capable socket.</param> /// <param name="pin">The pin to assign to the analog output.</param> /// <param name="module">The module using this analog output interface, which can be null if unspecified.</param> /// <returns>An instance of <see cref="AnalogOutput" /> for the given socket and pin number.</returns> public static AnalogOutput Create(Socket socket, Socket.Pin pin, Module module) { socket.EnsureTypeIsSupported('O', module); socket.ReservePin(pin, module); Cpu.AnalogOutputChannel channel = socket.AnalogOutput5; // native implementation is preferred to an indirected one if (channel == Cpu.AnalogOutputChannel.ANALOG_OUTPUT_NONE && socket.AnalogOutputIndirector != null) return socket.AnalogOutputIndirector(socket, pin, module); else return new NativeAnalogOutput(socket, pin, module, channel); }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <remarks>This automatically checks that the socket supports Type O, and reserves the pin. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="socket">The analog output capable socket.</param> /// <param name="pin">The pin to assign to the analog output.</param> /// <param name="module">The module using this analog output interface, which can be null if unspecified.</param> public AnalogOutput(Socket socket, Socket.Pin pin, Module module) { this.socket = socket; socket.EnsureTypeIsSupported('O', module); port = socket.AnalogOutput; if (port == null) { // this is a mainboard error but should not happen since we check for this, but it doesnt hurt to double-check throw new Socket.InvalidSocketException("Socket " + socket + " has an error with its Analog Output functionality. Please try a different socket."); } socket.ReservePin(pin, module); }
public NativePwmOutput(Socket socket, Socket.Pin pin, bool invert, Module module, Hardware.Cpu.PWMChannel channel) { if (channel == Hardware.Cpu.PWMChannel.PWM_NONE) { Socket.InvalidSocketException.ThrowIfOutOfRange(pin, Socket.Pin.Seven, Socket.Pin.Nine, "PWM", module); // this is a mainboard error that should not happen (we already check for it in SocketInterfaces.RegisterSocket) but just in case... throw Socket.InvalidSocketException.FunctionalityException(socket, "PWM"); } _channel = channel; _socket = socket; _invert = invert; }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <remarks>This automatically checks that the socket supports Type I, and reserves the SDA and SCL pins. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="address">The address for the I2C device.</param> /// <param name="clockRateKhz">The clock rate, in kHz, used when communicating with the I2C device.</param> /// <param name="socket">The socket for this I2C device interface.</param> /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param> public I2CBus(Socket socket, ushort address, int clockRateKhz, Module module) { socket.EnsureTypeIsSupported('I', module); lock (I2CLock) { if (device == null) { socket.ReservePin(Socket.Pin.Eight, module); socket.ReservePin(Socket.Pin.Nine, module); device = new I2CDevice(new I2CDevice.Configuration(0, 50)); } this.configuration = new I2CDevice.Configuration(address, clockRateKhz); } }
// Note: A constructor summary is auto-generated by the doc builder. /// <summary></summary> /// <remarks>This automatically checks that the socket supports Type X or Y as appropriate, and reserves the SDA and SCL pins. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="socket">The socket for this software I2C device interface.</param> /// <param name="address">The address of the I2C device.</param> /// <param name="clockRateKHz">The maximum clock speed supported by the I2C device.</param> /// <param name="sdaPin">The socket pin used for I2C data.</param> /// <param name="sclPin">The socket pin used for I2C clock.</param> /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param> public SoftwareI2CBus(Socket socket, Socket.Pin sdaPin, Socket.Pin sclPin, ushort address, int clockRateKHz, Module module) { this.address = (byte)address; this.clockRateKHz = clockRateKHz; // see if we've already reserved the pins and got instances of the ports, otherwise do that. string sdaPinString = socket.ToString() + "___" + sdaPin; if (!ReservedSdaPinPorts.Contains(sdaPinString)) { sdaPort = DigitalIOFactory.Create(socket, sdaPin, false, GlitchFilterMode.Off, ForceManagedPullUps ? ResistorMode.PullUp : ResistorMode.Disabled, module); ReservedSdaPinPorts.Add(sdaPinString, sdaPort); } else { sdaPort = (DigitalIO)ReservedSdaPinPorts[sdaPinString]; } string sclPinString = socket.ToString() + "___" + sclPin; if (!ReservedSclPinPorts.Contains(sclPinString)) { sclPort = DigitalIOFactory.Create(socket, sclPin, false, GlitchFilterMode.Off, ForceManagedPullUps ? ResistorMode.PullUp : ResistorMode.Disabled, module); ReservedSclPinPorts.Add(sclPinString, sclPort); } else { sclPort = (DigitalIO)ReservedSclPinPorts[sclPinString]; } this.socket = socket; this.sdaPin = sdaPin; this.sclPin = sclPin; lock (SoftwareI2CTimeoutList) { timeoutCount = -1; // Prevent the TimeoutHandler thread from watching this port for now SoftwareI2CTimeoutList.Add(this); if (timeoutThread == null) { threadExit = false; timeoutThread = new Thread(TimeoutHandler); timeoutThread.Start(); } } }
void ethernetENC28_NetworkUp(Module.NetworkModule sender, Module.NetworkModule.NetworkState state) { if (ethernetENC28.IsNetworkConnected) { ethernetENC28.UseThisNetworkInterface(); Debug.Print("*** Network connected!!! ***"); Debug.Print("IP:" + ethernetENC28.NetworkInterface.IPAddress); Debug.Print("Subnet: " + ethernetENC28.NetworkInterface.SubnetMask); Debug.Print(ethernetENC28.NetworkInterface.CableConnected ? "Cable Connected" : "No cable"); Debug.Print("DNS: " + ethernetENC28.NetworkInterface.DnsAddresses[0]); Debug.Print("Inter Type: " + ethernetENC28.NetworkInterface.NetworkInterfaceType.ToString()); Debug.Print("Gateway: " + ethernetENC28.NetworkInterface.GatewayAddress); Debug.Print(ethernetENC28.NetworkInterface.NetworkIsAvailable ? "Network available" : "*** Network is not available ***"); // Allow the network service to start when the network is up. _tinamousService.Start(); } }
/// <summary> /// Creates an instance of <see cref="I2CBus" /> for the given socket and pins. /// </summary> /// <remarks>This automatically checks that the socket supports Type I, and reserves the SDA and SCL pins. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="address">The address for the I2C device.</param> /// <param name="clockRateKhz">The clock rate, in kHz, used when communicating with the I2C device.</param> /// <param name="sdaPin">The SDA pin used by the I2C device.</param> /// <param name="sclPin">The SCL pin used by the I2C device.</param> /// <param name="socket">The socket for this I2C device interface.</param> /// <param name="module">The module using this I2C interface, which can be null if unspecified.</param> /// <returns>An instance of <see cref="I2CBus" /> for the given socket.</returns> public static I2CBus Create(Socket socket, ushort address, int clockRateKhz, Socket.Pin sdaPin, Socket.Pin sclPin, Module module) { // There is only one I²C module in .NET Micro Framework, so the NativeI2CBus would just go and use it // regardless of the requested pins, so we need to do the checks here instead. Cpu.Pin reservedSclPin = socket.ReservePin(sclPin, module); Cpu.Pin reservedSdaPin = socket.ReservePin(sdaPin, module); Cpu.Pin nativeSclPin, nativeSdaPin; HardwareProvider.HwProvider.GetI2CPins(out nativeSclPin, out nativeSdaPin); // native implementation is preferred to an indirected one if (reservedSdaPin == nativeSdaPin && reservedSclPin == nativeSclPin) return new NativeI2CBus(socket, address, clockRateKhz, module); else if (socket.I2CBusIndirector != null) return socket.I2CBusIndirector(socket, sdaPin, sclPin, address, clockRateKhz, module); else return new SoftwareI2CBus(socket, sdaPin, sclPin, address, clockRateKhz, module); }
/// <summary> /// Creates an instance of <see cref="Serial" /> for the given socket. /// </summary> /// <remarks>This automatically checks that the socket supports Type U, and reserves the pins. /// An exception will be thrown if there is a problem with these checks.</remarks> /// <param name="baudRate">The baud rate for the serial port.</param> /// <param name="parity">A value from the <see cref="SerialParity"/> enumeration that specifies /// the parity for the port.</param> /// <param name="stopBits">A value from the <see cref="SerialStopBits"/> enumeration that specifies /// the stop bits for the port.</param> /// <param name="dataBits">The number of data bits.</param> /// <param name="socket">The socket for this serial interface.</param> /// <param name="hardwareFlowControlRequirement">Specifies whether the module must use hardware flow control, will use hardware flow control if available, or does not use hardware flow control.</param> /// <param name="module">The module using this interface (which can be null if unspecified).</param> /// <returns>An instance of <see cref="Serial" /> for the given socket.</returns> public static Serial Create(Socket socket, int baudRate, SerialParity parity, SerialStopBits stopBits, int dataBits, HardwareFlowControl hardwareFlowControlRequirement, Module module) { bool hwFlowSupported = false; if (hardwareFlowControlRequirement == HardwareFlowControl.Required) socket.EnsureTypeIsSupported('K', module); else { hwFlowSupported = socket.SupportsType('K'); if (!hwFlowSupported) socket.EnsureTypeIsSupported('U', module); } socket.ReservePin(Socket.Pin.Four, module); socket.ReservePin(Socket.Pin.Five, module); if (hardwareFlowControlRequirement != HardwareFlowControl.NotRequired) { // must reserve hardware flow control pins even if not using them, since they are electrically connected. socket.ReservePin(Socket.Pin.Six, module); socket.ReservePin(Socket.Pin.Seven, module); } string portName = socket.SerialPortName; Serial instance; if ((portName == null || portName == "") && socket.SerialIndirector != null) instance = socket.SerialIndirector(socket, baudRate, (SerialParity)parity, (SerialStopBits)stopBits, dataBits, (HardwareFlowControl)hardwareFlowControlRequirement, module); else instance = new NativeSerial(socket, baudRate, (SerialParity)parity, (SerialStopBits)stopBits, dataBits, (HardwareFlowControl)hardwareFlowControlRequirement, module, portName, hwFlowSupported); instance.NewLine = "\n"; instance.ReadTimeout = System.Threading.Timeout.Infinite; instance.WriteTimeout = System.Threading.Timeout.Infinite; return instance; }
public NativeSerial(Socket socket, int baudRate, Socket.SocketInterfaces.SerialParity parity, Socket.SocketInterfaces.SerialStopBits stopBits, int dataBits, Socket.SocketInterfaces.HardwareFlowControl hwFlowRequirement, Module module, string portName, bool hwFlowSupported) { if (portName == null || portName == "") { // this is a mainboard error that should not happen (we already check for it in SocketInterfaces.RegisterSocket) but just in case... throw Socket.InvalidSocketException.FunctionalityException(socket, "Serial"); } _port = new SerialPort(portName, baudRate, (System.IO.Ports.Parity)parity, dataBits, (System.IO.Ports.StopBits)stopBits); if ((hwFlowRequirement != Socket.SocketInterfaces.HardwareFlowControl.NotRequired) && hwFlowSupported) { _port.Handshake = Handshake.RequestToSend; _hardwareFlowControl = true; } try { this.ReadTimeout = System.Threading.Timeout.Infinite; this.WriteTimeout = System.Threading.Timeout.Infinite; } catch { } }
public InteropI2CBus(GT.Socket socket, GT.Socket.Pin sdaPin, GT.Socket.Pin sclPin, ushort address, int clockRateKHz, GTM.Module module) { this.Address = address; this.ClockRateKHz = clockRateKHz; this.softwareBus = new SoftwareI2CBus(socket.CpuPins[(int)sclPin], socket.CpuPins[(int)sdaPin]); }
public InteropI2CBus(GT.Socket socket, GT.Socket.Pin sdaPin, GT.Socket.Pin sclPin, ushort address, int clockRateKHz, GTM.Module module) { this.sdaPin = socket.CpuPins[(int)sdaPin]; this.sclPin = socket.CpuPins[(int)sclPin]; this.Address = address; this.ClockRateKHz = clockRateKHz; }