Ejemplo n.º 1
0
        public Uart(SerialControlRegister controlRegister)
        {
            SerialControlRegister = controlRegister;
            Transmitter           = new Transmitter(controlRegister);
            Receiver = new Receiver(controlRegister);

            BaudPulse += Transmitter.HandleBaudPulse;
            BaudPulse += Receiver.HandleBaudPulse;
            Transmitter.DataTransmitting += OnTransmitting;
            Transmitter.DataTransmitting += Receiver.HandleDataTransmitting;
        }
Ejemplo n.º 2
0
        public static bool ComputeParityBit(byte data, SerialControlRegister register)
        {
            // "The 9th bit is always sent. It is either the result of a parity calculation on the transmit
            // data byte or it is the value set in the parity select bit in the control register.
            // The choice is made by the parity enable bit in the control byte. For example :
            // If PAREN is '0', then the 9th bit will be whatever the state of PAREVEN is."
            if (!register.TransmitParityEnable)
            {
                return(register.ParityEven);
            }

            // If PAREN is '1' and PAREVEN is '0', then the 9th bit will be the result of an 'odd' parity calculation
            // on the transmit data byte.
            return(CalculateParity(data, register.ParityEven));
        }
Ejemplo n.º 3
0
 public Transmitter(SerialControlRegister register)
 {
     this.controlRegister = register;
 }
Ejemplo n.º 4
0
 public Receiver(SerialControlRegister register)
 {
     this.controlRegister = register;
 }