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; }
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)); }
public Transmitter(SerialControlRegister register) { this.controlRegister = register; }
public Receiver(SerialControlRegister register) { this.controlRegister = register; }