|
Message
From: cvs at opencores.org<cvs@o...>
Date: Wed Mar 28 23:30:30 CEST 2007
Subject: [cvs-checkins] MODIFIED: openfire2 ...
Date: 00/07/03 28:23:30 Added: openfire2/sw/lib Makefile openfire.h uart1io.c Log: Revision Changes Path 1.1 openfire2/sw/lib/Makefile http://www.opencores.org/cvsweb.shtml/openfire2/sw/lib/Makefile?rev=1.1&content-type=text/x-cvsweb-markup Index: Makefile =================================================================== all: mb-gcc -c -mno-xl-soft-mul -c -Wa,-ahlms=uart1io.lst -o uart1io.o uart1io.c clean: -rm *.o -rm *.out -rm *.bin -rm *.v -rm *.map -rm *.lst -rm *.bak -rm *.srec -rm *.prom -rm *.rom 1.1 openfire2/sw/lib/openfire.h http://www.opencores.org/cvsweb.shtml/openfire2/sw/lib/openfire.h?rev=1.1&content-type=text/x-cvsweb-markup Index: openfire.h =================================================================== /* peripherals address and configurations */ /* openfire soc - 20070327 - a.anton */ #define SP3SK_GPIO 0x08000000 #define SP3SK_GPIO_SEGMENTS_N 0x000000FF #define SP3SK_GPIO_DRIVERS_N 0x00000F00 #define SP3SK_GPIO_PUSHBUTTONS 0x0000F000 #define SP3SK_GPIO_LEDS 0x00FF0000 #define SP3SK_GPIO_SWITCHES 0xFF000000 #define UARTS_STATUS_REGISTER 0x08000004 #define UART1_DATA_PRESENT 0x00000001 #define UART1_RX_HALF_FULL 0x00000002 #define UART1_RX_FULL 0x00000004 #define UART1_TX_HALF_FULL 0x00000008 #define UART1_TX_BUFFER_FULL 0x00000010 #define UART2_DATA_PRESENT 0x00010000 #define UART2_RX_HALF_FULL 0x00020000 #define UART2_RX_FULL 0x00040000 #define UART2_TX_HALF_FULL 0x00080000 #define UART2_TX_FULL 0x00100000 #define UART1_TXRX_DATA 0x08000008 #define UART2_TXRX_DATA 0x0800000C #define PROM_READER 0x08000010 #define PROM_DATA 0x000000FF #define PROM_REQUEST_SYNC 0x00000100 #define PROM_REQUEST_DATA 0x00000200 #define PROM_SYNCED 0x00000400 #define PROM_DATA_READY 0x00000800 #define TIMER1_PORT 0x08000014 #define TIMER1_VALUE 0x7FFFFFFF #define TIMER1_CONTROL 0x80000000 #define INTERRUPT_ENABLE 0x08000018 #define INTERRUPT_TIMER1 0x00000001 #define INTERRUPT_UART1_RX 0x00000002 #define INTERRUPT_UART2_RX 0x00000004 1.1 openfire2/sw/lib/uart1io.c http://www.opencores.org/cvsweb.shtml/openfire2/sw/lib/uart1io.c?rev=1.1&content-type=text/x-cvsweb-markup Index: uart1io.c =================================================================== /* libio functions for low level use with libc */ #include <sys/types.h> #include <sys/stat.h> #include <errno.h> #ifndef NULL #define NULL 0 #endif #define UARTS_STATUS_REGISTER 0x08000004 #define UART1_DATA_PRESENT 0x01 #define UART1_TX_BUFFER_FULL 0x10
#define UART1_TXRX_DATA 0x08000008
/* errno handling in a reentrant way *TODO?* */
int *__errno(void)
{
return &errno;
}
/* outbyte -- shove a byte out the serial port. We wait till the byte */
int outbyte( unsigned char c)
{
while ( *(unsigned char *)UARTS_STATUS_REGISTER & UART1_TX_BUFFER_FULL );
return (*(unsigned char*) UART1_TXRX_DATA = c);
}
/* inbyte -- get a byte from the serial port with eco and translates \r --> \n*/
unsigned char inbyte(void)
{
unsigned char c;
while ( (*(unsigned char *)UARTS_STATUS_REGISTER & UART1_DATA_PRESENT) == 0x0 );
c = *(unsigned char*) UART1_TXRX_DATA;
if(c == '\r') c = '\n';
outbyte(c);
return c;
}
/* havebyte() -- poll if a byte is available in the serial port */
int havebyte(void)
{
return *(unsigned char *)UARTS_STATUS_REGISTER & UART1_DATA_PRESENT;
}
|