added second UART

Committed on the Free edition of March Hare Software CVSNT Server.
Upgrade to CVS Suite for more features and support:
http://march-hare.com/cvsnt/


git-svn-id: http://moon:8086/svn/vhdl/trunk@517 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2009-10-14 22:06:19 +00:00
parent 51ea254c82
commit 6ac97e7bf3
+34 -4
View File
@@ -2,6 +2,9 @@
#include <stdlib.h>
#include <string.h>
#include "irq.h"
#define CPU_FREQ_HZ 100000000
#include "libsys.h"
char buffer[16384];
@@ -27,15 +30,25 @@ void handler2(void)
void handler3(void)
{
volatile char *pUART_stat = (char*)sys_uart_stat;
volatile char *pUART_data = (char*)sys_uart_data;
volatile UINT32 *pUART0_stat = (UINT32*)sys_uart0_stat;
volatile UINT32 *pUART0_data = (UINT32*)sys_uart0_data;
volatile UINT32 *pUART1_stat = (UINT32*)sys_uart1_stat;
volatile UINT32 *pUART1_data = (UINT32*)sys_uart1_data;
while((0x10 & *pUART_stat))
while(0x200 & *pUART0_stat)
{
// sputs("w: "); print_word((int)pPtr_w); sputs("\n");
if (pPtr_w == &buffer[16383])
pPtr_w = buffer;
*(pPtr_w++) = *pUART_data;
*(pPtr_w++) = *pUART0_data;
}
while(0x200 & *pUART1_stat)
{
// sputs("w: "); print_word((int)pPtr_w); sputs("\n");
if (pPtr_w == &buffer[16383])
pPtr_w = buffer;
*(pPtr_w++) = *pUART1_data;
}
}
@@ -63,6 +76,12 @@ void handler7(void)
int main(void)
{
volatile UINT32 *pUART0_stat = (UINT32*)sys_uart0_stat;
volatile UINT32 *pUART1_stat = (UINT32*)sys_uart1_stat;
volatile UINT32 *pUART0_baud = (UINT32*)sys_uart0_baud;
volatile UINT32 *pUART1_baud = (UINT32*)sys_uart1_baud;
UART1_setbaud(460800);
printf("Hello\n");
memset(buffer, 0, sizeof(buffer));
pPtr_r = buffer;
@@ -76,6 +95,17 @@ int main(void)
interrupt_register(2, handler2);
interrupt_enable(2);
printf("UART0 Status = 0x%8.8X\n", *pUART0_stat);
printf("UART0 Baud = 0x%8.8X\n", *pUART0_baud);
printf("UART1 Status = 0x%8.8X\n", *pUART1_stat);
printf("UART1 Baud = 0x%8.8X\n", *pUART1_baud);
// enable RX interrupt
*pUART0_stat |= (1 << 6);
*pUART1_stat |= (1 << 6);
printf("UART0 Status = 0x%8.8X\n", *pUART0_stat);
printf("UART1 Status = 0x%8.8X\n", *pUART1_stat);
interrupt_register(3, handler3);
interrupt_enable(3);