Beispiel #1
0
        // #########################################################################
        // ### Port Manipulation Code
        // #########################################################################
        #region

        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Opens the port. Throws an exception on failure, including if the port is
        /// already open.
        ///
        /// This is really just doing the equivalent of a shell command
        ///    echo <gpioID> > /sys/class/gpio/export
        ///  after which the /sys/class/gpio/gpio<gpioID> directory should exist.
        ///  If it already exists the port is in use by someone else
        ///
        /// </summary>
        /// <history>
        ///    01 Dec 16  Cynic - Originally written
        /// </history>
        protected override void OpenPort()
        {
            // some tests
            if (GpioID == GpioEnum.GPIO_NONE)
            {
                throw new Exception("Cannot open port. Invalid port: " + GpioID.ToString());
            }
            // do the open
            System.IO.File.WriteAllText(RPIDefinitions.SYSFS_GPIODIR + RPIDefinitions.SYSFS_GPIOEXPORT, GpioUtils.GpioIDToString(GpioID));
        }
Beispiel #2
0
        // #########################################################################
        // ### Port Manipulation Code
        // #########################################################################
        #region

        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Opens the port.
        /// </summary>
        /// <history>
        ///    01 Dec 16  Cynic - Originally written
        /// </history>
        protected override void OpenPort()
        {
            // some tests
            if (GpioID == GpioEnum.GPIO_NONE)
            {
                throw new Exception("Cannot open port. Invalid port: " + GpioID.ToString());
            }
            // ensure the pinmux is set appropriately so we can use this port
            SetPinMuxModesForPort();
            // set this flag
            portIsOpen = true;
        }
Beispiel #3
0
        // #########################################################################
        // ### Port Manipulation Code
        // #########################################################################
        #region

        /// +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
        /// <summary>
        /// Opens the port.
        /// </summary>
        /// <history>
        ///    28 Aug 14 Cynic - Originally written
        /// </history>
        protected override void OpenPort()
        {
            // some tests
            if (GpioID == GpioEnum.GPIO_NONE)
            {
                throw new Exception("Cannot open port. Invalid port: " + GpioID.ToString());
            }
            // make sure the gpio bank is enabled
            if (MMDevMem.GPIOBankIsEnabled(GpioCfgObject) == false)
            {
                MMDevMem.EnableGPIOBank(GpioCfgObject);
            }
            // set our direction on this port
            MMDevMem.SetGpioDirection(GpioCfgObject, PortDirection());
            // set this flag
            portIsOpen = true;
        }