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

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [examples/] [helloworld/] [src/] [helloworld.c] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
/*****************************************************************************
2
 * @file
3
 * @author   Sergey Khabarov
4
 * @brief    Firmware example.
5
 ****************************************************************************/
6
 
7
#include <inttypes.h>
8
#include <string.h>
9
#include <stdio.h>
10
#include "axi_maps.h"
11
 
12
extern char _end;
13
 
14
/**
15
 * @name sbrk
16
 * @brief Increase program data space.
17
 * @details Malloc and related functions depend on this.
18
 */
19
char *sbrk(int incr) {
20
    return &_end;
21
}
22
 
23
 
24
void print_uart(const char *buf, int sz) {
25
    uart_map *uart = (uart_map *)ADDR_NASTI_SLAVE_UART1;
26
    for (int i = 0; i < sz; i++) {
27
        while (uart->status & UART_STATUS_TX_FULL) {}
28
        uart->data = buf[i];
29
    }
30
}
31
 
32
void helloWorld() {
33
    char ss[256];
34
    int ss_len;
35
    ss_len = sprintf(ss, "Hellow World - %d!!!!\n", 1);
36
    print_uart(ss, ss_len);
37
}
38
 

powered by: WebSVN 2.1.0

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