GetSpiPins() public method

public GetSpiPins ( SPI spi_mod, Cpu &msk, Cpu &miso, Cpu &mosi ) : void
spi_mod SPI
msk Cpu
miso Cpu
mosi Cpu
return void
Esempio n. 1
0
        private void Dispose(bool fDisposing)
        {
            if (!m_disposed)
            {
                try
                {
                    HardwareProvider hwProvider = HardwareProvider.HwProvider;

                    if (hwProvider != null)
                    {
                        Cpu.Pin msk;
                        Cpu.Pin miso;
                        Cpu.Pin mosi;

                        hwProvider.GetSpiPins(m_config.SPI_mod, out msk, out miso, out mosi);

                        if (msk != Cpu.Pin.GPIO_NONE)
                        {
                            Port.ReservePin(msk, false);
                        }

                        if (miso != Cpu.Pin.GPIO_NONE)
                        {
                            Port.ReservePin(miso, false);
                        }

                        if (mosi != Cpu.Pin.GPIO_NONE)
                        {
                            Port.ReservePin(mosi, false);
                        }
                    }

                    if (m_config.ChipSelect_Port != Cpu.Pin.GPIO_NONE)
                    {
                        m_cs.Dispose();
                    }
                }
                finally
                {
                    m_disposed = true;
                }
            }
        }
Esempio n. 2
0
        //--//

        public SPI(Configuration config)
        {
            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            if (hwProvider != null)
            {
                Cpu.Pin msk;
                Cpu.Pin miso;
                Cpu.Pin mosi;

                hwProvider.GetSpiPins(config.SPI_mod, out msk, out miso, out mosi);

                if (msk != Cpu.Pin.GPIO_NONE)
                {
                    Port.ReservePin(msk, true);
                }

                if (miso != Cpu.Pin.GPIO_NONE)
                {
                    Port.ReservePin(miso, true);
                }

                if (mosi != Cpu.Pin.GPIO_NONE)
                {
                    Port.ReservePin(mosi, true);
                }
            }

            //if (config.ChipSelect_Port != Cpu.Pin.GPIO_NONE)
            //{
            //    //m_cs = new OutputPort(config.ChipSelect_Port, !config.ChipSelect_ActiveState);
            //    Port.ReservePin(config.ChipSelect_Port, true);
            //}

            if (config.ChipSelect_Port != Cpu.Pin.GPIO_NONE)
            {
                Port.ReservePin(config.ChipSelect_Port, true);
            }

            m_config   = config;
            m_disposed = false;
        }