Exemplo n.º 1
0
        /// <summary>
        ///     Default constructor
        /// </summary>
        /// <param name="socket">The socket in which the USB UART click board is inserted into.</param>
        /// <param name="baudRate">The baud rate for serial commumications.</param>
        /// <param name="dataBits"></param>
        /// <param name="parity"></param>
        /// <param name="stopBitCount"></param>
        /// <param name="handShake"></param>
        public USBUARTClick(Hardware.Socket socket, BaudRate baudRate, Int32 dataBits = 8, UartParity parity = UartParity.None, UartStopBitCount stopBitCount = UartStopBitCount.One, UartHandshake handShake = UartHandshake.None)
        {
            _serial = UartController.FromName(socket.ComPort);
            _serial.SetActiveSettings((Int32)baudRate, dataBits, parity, stopBitCount, handShake);
            _serial.Enable();

            _serial.DataReceived  += Serial_DataReceived;
            _serial.ErrorReceived += Serial_ErrorReceived;

            _simpleSerial = new SimpleSerial(_serial);

            _powerPin = GpioController.GetDefault().OpenPin(socket.PwmPin);
            _powerPin.SetDriveMode(GpioPinDriveMode.InputPullUp);
            _powerPin.ValueChanged += PowerPin_ValueChanged;

            _sleepPin = GpioController.GetDefault().OpenPin(socket.Cs);
            _sleepPin.SetDriveMode(GpioPinDriveMode.Input);
            _sleepPin.ValueChanged += SleepPin_ValueChanged;
        }
Exemplo n.º 2
0
 public extern void SetActiveSettings(int baudRate, int dataBits, UartParity parity, UartStopBitCount stopBits, UartHandshake handshaking);
Exemplo n.º 3
0
 public extern void SetActiveSettings(int baudRate, int dataBits, UartParity parity, UartStopBitCount stopBits, UartHandshake handshaking, bool enableDePin, bool invertTxPolarity, bool invertRxPolarity, bool invertBinaryData, bool swapTxRxPin, bool invertDePolarity);