unit UartUtils;

// For the non P16 version only:
// ---- Use "UART_Set_Active(@UARTx_Read, @UARTx_Write, @UARTx_Data_Ready, @UARTx_Tx_Idle);" 
//      before using the routines of this unit --- //
     
// interface
     
procedure UART_Write_Line(var UartText : string[255]);
// sends "uart_text" to the selected Uart followed by CRLF

procedure UART_DumpBuffer(var Buffer: array[0..4095] of byte; Size: word);
// dumps the content of Buffer to selected Uart in hex format
// "Size" is the buffersize to be displayed


procedure Uart_Write_Byte(Variable: Byte);
// send the ascii representation of a byte Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_Byte(Variable: Byte);
// send the ascii representation of a byte Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Short(variable: short);
// send the ascii representation of a short Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_Short(variable: short);
// send the ascii representation of a short Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Byte_Hex(variable: byte);
// send the hex representation of a Byte Variable to selected Uart
// with one leading space and 2 hex digits

procedure Uart_Write_Line_Byte_Hex(variable: byte);
// send the hex representation of a Byte Variable to selected Uart
// with one leading space and 2 hex digits and followed by a CRLF


procedure Uart_Write_Word(Variable: Word);
// send the ascii representation of a word Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_Word(Variable: Word);
// send the ascii representation of a Word Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Integer(variable: Integer);
// send the ascii representation of an integer Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_Integer(variable: Integer);
// send the ascii representation of an integer Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Word_Hex(variable: Word);
// send the hex representation of a Word Variable to selected Uart
// with one leading space and 4 hex digits

procedure Uart_Write_Line_Word_Hex(variable: Word);
// send the hex representation of a Word Variable to selected Uart
// with one leading space and 4 hex digits and followed by a CRLF


procedure Uart_Write_DWord(Variable: DWord);
// send the ascii representation of a DWord Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_DWord(Variable: DWord);
// send the ascii representation of a DWord Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_LongInt(variable: LongInt);
// send the ascii representation of a LongInt Variable to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_LongInt(variable: LongInt);
// send the ascii representation of a LongInt Variable to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Real(variable: real);
// send the ascii representation of a real Variable to selected Uart
// with one leading space

procedure Uart_Write_Line_Real(variable: Real);
// send the ascii representation of a real Variable to selected Uart
// with one leading space and followed by a CRLF

procedure Uart_Write_DWord_Hex(variable: DWord);
// send the hex representation of a DWord Variable to selected Uart
// with one leading space and 8 hex digits

procedure Uart_Write_Line_DWord_Hex(variable: DWord);
// send the hex representation of a DWord Variable to selected Uart
// with one leading space and 8 hex digits and followed by a CRLF


// ------------------------ generic routines -----------------------------------

procedure Uart_Write_UnsInt(Variable: DWord);
// send the ascii representation of unsigned integer Variable (Byte, Word or DWord) to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_UnsInt(Variable: DWord);
// send the ascii representation of unsigned integer Variable (Byte, Word or DWord) to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_SignInt(Variable: LongInt);
// send the ascii representation of signed integer Variable (Short, Integer or LongInt) to selected Uart in decimal format
// with one leading space

procedure Uart_Write_Line_SignInt(Variable: LongInt);
// send the ascii representation of signed integer Variable (Short, Integer or LongInt) to selected Uart in decimal format
// with one leading space and followed by a CRLF

procedure Uart_Write_Int_Hex(Variable: DWord);
// send the ascii representation of integer Variable (Byte, Word or DWord) to selected Uart in hexadecimal format
// with one leading space and an even number of digits

procedure Uart_Write_Line_Int_Hex(Variable: DWord);
// send the ascii representation of Variable (Byte, Word or DWord) to selected Uart in hexadecimal format
// with one leading space and an even number of digits, followed by a CRLF

procedure UART_Write_CRLF;
// sends a CRLF sequence to selected Uart