tb remove
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "uart.h"
|
||||
|
||||
|
||||
#ifndef UART_BASE
|
||||
#error UART Base address not define!!!
|
||||
#endif
|
||||
|
||||
|
||||
volatile uint32_t *uart_rfifo = (uint32_t*)( UART_BASE + RX_FIFO );
|
||||
volatile uint32_t *uart_tfifo = (uint32_t*)( UART_BASE + TX_FIFO );
|
||||
volatile uint32_t *uart_status = (uint32_t*)( UART_BASE + STAT_REG );
|
||||
volatile uint32_t *uart_ctrl = (uint32_t*)( UART_BASE + CTRL_REG );
|
||||
|
||||
|
||||
int32_t uart_init()
|
||||
{
|
||||
//reset rx & tx fifo, disable interrupt
|
||||
(*uart_status) = 0x03;
|
||||
(*uart_status) = 0x00;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t uart_sendByte( uint8_t data )
|
||||
{
|
||||
uint64_t sent = (uint64_t)data << 32;
|
||||
#if(0)
|
||||
//wait unitl tx fifo not full
|
||||
while( ((*uart_status) & 0x08) != 0);
|
||||
(*(volatile uint64_t*)(UART_BASE)) = sent;
|
||||
#else
|
||||
(*(volatile uint64_t*)(0x60000000)) = sent;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
uint8_t uart_recByte()
|
||||
{
|
||||
//wait unitl rx fifo has data
|
||||
while( ((*uart_status) & 0x01) == 0);
|
||||
|
||||
return (uint8_t)(*uart_rfifo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int32_t print_uart(const char *str)
|
||||
{
|
||||
const char *cur = &str[0];
|
||||
while (*cur != '\0')
|
||||
{
|
||||
uart_sendByte((uint8_t)*cur);
|
||||
cur++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
#ifndef _UART_H_
|
||||
#define _UART_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define UART_BASE 0x20600000U
|
||||
|
||||
|
||||
|
||||
#define RX_FIFO 0x0000
|
||||
#define TX_FIFO 0x0004
|
||||
#define STAT_REG 0x0008
|
||||
#define CTRL_REG 0x000c
|
||||
|
||||
|
||||
extern int32_t uart_init();
|
||||
extern int32_t uart_sendByte( uint8_t data );
|
||||
extern uint8_t uart_recByte();
|
||||
extern int32_t print_uart(const char *str);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user