Beispiel #1
0
        /// <summary>
        /// Herited from the IDriver interface but not used by this module.
        /// </summary>
        /// <param name="resetMode">The reset mode :
        /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin</para></param>
        /// <returns>True if Reset has been acknowledged, false otherwise.</returns>
        /// <exception cref="System.NotImplementedException">Thrown because this module does not support hardware reset.</exception>
        public bool Reset(ResetModes resetMode)
        {
            if (resetMode != ResetModes.Soft)
            {
                throw new NotSupportedException();
            }
            if (PowerMode == PowerModes.Off)
            {
                return(false);
            }

            // Enable software reset
            while (!WriteEnabled)
            {
            }
            Hardware.SPIBus.Write(_spiConfig, new Byte[] { 0x66 });
            while (WriteInProgress())
            {
            }

            // Reset the chip
            while (!WriteEnabled)
            {
            }
            Hardware.SPIBus.Write(_spiConfig, new Byte[] { 0x99 });
            while (WriteInProgress())
            {
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Resets the SHT11 Click.
        /// </summary>
        /// <para>Soft reset, resets the interface, clears the status register to default values.</para>
        /// <para>Hard reset, If communication with the device is lost the following signal sequence will reset the serial interface while preserving the Status Registers.</para>
        /// <param name="resetMode">The reset mode either hard or soft. See <see cref="ResetModes"/> for more information.</param>
        /// <returns>True if the Reset was successful, otherwise false.</returns>
        /// <example>Example usage:
        /// <code language="C#">
        ///    while (true)
        ///    {
        ///        _sht11Click.ReadTemperatureHumidity();
        ///       Thread.Sleep(2000);
        ///    }
        /// </code>
        /// <code language="VB">
        ///     While True
        ///	        _sht11Click.ReadTemperatureHumidity()
        ///	        Thread.Sleep(2000)
        ///     End While
        /// </code>
        /// </example>
        public bool Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Soft)
            {
                var ack = SendCommand(Commands.SoftReset);

                // Wait a minimum 11 ms per datasheet
                Thread.Sleep(20);

                return(!ack); //True on error, False on success
            }

            if (!_dataPort.Active)
            {
                _dataPort.Active = true;                    // set data port as output
            }
            _dataPort.Write(false);

            // Toggle clock signal 9 times. See datasheet.
            for (int i = 0; i < 9; i++)
            {
                _clkPort.Write(true);
                _clkPort.Write(false);
            }
            _dataPort.Write(true);

            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// Resets the BMP180 module.
        /// </summary>
        /// <param name="resetMode">The reset mode, see <see cref="ResetModes"/> for more information.</param>
        /// <returns>True if the reset was successful  or otherwise false.</returns>
        /// <remarks>This module only supports <see cref="ResetModes.Soft"/> and will perform the same sequence as power on reset.</remarks>
        /// <exception cref="NotImplementedException">A <see cref="NotImplementedException"/> will be thrown is a <see cref="ResetModes.Hard"/> reset is attempted.</exception>
        /// <example>Example code to perform a Soft reset.
        /// <code language = "C#">
        /// _bmp180Sensor.Reset(ResetModes.Soft);
        /// </code>
        /// <code language = "VB">
        /// _bmp180Sensor.Reset(ResetModes.Soft)
        /// </code>
        /// </example>
        public bool Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Hard)
            {
                throw new NotImplementedException("Hard Reset is not available for this module. Only Soft Reset is implemented.");
            }

            _resetBusyPin.Write(true);

            //_isResetting = true; // We do not want to poll the sensor when it is resetting. Bad things could happen.

            WriteByte(0xE0, 0xB6);

            while (!IsConnected())
            {
                Thread.Sleep(5);
            }

            var returnValue = GetCalibrationData();

            //_isResetting = false;

            _resetBusyPin.Write(false);

            return(returnValue);
        }
Beispiel #4
0
        /// <summary>
        /// Resets the HDC1000 Click to default values for Temperature (14-Bit), Humidity (14-Bit), Acquisition Mode (Sequential) and disables the on-board heater.
        /// </summary>
        /// <param name="resetMode">The <see cref="ResetModes"/> used for the reset.</param>
        /// <returns>True if successful, otherwise false.</returns>
        /// <exception cref="NotSupportedException">A NotSupportedException will be thrown if this method is called with <see cref="ResetModes.Hard"/> as this module does not support hard resets.</exception>
        /// <example>Example usage:
        /// <code language = "C#">
        ///  Debug.Print("Reset " + _tempHumidity.Reset(ResetModes.Soft));
        /// </code>
        /// </example>
        public Boolean Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Hard)
            {
                throw new NotSupportedException("Hard resets are not supported by this module.");
            }

            WriteRegister(ConfigRegister, 0x10);
            return(ReadRegister(ConfigRegister)[0] == 0x10);
        }
Beispiel #5
0
        /// <summary>
        /// Resets the module
        /// </summary>
        /// <param name="resetMode">The reset mode :
        /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin</para></param>
        /// <returns></returns>
        public bool Reset(ResetModes resetMode)
        {
            _chipReady = false;
            _resetPort.Write(false);
            Thread.Sleep(200);
            _resetPort.Write(true);
            do
            {
                Thread.Sleep(20);
            } while (!_chipReady);

            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// Resets the module
        /// </summary>
        /// <example>
        /// <code language = "C#">
        /// _sensor.Reset(ResetModes.Hard);
        /// </code>
        /// </example>
        /// <exception cref="T:System.NotSupportedException">A NotSupportedException will be thrown as this module has no soft reset feature.</exception>
        public Boolean Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Soft)
            {
                throw new NotSupportedException("This module does not have a soft reset feature. Use a hard reset instead.");
            }

            _resetPin.Write(GpioPinValue.Low);
            Thread.Sleep(1);
            _resetPin.Write(GpioPinValue.High);

            return(true);
        }
Beispiel #7
0
        /// <summary>
        /// Resets the Altitude 3 Click and reloads the calibration data into OTP memory.
        /// </summary>
        /// <param name="resetMode">Th <see cref="ResetModes"/> to use.</param>
        /// <example>
        /// Example usage:
        /// <code language="C#">
        /// // Reset the Altitude 3 Click
        /// _sensor.Reset;
        /// </code>
        /// <code language="VB">
        /// ' Reset the Altitude 3 Click
        /// _sensor.Reset
        /// </code>
        /// </example>
        public Boolean Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Hard)
            {
                throw new NotSupportedException("This module does not support hard resets. Use a soft reset instead.");
            }

            WriteByte(Si7034_CMD_RESET);

            Thread.Sleep(2);

            return(true);
        }
Beispiel #8
0
        /// <summary>
        /// Resets the FMClick
        /// </summary>
        /// <param name="resetMode">The type of <see cref="ResetModes"/> to perform.</param>
        /// <exception cref="NotImplementedException">A NotImplementedException will be thrown is <see cref="ResetModes.Soft"/> is passed to the Setter of this Property.</exception>
        /// <example>Example usage:
        /// <code language = "C#">
        /// Debug.Print("Reset Successful? " +_fm.Reset(ResetModes.Hard));
        /// </code>
        /// <code language = "VB">
        /// Debug.Print("Reset Successful? " <![CDATA[&]]>_fm.Reset(ResetModes.Hard))
        /// </code>
        /// </example>
        public Boolean Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Soft)
            {
                throw new NotImplementedException("ResetModes.Soft not implemented for this module. Use ResetModes.Hard to reset this module.");
            }

            _resetPin.Write(GpioPinValue.Low);
            Thread.Sleep(10);

            ReadRegisters();
            var success = _shadowRegisters[REGISTER_TEST] == 0x000;

            PowerUp();
            return(success);
        }
Beispiel #9
0
        /// <summary>
        /// Resets the HTU21D Click.
        /// </summary>
        /// <param name="resetMode">The reset mode :
        /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin.</para></param>
        /// <returns>True if the reset was successful, or otherwise false.</returns>
        /// <exception cref="System.NotImplementedException">A NotImplementedException will be thrown if a <see cref="ResetModes.Hard"/> is attempted. Use <see cref="ResetModes.Soft"/> to reset this module.</exception>
        /// <example>Example usage:
        /// <code language = "C#">
        /// sensor.Reset(ResetModes.Soft);
        /// </code>
        /// <code language = "VB">
        /// sensor.Reset(ResetModes.Soft)
        /// </code>
        /// </example>
        public bool Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Hard)
            {
                throw new NotImplementedException("Hard resets are not supported. Use ResetModes.Soft to reset this module");
            }

            var buffer = new byte[1];

            buffer[0] = SOFT_RESET;
            var returnvalue = WriteRegister(buffer);

            Thread.Sleep(15);

            return(returnvalue);
        }
Beispiel #10
0
        /// <summary>
        /// Reset the CAN controller
        /// Hard reset = Pull down the RST pin
        /// Soft reset = Send Reset command to MCP2515 controller
        /// </summary>
        /// <param name="resetMode"></param>
        /// <returns>True, if MCP2515 is in configuration mode after reset</returns>
        public Boolean Reset(ResetModes resetMode)
        {
            switch (resetMode)
            {
            case ResetModes.Hard:
                _rst.Write(GpioPinValue.Low);
                Thread.Sleep(10);
                _rst.Write(GpioPinValue.High);
                break;

            case ResetModes.Soft:
                lock (_socket.LockSpi)
                {
                    _canSpi.Write(new Byte[] { cmdRESET });
                }
                Thread.Sleep(10);
                break;
            }
            return((ReadReg(regCANSTAT) >> 5) == configMode);
        }
Beispiel #11
0
        /// <summary>
        /// Resets the OLED-c Click.
        /// </summary>
        /// <example>Example usage:
        /// <code language = "C#">
        /// _oled.Reset(ResetModes.Soft);
        /// </code>
        /// <code language = "VB">
        /// _oled.Reset(ResetModes.Soft)
        /// </code>
        /// </example>
        /// <exception cref="NotSupportedException">A NotSupportedException will be thrown if an invalid reset method is passed as a parameter.</exception>
        public bool Reset(ResetModes resetMode)
        {
            switch (resetMode)
            {
            case ResetModes.Soft:
            case ResetModes.Hard:
            {
                _resetPin.Write(true);
                _dcPin.Write(true);
                _rwPin.Write(true);

                InitilizeOLED();
                break;
            }

            default:
            {
                throw new NotSupportedException("Unknown Reset method passed.");
            }
            }
            return(true);
        }
Beispiel #12
0
        /// <summary>
        /// Resets the module
        /// </summary>
        /// <param name="resetMode">The reset mode :
        /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin</para></param>
        /// <returns></returns>
        public bool Reset(ResetModes resetMode)
        {
            if (resetMode == ResetModes.Hard)
            {
                _reset.Write(false);
                Thread.Sleep(10);
                _reset.Write(true);
            }
            else
            {
                WriteRegister(Registers.CONTROL1, 0x02);
            }
            Thread.Sleep(1000);
            do
            {
                Thread.Sleep(100);
            } while ((ReadRegister(Registers.CONTROL1) & 0xF0) != 0xF0);

            WriteRegister(Registers.CONTROL2, 0x84);

            return(true);
        }
Beispiel #13
0
 /// <summary>
 /// Resets the module
 /// </summary>
 /// <param name="resetMode">The reset mode :
 /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin</para></param>
 /// <returns>True if Reset has been acknowledged, false otherwise.</returns>
 /// <exception cref="System.NotImplementedException">This module has no Reset feature.</exception>
 public bool Reset(ResetModes resetMode)
 {
     throw new NotImplementedException("Reset");
 }
Beispiel #14
0
 /// <summary>
 ///     Resets the CurrentClick Click.
 /// </summary>
 /// <param name="resetMode">The reset mode, see <see cref="ResetModes"/> for more information.</param>
 /// <remarks>
 /// This module has no Reset method, calling this method will throw an exception.
 /// </remarks>
 /// <exception cref="NotImplementedException">This module does not implement a reset method. Calling this method will throw a <see cref="NotImplementedException"/></exception>
 /// <example>None: This module does not support a Reset method.</example>
 public bool Reset(ResetModes resetMode)
 {
     throw new NotImplementedException("This module does not implement a Reset method.");
 }
Beispiel #15
0
 /// <summary>
 /// Resets the module
 /// </summary>
 /// <param name="resetMode">The reset mode :
 /// <para>SOFT reset : generally by sending a software command to the chip</para><para>HARD reset : generally by activating a special chip's pin</para></param>
 /// <exception cref="System.NotImplementedException">A NotImplementedException will be thrown as this module has no reset feature.</exception>
 public bool Reset(ResetModes resetMode)
 {
     throw new NotImplementedException("This module has no reset feature.");
 }
Beispiel #16
0
 /// <summary>
 /// Resets the module
 /// </summary>
 /// <param name="resetMode">The reset mode :
 /// <para>SOFT reset : generally by sending a software command to the chip</para>
 /// <para>HARD reset : generally by activating a special chip's pin</para></param>
 /// <exception cref="System.NotImplementedException"></exception>
 /// <example>None: Reset methods are not supported by this module.</example>
 public Boolean Reset(ResetModes resetMode)
 {
     throw new NotImplementedException();
 }