コード例 #1
0
 internal void OnDaisyLinkInterrupt(DaisyLinkModule sender)
 {
     DebugPrint("DaisyLink Module on socket " + sender.daisylink.Socket + " in position " + sender.PositionOnChain + " of " + sender.LengthOfChain + " has raised its interrupt.");
     if (onDaisyLinkInterrupt == null)
     {
         onDaisyLinkInterrupt = new DaisyLinkInterruptEventHandler(OnDaisyLinkInterrupt);
     }
     if (Program.CheckAndInvoke(DaisyLinkInterrupt, onDaisyLinkInterrupt, sender))
     {
         DaisyLinkInterrupt(sender);
     }
 }
コード例 #2
0
            private DaisyLink(Socket socket, DaisyLinkModule module)
            {
                Ready       = false;
                this.Socket = socket;

                this.ReservedCount = 0;
                this.NodeCount     = 0;

                daisyLinkBus = I2CBusFactory.Create(socket, defaultI2cAddress, 10, i2cDataPin, i2cClockPin, module);

                // The link pin (port) is initialized as an input.  It is only driven during initialization of the daisylinked modules.
                daisyLinkResetPort     = DigitalIOFactory.Create(socket, daisyLinkPin, false, GlitchFilterMode.Off, ResistorMode.PullUp, module);
                daisyLinkInterruptPort = null;
            }
コード例 #3
0
                private DaisyLink(Socket socket, DaisyLinkModule module) : base(socket, i2cDataPin, i2cClockPin, module)
                {
                    Ready       = false;
                    this.Socket = socket;

                    this.ReservedCount = 0;
                    this.NodeCount     = 0;

                    // The link pin (port) is initialized as an input.  It is only driven during initialization of the daisylinked modules.
                    // Setting the initial state to false insures that the pin will always drive low when Active is set to true.
                    daisyLinkCpuPin        = socket.ReservePin(daisyLinkPin, module);
                    daisyLinkResetPort     = new TristatePort(daisyLinkCpuPin, false, false, Port.ResistorMode.PullUp);
                    daisyLinkInterruptPort = null;
                }
コード例 #4
0
            /// <summary>
            /// Returns the DaisyLink instance for a given DaisyLink compatible socket.
            /// If this is the first call to this method for a given socket, it creates a new DaisyLink instance,
            /// which causes the chain to be initialised using the DaisyLink protocol.
            /// </summary>
            /// <param name="socket">The socket where the DaisyLink chain of modules is plugged in.</param>
            /// <param name="module">The daisylink module.</param>
            /// <returns>The DaisyLink instance for that socket</returns>
            public static DaisyLink GetDaisyLinkForSocket(Socket socket, DaisyLinkModule module)
            {
                lock (portLock)
                {
                    for (int i = 0; i < daisyLinkList.Count; i++)
                    {
                        if (((DaisyLink)daisyLinkList[i]).Socket == socket)
                        {
                            return((DaisyLink)daisyLinkList[i]);
                        }
                    }

                    DaisyLink daisylink;
                    daisylink = new DaisyLink(socket, module);
                    daisyLinkList.Add(daisylink);
                    daisylink.Initialize();
                    return(daisylink);
                }
            }
コード例 #5
0
                /// <summary>
                /// Returns the DaisyLink instance for a given DaisyLink compatible socket.
                /// If this is the first call to this method for a given socket, it creates a new DaisyLink instance,
                /// which causes the chain to be initialised using the DaisyLink protocol.
                /// </summary>
                /// <param name="socket">The socket where the DaisyLink chain of modules is plugged in.</param>
                /// <param name="module">The daisylink module.</param>
                /// <returns>The DaisyLink instance for that socket</returns>
                public static DaisyLink GetDaisyLinkForSocket(Socket socket, DaisyLinkModule module)
                {
                    lock (portLock)
                    {
                        foreach (DaisyLink dl in daisyLinkList)
                        {
                            if (dl.Socket == socket)
                            {
                                return(dl);
                            }
                        }

                        DaisyLink daisylink;
                        daisylink = new DaisyLink(socket, module);
                        daisyLinkList.Add(daisylink);
                        daisylink.Initialize();
                        return(daisylink);
                    }
                }
コード例 #6
0
 /// <summary>
 /// Reserves the next node address on this DaisyLink chain.
 /// </summary>
 /// <returns>The I2C address of the next node on this DaisyLink chain.</returns>
 /// <exception cref="System.Exception">The chain is empty, or there is no more space on the chain for another node.</exception>
 internal byte ReserveNextDaisyLinkNodeAddress(DaisyLinkModule moduleInstance)
 {
     lock (portLock)
     {
         if (ReservedCount >= this.NodeCount)
         {
             if (this.NodeCount == 0)
             {
                 throw new ApplicationException("No DaisyLink modules are detected on socket " + Socket);
             }
             else
             {
                 throw new ApplicationException("Attempting to initialize " + (ReservedCount + 1) + " modules on socket " + Socket + " but only " + NodeCount + " modules were found.");
             }
         }
         this.socketModuleList[ReservedCount] = moduleInstance;
         byte ret = (byte)(this.StartAddress + ReservedCount);
         this.ReservedCount++;
         return(ret);
     }
 }
コード例 #7
0
            private DaisyLink(Socket socket, DaisyLinkModule module)
            {
                Ready = false;
                this.Socket = socket;

                this.ReservedCount = 0;
                this.NodeCount = 0;

                daisyLinkBus = I2CBusFactory.Create(socket, defaultI2cAddress, 10, i2cDataPin, i2cClockPin, module);

                // The link pin (port) is initialized as an input.  It is only driven during initialization of the daisylinked modules.
                daisyLinkResetPort = DigitalIOFactory.Create(socket, daisyLinkPin, false, GlitchFilterMode.Off, ResistorMode.PullUp, module);
                daisyLinkInterruptPort = null;
            }
コード例 #8
0
 /// <summary>
 /// Reserves the next node address on this DaisyLink chain.
 /// </summary>
 /// <returns>The I2C address of the next node on this DaisyLink chain.</returns>
 /// <exception cref="System.Exception">The chain is empty, or there is no more space on the chain for another node.</exception>
 internal byte ReserveNextDaisyLinkNodeAddress(DaisyLinkModule moduleInstance)
 {
     lock (portLock)
     {
         if (ReservedCount >= this.NodeCount)
         {
             if (this.NodeCount == 0)
             {
                 throw new ApplicationException("No DaisyLink modules are detected on socket " + Socket);
             }
             else
             {
                 throw new ApplicationException("Attempting to initialize " + (ReservedCount + 1) + " modules on socket " + Socket + " but only " + NodeCount + " modules were found.");
             }
         }
         this.socketModuleList[ReservedCount] = moduleInstance;
         byte ret = (byte)(this.StartAddress + ReservedCount);
         this.ReservedCount++;
         return ret;
     }
 }
コード例 #9
0
            /// <summary>
            /// Returns the DaisyLink instance for a given DaisyLink compatible socket.  
            /// If this is the first call to this method for a given socket, it creates a new DaisyLink instance, 
            /// which causes the chain to be initialised using the DaisyLink protocol.
            /// </summary>
            /// <param name="socket">The socket where the DaisyLink chain of modules is plugged in.</param>
            /// <param name="module">The daisylink module.</param>
            /// <returns>The DaisyLink instance for that socket</returns>
            public static DaisyLink GetDaisyLinkForSocket(Socket socket, DaisyLinkModule module)
            {
                lock (portLock)
                {
                    for (int i = 0; i < daisyLinkList.Count; i++)
                    {
                        if (((DaisyLink)daisyLinkList[i]).Socket == socket)
                            return (DaisyLink)daisyLinkList[i];
                    }

                    DaisyLink daisylink;
                    daisylink = new DaisyLink(socket, module);
                    daisyLinkList.Add(daisylink);
                    daisylink.Initialize();
                    return daisylink;
                }
            }
コード例 #10
0
        internal void OnDaisyLinkInterrupt(DaisyLinkModule sender)
        {
            DebugPrint("DaisyLink Module on socket " + sender.daisylink.Socket + " in position " + sender.PositionOnChain + " of " + sender.LengthOfChain + " has raised its interrupt.");
            if (onDaisyLinkInterrupt == null) onDaisyLinkInterrupt = new DaisyLinkInterruptEventHandler(OnDaisyLinkInterrupt);
            if (Program.CheckAndInvoke(DaisyLinkInterrupt, onDaisyLinkInterrupt, sender))
            {
                DaisyLinkInterrupt(sender);
            }

        }
コード例 #11
0
            private DaisyLink(Socket socket, DaisyLinkModule module)
                : base(socket, i2cDataPin, i2cClockPin, module)
            {
                Ready = false;
                this.Socket = socket;

                this.ReservedCount = 0;
                this.NodeCount = 0;

                // The link pin (port) is initialized as an input.  It is only driven during initialization of the daisylinked modules.
                // Setting the initial state to false insures that the pin will always drive low when Active is set to true.
                //daisyLinkCpuPin = socket.ReservePin(daisyLinkPin, module);
                daisyLinkResetPort = new GTI.DigitalIO(socket, daisyLinkPin, false, GTI.GlitchFilterMode.Off, GTI.ResistorMode.PullUp, module);
                daisyLinkInterruptPort = null;
            }
コード例 #12
0
            /// <summary>
            /// Returns the DaisyLink instance for a given DaisyLink compatible socket.  
            /// If this is the first call to this method for a given socket, it creates a new DaisyLink instance, 
            /// which causes the chain to be initialised using the DaisyLink protocol.
            /// </summary>
            /// <param name="socket">The socket where the DaisyLink chain of modules is plugged in.</param>
            /// <param name="module">The daisylink module.</param>
            /// <returns>The DaisyLink instance for that socket</returns>
            public static DaisyLink GetDaisyLinkForSocket(Socket socket, DaisyLinkModule module)
            {
                lock (portLock)
                {
                    foreach (DaisyLink dl in daisyLinkList)
                    {
                        if (dl.Socket == socket)
                        {
                            return dl;
                        }
                    }

                    DaisyLink daisylink;
                    daisylink = new DaisyLink(socket, module);
                    daisyLinkList.Add(daisylink);
                    daisylink.Initialize();
                    return daisylink;
                }
            }