OpenCores
URL https://opencores.org/ocsvn/openfire2/openfire2/trunk

Subversion Repositories openfire2

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /openfire2/trunk/sw/lib
    from Rev 4 to Rev 6
    Reverse comparison

Rev 4 → Rev 6

/uart1_readline.c
0,0 → 1,12
#include "openfire.h"
 
void uart1_readline(char *buffer)
{
char tmp;
do
{
*(buffer++) = tmp = uart1_readchar();
uart1_printchar(tmp);
} while(tmp != 0x0 && tmp != '\n' && tmp != '\r');
}
 
/uart1_printline.c
0,0 → 1,6
#include "openfire.h"
 
void uart1_printline(char *txt)
{
while( *(unsigned char *)txt ) uart1_printchar( (unsigned char) *(txt++));
}
/__errno.c
0,0 → 1,9
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
 
/* errno handling in a reentrant way *TODO?* */
int *__errno(void)
{
return &errno;
}
/puthexstring.c
0,0 → 1,19
#include "openfire.h"
 
static char puthexchar(unsigned n)
{
n &= 0xF;
return n + (n < 10 ? '0' : 'A' - 10);
}
 
void puthexstring(char *string, unsigned number, unsigned size)
{
int n = size - 1;
while(number && n >= 0) // hex 2 ascii right to left
{
string[n] = puthexchar(number & 0xf);
number >>= 4;
n--;
}
while(n >= 0) string[n--] = '0'; // left padding with 0
}
/uart1_readchar.c
0,0 → 1,7
#include "openfire.h"
 
char uart1_readchar(void)
{
while( ((*(volatile unsigned char *) UARTS_STATUS_REGISTER) & UART1_DATA_PRESENT) == 0 ); // wait a received char
return *(char *) UART1_TXRX_DATA;
}
/uart1_printchar.c
0,0 → 1,8
#include "openfire.h"
 
// --------- uart #1 functions ----------
void uart1_printchar(unsigned char c)
{
while( (*(volatile unsigned char *) UARTS_STATUS_REGISTER) & UART1_TX_BUFFER_FULL ); // wait empty buffer
*(char *) UART1_TXRX_DATA = c;
}
/havebyte.c
0,0 → 1,8
#include "openfire.h"
 
/* havebyte() -- poll if a byte is available in the serial port */
int havebyte(void)
{
return (*(volatile unsigned char *)UARTS_STATUS_REGISTER) & UART1_DATA_PRESENT;
}
 
/inbyte.c
0,0 → 1,10
#include "openfire.h"
 
/* inbyte -- get a byte from the serial port with eco and translates \r --> \n */
unsigned char inbyte(void)
{
unsigned char c = uart1_readchar();
if(c == '\r') c = '\n';
outbyte(c);
return c;
}
/gethexstring.c
0,0 → 1,31
#include "openfire.h"
 
static unsigned gethexchar(char c)
{
if(c >= 'a') c = c - 'a' + '0' + 10;
else if(c >= 'A') c = c - 'A' + '0' + 10;
return c - '0';
}
 
static unsigned ishexdigit(char c)
{
return (c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'f') ||
(c >= 'A' && c <= 'F');
}
 
char *gethexstring(char *string, unsigned *value, unsigned maxdigits)
{
unsigned number = 0;
while( ishexdigit( string[0] ) && maxdigits > 0)
{
number <<= 4;
number |= gethexchar(string[0]);
string++;
maxdigits--;
}
*value = number;
return string;
}
/outbyte.c
0,0 → 1,7
#include "openfire.h"
 
/* outbyte -- shove a byte out the serial port. We wait till the byte */
int outbyte( unsigned char c)
{
uart1_printchar(c);
}
/Makefile
0,0 → 1,24
PRJ = io
SRCS = __errno.c inbyte.c outbyte.c havebyte.c uart1_printchar.c uart1_printline.c uart1_readchar.c \
uart1_readline.c gethexstring.c puthexstring.c
OBJS = $(SRCS:.c=.o)
 
lib$(PRJ): $(OBJS)
--rm lib$(PRJ).a
mb-ar q lib$(PRJ).a $(OBJS)
 
$(OBJS): $(SRCS)
mb-gcc -O2 -B. -mno-xl-soft-mul -c -Wa,-ahlms=$(@:.o=.lst) -o $@ $(@:.o=.c)
 
clean:
-rm *.o
-rm *.out
-rm *.bin
-rm *.v
-rm *.map
-rm *.lst
-rm *.bak
-rm *.srec
-rm *.prom
-rm *.rom
-rm *.a
/openfire.h
0,0 → 1,63
/* peripherals address and configurations */
/* basic i/o */
/* openfire soc - 20070327 - a.anton */
 
#ifndef __OPENFIRE_H
#define __OPENFIRE_H
 
#define SP3SK_GPIO 0x08000000L
 
#define SP3SK_GPIO_SEGMENTS_N 0x000000FFL
#define SP3SK_GPIO_DRIVERS_N 0x00000F00L
#define SP3SK_GPIO_PUSHBUTTONS 0x0000F000L
#define SP3SK_GPIO_LEDS 0x00FF0000L
#define SP3SK_GPIO_SWITCHES 0xFF000000L
 
#define UARTS_STATUS_REGISTER 0x08000004L
 
#define UART1_DATA_PRESENT 0x00000001L
#define UART1_RX_HALF_FULL 0x00000002L
#define UART1_RX_FULL 0x00000004L
#define UART1_TX_HALF_FULL 0x00000008L
#define UART1_TX_BUFFER_FULL 0x00000010L
 
#define UART2_DATA_PRESENT 0x00010000L
#define UART2_RX_HALF_FULL 0x00020000L
#define UART2_RX_FULL 0x00040000L
#define UART2_TX_HALF_FULL 0x00080000L
#define UART2_TX_FULL 0x00100000L
 
#define UART1_TXRX_DATA 0x08000008L
#define UART2_TXRX_DATA 0x0800000CL
 
#define PROM_READER 0x08000010L
#define PROM_DATA 0x000000FFL
#define PROM_REQUEST_SYNC 0x00000100L
#define PROM_REQUEST_DATA 0x00000200L
#define PROM_SYNCED 0x00000400L
#define PROM_DATA_READY 0x00000800L
 
#define TIMER1_PORT 0x08000014L
#define TIMER1_VALUE 0x7FFFFFFFL
#define TIMER1_CONTROL 0x80000000L
 
#define INTERRUPT_ENABLE 0x08000018L
#define INTERRUPT_TIMER1 0x00000001L
#define INTERRUPT_UART1_RX 0x00000002L
#define INTERRUPT_UART2_RX 0x00000004L
 
unsigned char inbyte(void);
int outbyte( unsigned char c);
int havebyte(void);
 
char *gethexstring(char *string, unsigned *value, unsigned maxdigits);
void puthexstring(char *string, unsigned number, unsigned size);
 
void uart1_printchar(unsigned char c);
void uart1_printline(char *txt);
char uart1_readchar(void);
void uart1_readline(char *buffer);
 
int *__errno(void);
 
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.