mirror of
git://projects.qi-hardware.com/nn-usb-fpga.git
synced 2025-04-21 12:27:27 +03:00
Adding plasma example
This commit is contained in:
54
plasma/lib/no_os.c
Normal file
54
plasma/lib/no_os.c
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "plasma.h"
|
||||
|
||||
#define MemoryRead(A) (*(volatile unsigned int*)(A))
|
||||
#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V)
|
||||
|
||||
int putchar(int value)
|
||||
{
|
||||
while((MemoryRead(IRQ_STATUS) & IRQ_UART_WRITE_AVAILABLE) == 0)
|
||||
;
|
||||
MemoryWrite(UART_WRITE, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int puts(const char *string)
|
||||
{
|
||||
while(*string)
|
||||
{
|
||||
if(*string == '\n')
|
||||
putchar('\r');
|
||||
putchar(*string++);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_hex(unsigned long num)
|
||||
{
|
||||
long i;
|
||||
unsigned long j;
|
||||
for(i = 28; i >= 0; i -= 4)
|
||||
{
|
||||
j = (num >> i) & 0xf;
|
||||
if(j < 10)
|
||||
putchar('0' + j);
|
||||
else
|
||||
putchar('a' - 10 + j);
|
||||
}
|
||||
}
|
||||
|
||||
void OS_InterruptServiceRoutine(unsigned int status)
|
||||
{
|
||||
(void)status;
|
||||
putchar('I');
|
||||
}
|
||||
|
||||
int kbhit(void)
|
||||
{
|
||||
return MemoryRead(IRQ_STATUS) & IRQ_UART_READ_AVAILABLE;
|
||||
}
|
||||
|
||||
int getch(void)
|
||||
{
|
||||
while(!kbhit()) ;
|
||||
return MemoryRead(UART_READ);
|
||||
}
|
||||
Reference in New Issue
Block a user