Ejemplo n.º 1
0
        //--//

        public I2CDevice(Configuration config)
        {
            this.Config = config;

            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            if (hwProvider != null)
            {
                Cpu.Pin scl;
                Cpu.Pin sda;

                hwProvider.GetI2CPins(out scl, out sda);

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

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

            Initialize();

            m_disposed = false;
        }
Ejemplo n.º 2
0
        private void Dispose(bool fDisposing)
        {
            if (!m_disposed)
            {
                try
                {
                    HardwareProvider hwProvider = HardwareProvider.HwProvider;

                    if (hwProvider != null)
                    {
                        Cpu.Pin scl;
                        Cpu.Pin sda;

                        hwProvider.GetI2CPins(out scl, out sda);

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

                        if (sda != Cpu.Pin.GPIO_NONE)
                        {
                            Port.ReservePin(sda, false);
                        }
                    }
                }
                finally
                {
                    m_disposed = true;
                }
            }
        }
Ejemplo n.º 3
0
        private static void GetPorts()
        {
            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            if (hwProvider != null)
            {
                Cpu.Pin scl; //24 - B8
                Cpu.Pin sda; //25 - B9

                hwProvider.GetI2CPins(out scl, out sda);

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

                if (sda != Cpu.Pin.GPIO_NONE)
                {
                    Port.ReservePin(sda, true);
                }
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            HardwareProvider hwProvider = HardwareProvider.HwProvider;

            Debug.Print("Test GPIO Hardware provider functions ");

            while (true)
            {
                // GPIO
                int            GpioCnt = hwProvider.GetPinsCount();
                Cpu.PinUsage[] PinMap;
                int            size;
                hwProvider.GetPinsMap(out PinMap, out size);
                Debug.Print("------------------------------");

                Debug.Print("-------Pin Map ----------");
                for (int i = 0; i < GpioCnt; i++)
                {
                    Debug.Print("Pin Map - usage" + i + " : " + PinMap[i]);
                }
                Debug.Print("Pin count size " + size);

                Debug.Print("------------------------------");
                Debug.Print("---Pin Usage -------");

                Cpu.PinUsage OnePinUsage;
                for (int i = 0; i < GpioCnt; i++)
                {
                    OnePinUsage = hwProvider.GetPinsUsage((Cpu.Pin)i);
                    if (OnePinUsage != PinMap[i])
                    {
                        Debug.Print("ERRORR       **** ");
                    }
                    Debug.Print("cnt " + i + "usage" + OnePinUsage);
                }
                Debug.Print("------------------------------");

                Cpu.PinValidResistorMode OnePinResistorMode = hwProvider.GetSupportedResistorModes((Cpu.Pin) 0);
                Debug.Print("Reistor Mode " + OnePinResistorMode);

                Debug.Print("------------------------------");

                Cpu.PinValidInterruptMode OnePinIntMode = hwProvider.GetSupportedInterruptModes((Cpu.Pin) 0);
                Debug.Print("Interrupt Mode " + OnePinIntMode);
                Debug.Print("------------------------------");



                // serial
                Cpu.Pin rxPin;
                Cpu.Pin txPin;
                Cpu.Pin ctsPin;
                Cpu.Pin rtsPin;

                hwProvider.GetSerialPins("COM1", out rxPin, out txPin, out ctsPin, out rtsPin);
                Debug.Print("Serial Port : ");
                Debug.Print("Rx- " + rxPin);
                Debug.Print("Tx- " + txPin);
                Debug.Print("cts- " + ctsPin);
                Debug.Print("Rts- " + rtsPin);

                int SerialNo = hwProvider.GetSerialPortsCount();
                Debug.Print("Total Serial Port : " + SerialNo);

                System.IO.Ports.BaudRate[] StandardBR;
                hwProvider.GetSupportBaudRates(0, out StandardBR, out size);
                Debug.Print("#Standard Baudrate size" + size);
                for (int i = 0; i < size; i++)
                {
                    Debug.Print("Baudrate " + StandardBR[i]);
                }
                Debug.Print("------------------------------");



                bool SupportNonStandardBR = hwProvider.SupportsNonStandardBaudRate(0);
                Debug.Print("Support NonStandard Baudrate " + SupportNonStandardBR);

                uint br = 115200;
                Debug.Print(" support " + br);

                bool result;
                result = hwProvider.IsSupportedBaudRate(0, ref br);
                Debug.Print(" result " + result + "(" + br + ")");

                uint maxbr, minbr;
                hwProvider.GetBaudRateBoundary(0, out maxbr, out minbr);
                Debug.Print("Com 0 max br" + maxbr + " minBr: " + minbr);

                br     = maxbr + 1000;
                result = hwProvider.IsSupportedBaudRate(0, ref br);
                Debug.Print(" over max+100 result " + result + "(" + br + ")");

                // SPI
                Cpu.Pin msk;
                Cpu.Pin miso;
                Cpu.Pin mosi;

                hwProvider.GetSpiPins(SPI.SPI_module.SPI1, out msk, out miso, out mosi);
                Debug.Print("SPI Port : ");
                Debug.Print("msk- " + msk);
                Debug.Print("miso- " + miso);
                Debug.Print("mosi- " + mosi);


                int SpiNo = hwProvider.GetSpiPortsCount();
                Debug.Print("Total Spi Port : " + SpiNo);

                // I2C
                Cpu.Pin scl;
                Cpu.Pin sda;

                hwProvider.GetI2CPins(out scl, out sda);
                Debug.Print("I2C Port : ");
                Debug.Print("scl- " + scl);
                Debug.Print("sda- " + sda);


                // LCD
                int width, height, orientation, bpp;
                hwProvider.GetLCDMetrics(out width, out height, out bpp, out orientation);
                Debug.Print("width : " + height);
                Debug.Print("Length : " + height);
                Debug.Print("Bit Per Pixel : " + bpp);
                Debug.Print("orientatoin " + orientation);


                //get button -
                Debug.Print("Button Menu pin no " + hwProvider.GetButtonPins(Button.VK_MENU));
                Debug.Print("Button Select pin no " + hwProvider.GetButtonPins(Button.VK_SELECT));
                Debug.Print("Button Back pin no " + hwProvider.GetButtonPins(Button.VK_BACK));
                Debug.Print("Button Up pin no " + hwProvider.GetButtonPins(Button.VK_UP));
                Debug.Print("Button down pin no " + hwProvider.GetButtonPins(Button.VK_DOWN));
                Debug.Print("Button Left pin no " + hwProvider.GetButtonPins(Button.VK_LEFT));

                Debug.Print("Button right pin no " + hwProvider.GetButtonPins(Button.VK_RIGHT));
                Debug.Print("Button home pin no " + hwProvider.GetButtonPins(Button.VK_HOME));
                Debug.Print("Button appdef pin no " + hwProvider.GetButtonPins(Button.AppDefined1));
                Debug.Print("Button VK convert pin no " + hwProvider.GetButtonPins(Button.VK_CONVERT));



                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            Debug.Print("\n\n");
            Debug.Print("Hello world - i'm trying to find what are hidden to this firmware ");
            Debug.Print("\n\n");

            HardwareProvider provider = HardwareProvider.HwProvider;

            var cnt = provider.GetAnalogChannelsCount();

            for (int i = 0; i < cnt; i++)
            {
                var     channel    = (Cpu.AnalogChannel)i;
                Cpu.Pin pin        = provider.GetAnalogPinForChannel(channel);
                int[]   precisions = provider.GetAvailablePrecisionInBitsForChannel(channel);

                Debug.Print("AnalogChannel" + channel + ": pin=" + pin.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(pin) + "): precisions=" + precisions[0].ToString() + " bit");
            }
            Debug.Print("\n\n");

            cnt = 0;
            cnt = provider.GetAnalogOutputChannelsCount();
            for (int i = 0; i < cnt; i++)
            {
                var     channel    = (Cpu.AnalogOutputChannel)i;
                Cpu.Pin pin        = provider.GetAnalogOutputPinForChannel(channel);
                int[]   precisions = provider.GetAvailableAnalogOutputPrecisionInBitsForChannel(channel);

                Debug.Print("AnalogOutputChannel" + ": pin=" + pin.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(pin) + "): precisions=" + precisions[0].ToString() + " bit");
            }
            Debug.Print("\n\n");

            /* find pwm */
            cnt = 0;
            cnt = provider.GetPWMChannelsCount();
            for (int i = 0; i < cnt; i++)
            {
                var     channel = (Cpu.PWMChannel)i;
                Cpu.Pin pin     = provider.GetPwmPinForChannel(channel);
                Debug.Print("PWMChannel" + channel + ": pin=" + pin.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(pin) + ")");
            }
            Debug.Print("\n\n");

            /*find uart */
            cnt = 0;
            cnt = provider.GetSerialPortsCount();
            for (int i = 0; i < cnt; i++)
            {
                string  comPort = Serial.COM1.Substring(0, 3) + (i + 1);
                Cpu.Pin rxPin, txPin, ctsPin, rtsPin;
                provider.GetSerialPins(comPort, out rxPin, out txPin, out ctsPin, out rtsPin);
                uint max, min;
                provider.GetBaudRateBoundary(i, out max, out min);

                Debug.Print(comPort + ": (rx, tx, cts, rts)=(" +
                            STM32F411RE.Hardware.Pin.GetPinName(rxPin) + ", " +
                            STM32F411RE.Hardware.Pin.GetPinName(txPin) + ", " +
                            STM32F411RE.Hardware.Pin.GetPinName(ctsPin) + ", " +
                            STM32F411RE.Hardware.Pin.GetPinName(rtsPin) + ")" +
                            " baud=" + min + "..." + max);
            }
            Debug.Print("\n\n");
            /* find i2c */
            Cpu.Pin i2cscl, i2csda;
            provider.GetI2CPins(out i2cscl, out i2csda);
            Debug.Print("I2C module:(scl value=" + i2cscl.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(i2cscl) + "),sda=" + i2csda.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(i2csda) + "));");
            Debug.Print("\n\n");

            /* find SPI */
            var spicnt = provider.GetSpiPortsCount();

            for (int i = 0; i < spicnt; i++)
            {
                var module = (SPI.SPI_module)i;

                Cpu.Pin msk, miso, mosi;
                provider.GetSpiPins(module, out msk, out miso, out mosi);
                Debug.Print("SPI_module" + (i + 1) + ": (msk=" + msk.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(msk) + "), miso=" + miso.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(miso) + "), mosi=" + mosi.ToString() + "(" + STM32F411RE.Hardware.Pin.GetPinName(mosi) + "));");
            }
            Debug.Print("\n\n");

            UsbController[] controllers = UsbController.GetControllers();
            for (int i = 0; i < controllers.Length; i++)
            {
                Debug.Print("USB" + i + ": " + Convert(controllers[i].Status));
                Thread.Sleep(500);
            }

            Debug.Print("\n\n");
            Debug.Print("Finished check of hardware ");
        }