public ContactSensor(Cpu.Pin sensorPin) { this.sensorPin = sensorPin; sensorPort = new InterruptPort(sensorPin, false, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLevelLow); sensorPort.OnInterrupt += new NativeEventHandler(OnInterrupt); }
/// <summary> /// Sets up the relay board using the passed in /// pin map. If that is null, it will set up one /// based on pin0 == GPIO_PIN_D2 /// </summary> /// <param name="rawPinMap"></param> public RelayBoard(bool inverse = true, Cpu.Pin[] rawPinMap = null) { Inverse = inverse; if (null == rawPinMap) { rawPinMap = new Cpu.Pin[] { Pins.GPIO_PIN_D2, Pins.GPIO_PIN_D3, Pins.GPIO_PIN_D4, Pins.GPIO_PIN_D5, Pins.GPIO_PIN_D6, Pins.GPIO_PIN_D7, Pins.GPIO_PIN_D8, Pins.GPIO_PIN_D9 }; } MaxPin = rawPinMap.Length; // Build the outputs bool initalState = Inverse ? true : false; PinMap = new OutputPort[MaxPin]; for (int i = 0; i < MaxPin; i++) { PinMap[i] = new OutputPort(rawPinMap[i], initalState); } }
public Configuration( Cpu.Pin ChipSelect_Port, bool ChipSelect_ActiveState, uint ChipSelect_SetupTime, uint ChipSelect_HoldTime, bool Clock_IdleState, bool Clock_Edge, uint Clock_RateKHz, SPI_module SPI_mod, Cpu.Pin BusyPin, bool BusyPin_ActiveState ) { this.ChipSelect_Port = ChipSelect_Port; this.ChipSelect_ActiveState = ChipSelect_ActiveState; this.ChipSelect_SetupTime = ChipSelect_SetupTime; this.ChipSelect_HoldTime = ChipSelect_HoldTime; this.Clock_IdleState = Clock_IdleState; this.Clock_Edge = Clock_Edge; this.Clock_RateKHz = Clock_RateKHz; this.SPI_mod = SPI_mod; this.BusyPin = BusyPin; this.BusyPin_ActiveState = BusyPin_ActiveState; }
public HttpWiflyImpl(HttpImplementationClient.RequestReceivedDelegate requestReceived, int localPort, DeviceType deviceType, SPI.SPI_module spiModule, Cpu.Pin chipSelect) { m_requestReceived = requestReceived; LocalPort = localPort; this.m_spiModule = spiModule; this.m_chipSelect = chipSelect; }
//--// /// <summary> /// Build an instance of the PWM type /// </summary> /// <param name="channel">The channel to use</param> /// <param name="frequency_Hz">The frequency of the pulse in Hz</param> /// <param name="dutyCycle">The duty cycle of the pulse as a fraction of unity. Value should be between 0.0 and 1.0</param> /// <param name="invert">Whether the output should be inverted or not</param> public PWM(Cpu.PWMChannel channel, double frequency_Hz, double dutyCycle, bool invert) { HardwareProvider hwProvider = HardwareProvider.HwProvider; if(hwProvider == null) throw new InvalidOperationException(); m_pin = hwProvider.GetPwmPinForChannel(channel); m_channel = channel; //--// m_period = PeriodFromFrequency(frequency_Hz, out m_scale); m_duration = DurationFromDutyCycleAndPeriod(dutyCycle, m_period); m_invert = invert; //--// try { Init(); Commit(); Port.ReservePin(m_pin, true); } catch { Dispose(false); } }
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); }
/// <summary> /// Create a RGB LED Control. Supports On/off and blink manager /// </summary> /// <param name="red">From the SecretLabs.NETMF.Hardware.NetduinoPlus.Pins namespace</param> /// <param name="green">From the SecretLabs.NETMF.Hardware.NetduinoPlus.Pins namespace</param> /// <param name="blue">From the SecretLabs.NETMF.Hardware.NetduinoPlus.Pins namespace</param> /// <param name="name">Unique identifying name for command and control</param> public RgbLed(Cpu.Pin red, Cpu.Pin green, Cpu.Pin blue, string name) : base(name, "rgbled") { Cpu.Pin[] ledPins = new Cpu.Pin[] { red, green, blue }; for (int i = 0; i < 3; i++) { ls[i] = new ledState(); ls[i].led = new OutputPort(ledPins[i], false); } }
public NecRemoteControlDecoder(Cpu.Pin irReceiverPin) { _irReceiverPin = irReceiverPin; pulses = new long[200]; currentPulseIndex = 0; irReceiverPort = new InterruptPort(irReceiverPin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); irReceiverPort.OnInterrupt += new NativeEventHandler(irReceiverPort_OnInterrupt); irPulseTimeOutTimer = new Timer(new TimerCallback(IrPulseTimeOut), null, Timeout.Infinite, Timeout.Infinite); }
//--// /// <summary> /// Builds an instance of AnalogInput type for the specified channel /// </summary> /// <param name="channel">The channel for the AnalogInput</param> /// <param name="scale">A multiplicative factor to apply to the raw reading from the sensor</param> /// <param name="offset">A constant factor to add to the raw reading from the sensor</param> /// <param name="precisionInBits">The desired bit precision for the A/D conversion. A value of -1 indicates default precision.</param> public AnalogInput(Cpu.AnalogChannel channel, double scale, double offset, int precisionInBits) { m_channel = channel; HardwareProvider hwProvider = HardwareProvider.HwProvider; if(hwProvider == null) throw new InvalidOperationException(); m_pin = hwProvider.GetAnalogPinForChannel(channel); m_scale = scale; m_offset = offset; int[] availablePrecisions = hwProvider.GetAvailablePrecisionInBitsForChannel(channel); if(precisionInBits == -1) { if(availablePrecisions.Length == 0) throw new InvalidOperationException(); m_precision = availablePrecisions[0]; } else { bool found = false; foreach(int precision in availablePrecisions) { if(precisionInBits == precision) { m_precision = precision; found = true; break; } } if(!found) { throw new ArgumentException(); } } bool fReserved = false; try { lock(s_syncRoot) { fReserved = Port.ReservePin(m_pin, true); Initialize(channel, m_precision); } } catch { if (fReserved) { Port.ReservePin(m_pin, false); } throw; } }
/// <summary> /// Create a new instance of <see cref="LCDConfiguration"/> /// </summary> /// <param name="reset"></param> /// <param name="chipSelect"></param> /// <param name="RS"></param> /// <param name="backLight"></param> /// <param name="dataPins"></param> /// <param name="writePin"></param> /// <param name="readPin"></param> public LCDConfiguration(FEZ_Pin.Digital reset, FEZ_Pin.Digital chipSelect, FEZ_Pin.Digital RS, FEZ_Pin.Digital backLight, FEZ_Pin.Digital[] dataPins, FEZ_Pin.Digital writePin, FEZ_Pin.Digital readPin) { this.dataPins = new Cpu.Pin[8]; for (int i = 0; i < 8; i++) this.dataPins[i] = (Cpu.Pin)dataPins[i]; this.writePin = (Cpu.Pin)writePin; this.readPin = (Cpu.Pin)readPin; this.chipSelect = (Cpu.Pin)chipSelect; this.reset = (Cpu.Pin)reset; this.RS = (Cpu.Pin)RS; this.backLight = (Cpu.Pin)backLight; }
public static void Main() { // Monitor 6 distance sensors. If an analog input is not connected to a sensor, it must be connected to the Netduino's GND. var sensorPins = new Cpu.Pin[6]; sensorPins[0] = Pins.GPIO_PIN_A0; sensorPins[1] = Pins.GPIO_PIN_A1; sensorPins[2] = Pins.GPIO_PIN_A2; sensorPins[3] = Pins.GPIO_PIN_A3; sensorPins[4] = Pins.GPIO_PIN_A4; sensorPins[5] = Pins.GPIO_PIN_A5; var sensorArray = new SharpGP2Y0A21YK0F(sensorPins); sensorArray.Start(VoltageTrigger); Debug.Print("Started monitoring " + sensorPins.Length + " distance sensors"); uint seconds = 60; while (--seconds > 0) { Thread.Sleep(1000); } sensorArray.Dispose(); Debug.Print("Finished monitoring sensors"); }
static void TestPins() { Cpu.Pin[] pins = new Cpu.Pin[] { /*(Cpu.Pin)63, (Cpu.Pin)62, (Cpu.Pin)60, (Cpu.Pin)61, (Cpu.Pin)46, (Cpu.Pin)51, (Cpu.Pin)48, (Cpu.Pin)49*/ (Cpu.Pin)44, (Cpu.Pin)42, (Cpu.Pin)48, (Cpu.Pin)43, (Cpu.Pin)40, }; for (int i = 0; i < pins.Length; i++) { try { using (OutputPort port = new OutputPort(pins[i], false)) { port.Write(true); port.Write(false); port.Write(true); } } catch (Exception e) { Debug.Print(e.ToString()); } } }
public ADC124S101(Cpu.Pin chipSelectPin, float supplyVoltage, uint clockRateKHz, SPI.SPI_module spiModule) { if (chipSelectPin == Cpu.Pin.GPIO_NONE) throw new ArgumentOutOfRangeException("chipSelectPin"); if (supplyVoltage <= 0.0f) throw new ArgumentOutOfRangeException("supplyVoltage"); this.chipSelectPin = chipSelectPin; this.supplyVoltage = supplyVoltage; SPI.Configuration config = new SPI.Configuration( chipSelectPin, //chip select port false, //IC is accessed when chip select is low 1, //setup time 1 ms, is actually min 10 ns 1, //hold chip select 1 ms after transfer true, //clock line is high if device is not selected false, //data is sampled at falling edge of clock clockRateKHz, //possible 10000 - 20000 KHz spiModule //select SPI bus ); this.spi = new SPI(config); }
internal Fertilize_Pump(Cpu.Pin pin, int pumpNumber) { port = new OutputPort(pin, false); PumpNumber = pumpNumber; timer_CheckFertilizeJobs = new Timer(timer_CheckFertilizeJobs_Tick, null, 0, 30 * 1000); }
override public void GetI2CPins(out Cpu.Pin scl, out Cpu.Pin sda) { scl = Pins.GPIO_PIN_A_11; sda = Pins.GPIO_PIN_A_10; }
public LightSensor(Cpu.Pin pin) { sensor = new AnalogInput(pin); }
/// <summary> /// Binds to the Shell Core /// </summary> /// <param name="Shell">The ShellCore object</param> /// <param name="ONBOARD_SW1">Reference to the onboard button</param> /// <param name="ONBOARD_LED">Reference to the onboard LED</param> public static void Bind(ShellCore Shell, Cpu.Pin ONBOARD_SW1, Cpu.Pin ONBOARD_LED) { NetduinoPlus.ONBOARD_SW1 = ONBOARD_SW1; NetduinoPlus.ONBOARD_LED = ONBOARD_LED; Shell.OnCommandReceived += new ShellCore.CommandReceived(Shell_OnCommandReceived); }
public M8_TempMgr(Cpu.Pin owPin) { this._owPin = owPin; this._owBus = new OneWire(this._owPin); this._thermometers = new ArrayList(); this._getThermometers(); }
/// <summary> /// Dispose native resources /// </summary> public void Dispose() { Stop(); NativeDispose(); Port.ReservePin(_pin, false); _pin = Cpu.Pin.GPIO_NONE; _rawLevels = null; }
/// <summary> /// Release the output pin and native resources /// </summary> public void Dispose() { if (_pin != Cpu.Pin.GPIO_NONE) { Port.ReservePin(Pin, false); NativeDispose(); _pin = Cpu.Pin.GPIO_NONE; _levelTimes = null; } }
/// <summary> /// Initialize a new instance of the <see cref="Dht22Sensor"/> class. /// </summary> /// <param name="pin1">The identifier for the sensor's data bus port.</param> /// <param name="pin2">The identifier for the sensor's data bus port.</param> /// <param name="pullUp">The pull-up resistor type.</param> /// <remarks> /// The ports identified by <paramref name="pin1"/> and <paramref name="pin2"/> /// must be wired together. /// </remarks> public Dht22Sensor(Cpu.Pin pin1, Cpu.Pin pin2, Port.ResistorMode pullUp) : base(pin1, pin2, pullUp) { // This constructor is intentionally left blank. }
public void Begin(Cpu.Pin selectPin) { SelectPin = selectPin; InitPins(); InitSpi(); }
/// <summary> /// Create and start a temperature senor. Note temperature is cached for 10 minutes /// as temperature chip tends to heat up if read too often /// </summary> /// <param name="pin">From the SecretLabs.NETMF.Hardware.NetduinoPlus.Pins namespace</param> /// <param name="SampleRateMilliseconds">How often to measure in milliseconds or -1 to disable auto timed sensor readings</param> /// <param name="name">Unique identifying name for command and control</param> public SensorTemp(Cpu.Pin pin, int SampleRateMilliseconds, string name) : base("temp", "c", ValuesPerSample.One, SampleRateMilliseconds, name) { ds = new DS18B20(pin); StartMeasuring(); }
/// <summary> /// Maps GPIOs to Buttons that can be processed by /// Microsoft.SPOT.Presentation. /// </summary> /// <param name="source"></param> public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and // get back an InputProviderSite object which forwards the input // report to the input manager, which then places the input in the // staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's // ReportInput method. callback = new DispatcherOperationCallback(delegate(object report) { #if MF_FRAMEWORK_VERSION_V3_0 return(site.ReportInput((InputReport)report)); #else InputReportArgs args = (InputReportArgs)report; return(site.ReportInput(args.Device, args.Report)); #endif }); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider. HardwareProvider hwProvider = new HardwareProvider(); // Create the pins that are needed for the buttons. Default their // values for the emulator. Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins. If the left pin is // not set, assume none of the pins are set, and set the left pin // back to the default emulator value. if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) { pinLeft = Cpu.Pin.GPIO_Pin0; } else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as // input from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT, pinLeft), new ButtonPad(this, Button.VK_RIGHT, pinRight), new ButtonPad(this, Button.VK_UP, pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN, pinDown), }; this.buttons = buttons; }
public void Intialize(Cpu.Pin tPin = Cpu.Pin.GPIO_Pin13) { var input = new InterruptPort(tPin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); input.OnInterrupt += OnFanRotation; }
public Tachometer(Cpu.Pin pin, bool glitchFilter, ResistorMode resistorMode, InterruptMode interruptMode) : base(pin, glitchFilter, resistorMode, interruptMode) { }
public FEZCobraII_AnalogOut(Cpu.Pin pin) { this.pin = pin; }
public TempSensor(Cpu.Pin Input) { IOPin = Input; Triport = new TristatePort(IOPin, false, false, Port.ResistorMode.Disabled); }
public AX88796C(SPI.SPI_module spiBusID, Cpu.Pin csPinID, Cpu.Pin intPinID, Cpu.Pin resetPinID, Cpu.Pin wakeupPinID) { // create our chip select pin and SPI bus objects _chipSelectPin = new OutputPort(csPinID, true); _spi = new SPI(new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, 0, 0, false, true, 40000, spiBusID)); // wire up our interrupt, for future use _interruptPin = new InterruptPort(intPinID, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); _interruptPin.DisableInterrupt(); _interruptPin.OnInterrupt += _interruptPin_OnInterrupt; // save our reset pin ID (which we will use to control the reset pin a bit later on) _resetPinID = resetPinID; // save our wakeup pin ID (which we can use to create an InterruptPort right before we go to sleep) _wakeupPinID = wakeupPinID; // create our _sendPacketTxPagesFreeEvent _sendPacketTxPagesFreeEvent = new System.Threading.AutoResetEvent(false); // we are not initialized; we will initialize when we are started. _isInitialized = false; }
public Button(Cpu.Pin pin) { _port = new InterruptPort(pin, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); _port.OnInterrupt += port_OnInterrupt; }
// 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="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 SoftwareI2C(Socket socket, Socket.Pin sdaPin, Socket.Pin sclPin, Module module) { // first check the socket is compatible if (sclPin > Socket.Pin.Five || sdaPin > Socket.Pin.Five) { socket.EnsureTypeIsSupported('Y', module); } else { socket.EnsureTypeIsSupported(new char[] { 'X', 'Y' }, module); } if (ForceManagedSoftwareI2CImplementation || socket.NativeI2CWriteRead == null) { usingManaged = true; } // then 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)) { Cpu.Pin sdaCpuPin = socket.ReservePin(sdaPin, module); if (usingManaged) { sdaPort = new TristatePort(sdaCpuPin, false, false, ForceManagedPullUps ? Port.ResistorMode.PullUp : Port.ResistorMode.Disabled); } ReservedSdaPinPorts.Add(sdaPinString, sdaPort); } else { sdaPort = (TristatePort)ReservedSdaPinPorts[sdaPinString]; } string sclPinString = socket.ToString() + "___" + sclPin; if (!ReservedSclPinPorts.Contains(sclPinString)) { Cpu.Pin sclCpuPin = socket.ReservePin(sclPin, module); if (usingManaged) { sclPort = new TristatePort(sclCpuPin, false, false, ForceManagedPullUps ? Port.ResistorMode.PullUp : Port.ResistorMode.Disabled); } ReservedSclPinPorts.Add(sclPinString, sclPort); } else { sclPort = (TristatePort)ReservedSclPinPorts[sclPinString]; } this.socket = socket; this.sdaPin = sdaPin; this.sclPin = sclPin; if (usingManaged) { 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(new ThreadStart(TimeoutHandler)); timeoutThread.Start(); } } } }
public VariableLED(Cpu.Pin pin) : base(pin) { TurnOff(); }
public Button(Cpu.Pin pin) { this.pin = pin; this.port = new InterruptPort(pin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeBoth); this.port.OnInterrupt += new NativeEventHandler(port_OnInterrupt); }
public Led(Cpu.Pin pin) { port = new OutputPort(pin, true); _enabled = false; }
public DigitalElement(BaseShield.DigitalPorts port) { var pins = BaseShield.GetDigitalPins(port); Pin1 = pins[0]; Pin2 = pins[1]; }
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 ParallaxPingSimple(Cpu.Pin pin, int period, bool enabled) { _port = new TristatePort(pin, false, false, ResistorModes.Disabled); }
override public void GetI2CPins(out Cpu.Pin scl, out Cpu.Pin sda) { scl = Pins.GPIO_NONE; sda = Pins.GPIO_NONE; }
override public void GetSerialPins(string comPort, out Cpu.Pin rxPin, out Cpu.Pin txPin, out Cpu.Pin ctsPin, out Cpu.Pin rtsPin) { switch (comPort) { case "COM1": rxPin = Pins.GPIO_PIN_A_0; txPin = Pins.GPIO_PIN_A_1; ctsPin = Pins.GPIO_NONE; rtsPin = Pins.GPIO_NONE; break; case "COM2": rxPin = Pins.GPIO_PIN_A_27; txPin = Pins.GPIO_PIN_A_28; ctsPin = Pins.GPIO_NONE; rtsPin = Pins.GPIO_NONE; break; default: throw new NotSupportedException(); } }
//--// protected Port(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode) { this.Id = portId; GPIOManager.GetInstance().Export(portId); }
override public void GetSpiPins(SPI.SPI_module spi_mod, out Cpu.Pin msk, out Cpu.Pin miso, out Cpu.Pin mosi) { switch (spi_mod) { case SPI.SPI_module.SPI1: msk = Pins.GPIO_PIN_A_18; miso = Pins.GPIO_PIN_A_16; mosi = Pins.GPIO_PIN_A_17; break; default: throw new NotSupportedException(); } }
protected Port(Cpu.Pin portId, bool initialState) { this.Id = portId; GPIOManager.GetInstance().Export(portId); }
public static Device[] Scan(Cpu.Pin pin, params Family[] includeFamilies) { using (var op = new OutputPort(pin, false)) return(Scan(new OneWire(op), includeFamilies)); }
protected Port(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor) { this.Id = portId; throw new NotImplementedException(); }
/// <summary> /// Creates an I2C bus using the clock and data pins. /// </summary> /// <param name="clockPin">Clock pin.</param> /// <param name="dataPin">Data pin.</param> public SoftwareI2CBus(Cpu.Pin clockPin, Cpu.Pin dataPin) { if (Port.ReservePin(clockPin, true)) { if (Port.ReservePin(dataPin, true) == false) { Port.ReservePin(clockPin, false); throw new InvalidOperationException(); } } else throw new InvalidOperationException(); this.clockPin = clockPin; this.dataPin = dataPin; }
public Rfm9XDevice(SPI.SPI_module spiModule, Cpu.Pin chipSelect, Cpu.Pin resetPin, Cpu.Pin interruptPin) { this.Rfm9XLoraModem = new RegisterManager(spiModule, chipSelect); // Factory reset pin configuration ResetGpioPin = new OutputPort(resetPin, true); ResetGpioPin.Write(false); Thread.Sleep(10); ResetGpioPin.Write(true); Thread.Sleep(10); InterruptPin = new InterruptPort(interruptPin, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); InterruptPin.OnInterrupt += InterruptPin_OnInterrupt; Thread.Sleep(100); }
/// <summary> /// Initialize a new instance of <see cref="SignalGenerator"/> for the specified pin /// </summary> /// <param name="pin">Output pin</param> /// <param name="invert">Initial state applied to <paramref name="pin"/> when configured for output.</param> /// <exception cref="InvalidOperationException">Thrown if the specified pin is already reserved by another task</exception> public SignalGenerator(Cpu.Pin pin, bool invert = false) { if (pin == Cpu.Pin.GPIO_NONE) throw new ArgumentException("pin"); if (!Port.ReservePin(pin, true)) throw new InvalidOperationException("Pin already reserved for another task"); _signalInfo = new int[30]; _pin = pin; _invert = invert; NativeInitialize(); }
public InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor) : base(portId, glitchFilter, resistor, InterruptMode.InterruptNone) { GPIOManager.GetInstance().SetPortType(portId, PortType.INPUT); }
public Led(Cpu.Pin pin) { this.pin = pin; this.state = false; this.led = new OutputPort(pin, state); }
protected InputPort(Cpu.Pin portId, bool glitchFilter, ResistorMode resistor, InterruptMode interruptMode) : base(portId, glitchFilter, resistor, interruptMode) { GPIOManager.GetInstance().SetPortType(portId, PortType.INPUT); }
/// <summary> /// One and only constructor /// </summary> /// <param name="pwm">LIDAR-Lite PWM pin</param> /// <param name="enable">LIDAR-Lite enable pin</param> public LIDARLite(Cpu.Pin pwm, Cpu.Pin enable) { m_PWM = pwm; m_Enable = enable; }
public OutputPort(Cpu.Pin portId, bool initialState) : base(portId, initialState) { GPIOManager.GetInstance().SetPortType(portId, PortType.OUTPUT); }
// byte[] RegisterNum; // byte[] RegisterValue; // I2CDevice MyI2C; public Dial(Dials id, Cpu.Pin interruptPin, ushort i2cAddress) : base() { dialId = id; pinInt = interruptPin; //MyI2C = i2cdev; i2con = new I2CDevice.Configuration(i2cAddress, 100); // the pin will generate interrupt on high and low edges intPort = new InterruptPort(pinInt, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeHigh); // add an interrupt handler to the pin intPort.OnInterrupt += new NativeEventHandler(OnInterrupt); }
protected OutputPort(Cpu.Pin portId, bool initialState, bool glitchFilter, ResistorMode resistor) : base(portId, initialState, glitchFilter, resistor) { throw new NotImplementedException(); }
/// <summary> /// Initialize a new instance of <see cref="AnalogSignalGenerator"/> for the specified channel /// </summary> /// <param name="channel">The analog output channel</param> /// <param name="clockDivisor">The divisor applied to <see cref="Cpu.SlowClock"/> to define the sample clock</param> public AnalogSignalGenerator(Cpu.AnalogOutputChannel channel, int clockDivisor) { int channelCount = GetChannelCount(); if ((int)channel < 0 || (int)channel >= channelCount) throw new ArgumentOutOfRangeException("channel"); _channel = channel; _pin = GetPin(channel); if (!Port.ReservePin(_pin, true)) throw new InvalidOperationException("Pin already reserved for another task"); _signalInfo = new int[8]; ClockDivisor = (UInt16)clockDivisor; NativeInitialize(); }
/// <summary> /// Initialize a new instance of the <see cref="RHT03Sensor"/> class. /// </summary> /// <param name="pin1">The identifier for the sensor's data bus port.</param> /// <param name="pin2">The identifier for the sensor's data bus port.</param> /// <param name="pullUp">The pull-up resistor type.</param> /// <remarks> /// The ports identified by <paramref name="pin1"/> and <paramref name="pin2"/> /// must be wired together. /// </remarks> public RHT03Sensor(Cpu.Pin pin1, Cpu.Pin pin2, PullUpResistor pullUp) : base(pin1, pin2, pullUp) { }
/// <summary> /// Build an instance of the PWM type /// </summary> /// <param name="channel">The channel</param> /// <param name="period">The period of the pulse</param> /// <param name="duration">The duration of the pulse. The value should be a fraction of the period</param> /// <param name="scale">The scale factor for the period/duration (nS, uS, mS)</param> /// <param name="invert">Whether the output should be inverted or not</param> public PWM(Cpu.PWMChannel channel, uint period, uint duration, ScaleFactor scale, bool invert) { HardwareProvider hwProvider = HardwareProvider.HwProvider; if (hwProvider == null) throw new InvalidOperationException(); m_pin = hwProvider.GetPwmPinForChannel(channel); m_channel = channel; //--// m_period = period; m_duration = duration; m_scale = scale; m_invert = invert; //--// try { Init(); Commit(); Port.ReservePin(m_pin, true); } catch { Dispose(false); } }
public FEZCerbot_AnalogOut(Cpu.Pin pin) { this.pin = pin; }
static public bool ReservePin(Cpu.Pin pin, bool fReserve) { return(GPIOManager.GetInstance().ReservePin(pin, fReserve)); }
public SiliconStorageDevice(Cpu.Pin chipSelect, SPI.SPI_module spiModule) { _chipSelect = chipSelect; _spiModule = spiModule; }