Hardware Design: SIE
Sign in or create your account | Project List | Help
Hardware Design: SIE Git Source Tree
Root/
| 1 | #include "plasma.h" |
| 2 | |
| 3 | #define MemoryRead(A) (*(volatile unsigned int*)(A)) |
| 4 | #define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V) |
| 5 | |
| 6 | int putchar(int value) |
| 7 | { |
| 8 | while((MemoryRead(IRQ_STATUS) & IRQ_UART_WRITE_AVAILABLE) == 0) |
| 9 | ; |
| 10 | MemoryWrite(UART_WRITE, value); |
| 11 | return 0; |
| 12 | } |
| 13 | |
| 14 | int puts(const char *string) |
| 15 | { |
| 16 | while(*string) |
| 17 | { |
| 18 | if(*string == '\n') |
| 19 | putchar('\r'); |
| 20 | putchar(*string++); |
| 21 | } |
| 22 | return 0; |
| 23 | } |
| 24 | |
| 25 | void print_hex(unsigned long num) |
| 26 | { |
| 27 | long i; |
| 28 | unsigned long j; |
| 29 | for(i = 28; i >= 0; i -= 4) |
| 30 | { |
| 31 | j = (num >> i) & 0xf; |
| 32 | if(j < 10) |
| 33 | putchar('0' + j); |
| 34 | else |
| 35 | putchar('a' - 10 + j); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | void OS_InterruptServiceRoutine(unsigned int status) |
| 40 | { |
| 41 | (void)status; |
| 42 | putchar('I'); |
| 43 | } |
| 44 | |
| 45 | int kbhit(void) |
| 46 | { |
| 47 | return MemoryRead(IRQ_STATUS) & IRQ_UART_READ_AVAILABLE; |
| 48 | } |
| 49 | |
| 50 | int getch(void) |
| 51 | { |
| 52 | while(!kbhit()) ; |
| 53 | return MemoryRead(UART_READ); |
| 54 | } |
| 55 |
Branches:
master
