void sprint(const char str[])
{
int j = 0;
uart_reg *puart;
puart = (uart_reg *) UART3_REG_BASE;
while (str[j] != '\0')
{
while (!(puart->UART_LSR & UART_TXFIFO_EMPTY))
;
puart->UART_THR = str[j];
j++;
}
}
and its header file
#ifndef __SPRINT_H
#define __SPRINT_H
#define UART3_REG_BASE 0x49020000
#define UART3_OP_MODE 0x3
#define UART3_B_MODE 0xBF
#define UART_RST_MASK 0x2
#define BAUD_115200 0x1A
#define UART_16X_MODE 0xFFFFFFF0
#define UART_TXFIFO_EMPTY 0x00000020
extern void sprint(const char str[]);
typedef struct {
unsigned int UART_THR;
unsigned int UART_IER;
unsigned int UART_FCR;
unsigned int UART_LCR;
unsigned int UART_MCR;
unsigned int UART_LSR;
unsigned int UART_MSR_TCR;
unsigned int UART_SPR_TLR;
unsigned int UART_MDR1;
unsigned int UART_MDR2;
unsigned int UART_SFLSR;
unsigned int UART_TXFLL;
unsigned int UART_RESUME;
unsigned int UART_TXFLH;
unsigned int UART_RXFLL;
unsigned int UART_SFREGL;
unsigned int UART_RXFLH;
unsigned int UART_SFREGH;
unsigned int UART_BLR;
unsigned int UART_ACREG;
unsigned int UART_SCR;
unsigned int UART_SSR;
unsigned int UART_EBLR;
unsigned int UART_SYSC;
unsigned int UART_SYSS;
unsigned int UART_WER;
unsigned int UART_CFPS;
} uart_reg;
#endif
No comments:
Post a Comment