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

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [common/] [libsoc/] [src/] [hw_ion_mpu.c] - Blame information for rev 175

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 172 ja_rd
/**
2
    @file hw_ion_mpu.c
3
    @brief Hardware-dependent code for the default Ion MPU.
4
 
5
 
6
    This is the file that needs to be modified in order to use the library in
7
    an FPGA project other than the default one supplied with the Ion core.
8
 
9
    This code targets the 'default' MPU built around the Ion core. That is, the
10
    MPU built from vhdl template 'mips_mpu1_template.vhdl' which includes the
11
    CPU, cache module, a timer and a simple UART.
12
 
13
    @note The functionality of the functions is not entirely compatible to the
14
    libc standard. For example, neither getchar nor putchar update errno, etc.
15
*/
16
#include <stdint.h>
17
 
18
#include "hw.h"
19
 
20
/** Replacement for the standard C library putchar. */
21
int putchar(int c){
22
   while( !((*((volatile uint32_t *)UART_STATUS) ) & UART_TXRDY_MASK));
23
    *((volatile uint32_t *)UART_TX) = (uint32_t)c;
24
    return c;
25
}
26
 
27
/** Replacement for the standard C library getchar. */
28
int getchar(void){
29
    uint32_t uart;
30
 
31
    while(1){
32
        uart = *((volatile uint32_t *)UART_STATUS);
33
        if(uart & UART_RXRDY_MASK) break;
34
    }
35
    uart = *((volatile uint32_t *)UART_RX);
36
    uart = (uart >> 24) & 0x0ff;
37
    return (int)uart;
38
}

powered by: WebSVN 2.1.0

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