/* File name: XMTR.c

*/

#include <stdio.h>
#include <math.h>

#define FOREVER 1

#define UART 0x500200
#define RBR (UART+0x00)
#define THR (UART+0x00)
#define DLL (UART+0x00)
#define DLM (UART+0x02)
#define IER (UART+0x02)
#define EFR (UART+0x02)
#define ISR (UART+0x04)
#define FCR (UART+0x04)
#define LCR (UART+0x06)
#define MCR (UART+0x08)
#define LSR (UART+0x0A)
#define MSR (UART+0x0C)
#define SPR (UART+0x0E)


unsigned FarPeek(unsigned long);
void     FarPoke(unsigned long, unsigned);

int RateLow = 6, RateHigh = 0;

void UART_Init(void)
{
        FarPoke(LCR, 0x80); // access baud rate registers
        FarPoke(DLM, RateHigh);
        FarPoke(DLL, RateLow);
        FarPoke(LCR, 0x07); // now access xmt and rcv regs
        return;
}

void TX_Put(char code)
{
    
    FarPoke(THR, code);              // send character code
    while ((FarPeek(LSR)&0x20)==0);  // wait for character to go
    return;
}
