Skip to content

Commit

Permalink
⚠️ Software libraries cleanup (#1186)
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting authored Feb 20, 2025
2 parents 1f17db9 + ae8d57e commit 54581c5
Show file tree
Hide file tree
Showing 40 changed files with 263 additions and 311 deletions.
4 changes: 4 additions & 0 deletions docs/datasheet/software.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ The NEORV32 HAL consists of the following files.
| `neorv32_newlib.c` | - | Platform-specific system calls for _newlib_
|=======================

.Defines and Macros
[TIP]
Macros and defines provides by the NEORV32 software framework are written in capital letters.

.Core Libraries Documentation
[TIP]
The Doxygen-based documentation of the software framework including all core libraries is available online at
Expand Down
14 changes: 12 additions & 2 deletions sw/example/demo_blink_led/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand All @@ -15,6 +15,16 @@
#include <neorv32.h>


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* Main function; shows an incrementing 8-bit counter on GPIO.output(7:0).
*
Expand All @@ -31,7 +41,7 @@ int main() {

while (1) {
neorv32_gpio_port_set(cnt++ & 0xFF); // increment counter and mask for lowest 8 bit
neorv32_cpu_delay_ms(250); // wait 250ms using busy wait
delay_ms(250); // wait 250ms using busy wait
}

// this should never be reached
Expand Down
16 changes: 13 additions & 3 deletions sw/example/demo_neopixel/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand Down Expand Up @@ -33,6 +33,16 @@
uint32_t hsv2rgb(int h, int v);


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* Main function
* This demo uses a 12-LED RGB ring
Expand Down Expand Up @@ -83,7 +93,7 @@ int main() {
for (i=0; i<NUM_LEDS_24BIT; i++) {
neorv32_neoled_write_blocking(0);
}
neorv32_cpu_delay_ms(500);
delay_ms(500);


// a simple animation example: rotating rainbow
Expand All @@ -100,7 +110,7 @@ int main() {
angle += 1; // rotation increment per frame

neorv32_neoled_strobe_blocking(); // send strobe ("RESET") command
neorv32_cpu_delay_ms(10); // delay between frames
delay_ms(10); // delay between frames
}

return 0;
Expand Down
4 changes: 2 additions & 2 deletions sw/example/demo_newlib/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand Down Expand Up @@ -76,7 +76,7 @@ int main() {


// heap size definition
uint32_t max_heap = (uint32_t)neorv32_heap_size_c;
uint32_t max_heap = (uint32_t)NEORV32_HEAP_SIZE;
if (max_heap > 0){
neorv32_uart0_printf("MAX heap size: %u bytes\n", max_heap);
}
Expand Down
13 changes: 11 additions & 2 deletions sw/example/demo_pwm/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand All @@ -27,6 +27,15 @@
/**@}*/


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* This program generates a simple dimming sequence for PWM channels 0 to 3.
Expand Down Expand Up @@ -115,7 +124,7 @@ int main() {
}

neorv32_pwm_ch_set_duty(ch, dc); // set new duty cycle for channel
neorv32_cpu_delay_ms(3); // wait ~3ms using busy-wait
delay_ms(3); // wait ~3ms using busy-wait
}

return 0;
Expand Down
14 changes: 12 additions & 2 deletions sw/example/demo_trng/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand Down Expand Up @@ -33,6 +33,16 @@ void generate_histogram(void);
void compute_rate(void);


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* Simple true random number test/demo program.
*
Expand Down Expand Up @@ -73,7 +83,7 @@ int main(void) {
neorv32_uart0_printf("\nTRNG FIFO depth: %i\n", neorv32_trng_get_fifo_depth());
neorv32_uart0_printf("Starting TRNG...\n");
neorv32_trng_enable();
neorv32_cpu_delay_ms(100); // TRNG "warm up"
delay_ms(100); // TRNG "warm up"
neorv32_trng_fifo_clear(); // discard "warm-up" data

while(1) {
Expand Down
12 changes: 11 additions & 1 deletion sw/example/demo_wdt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@
/**@}*/


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* Main function
*
Expand Down Expand Up @@ -91,7 +101,7 @@ int main() {
neorv32_uart0_puts("Resetting WDT 5 times...\n");
int i;
for (i=0; i<5; i++) {
neorv32_cpu_delay_ms(750);
delay_ms(750);
neorv32_wdt_feed(WDT_PASSWORD); // reset internal counter using the access password
neorv32_uart0_puts("WDT reset.\n");
}
Expand Down
9 changes: 8 additions & 1 deletion sw/example/eclipse/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#define BAUD_RATE 19200


// Simple bus-wait helper
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


// Main function
int main() {

// setup NEORV32 runtime environment
Expand All @@ -23,7 +30,7 @@ int main() {
while (1) {
cnt = (cnt + 1) & 0xff; // increment counter and mask for lowest 8 bit
neorv32_gpio_port_set(cnt); // output via GPIO.out
neorv32_cpu_delay_ms(250); // wait 250ms using busy wait
delay_ms(250); // wait 250ms using busy wait
}

// this should never be reached
Expand Down
8 changes: 5 additions & 3 deletions sw/example/eclipse/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ USER_FLAGS += -ggdb -gdwarf-3
APP_SRC += $(wildcard ./*.c)
APP_INC += -I .

# Adjust processor IMEM size
# Adjust processor IMEM size and base address
USER_FLAGS += -Wl,--defsym,__neorv32_rom_size=16k
USER_FLAGS += -Wl,--defsym,__neorv32_rom_base=0x00000000

# Adjust processor DMEM size
# Adjust processor DMEM size and base address
USER_FLAGS += -Wl,--defsym,__neorv32_ram_size=8k
USER_FLAGS += -Wl,--defsym,__neorv32_ram_base=0x80000000

# Adjust maximum heap size
USER_FLAGS += -Wl,--defsym,__neorv32_heap_size=1k
USER_FLAGS += -Wl,--defsym,__neorv32_heap_size=2k

# Set path to NEORV32 root directory
NEORV32_HOME ?= ../../..
Expand Down
26 changes: 18 additions & 8 deletions sw/example/game_of_life/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ================================================================================ //
// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
// Copyright (c) NEORV32 contributors. //
// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
// Copyright (c) 2020 - 2025 Stephan Nolting. All rights reserved. //
// Licensed under the BSD-3-Clause license, see LICENSE for details. //
// SPDX-License-Identifier: BSD-3-Clause //
// ================================================================================ //
Expand All @@ -21,17 +21,17 @@
**************************************************************************/
/**@{*/
/** UART BAUD rate */
#define BAUD_RATE 19200
#define BAUD_RATE (19200)
/** Universe x size (has to be a multiple of 8) */
#define NUM_CELLS_X 160
#define NUM_CELLS_X (160)
/** Universe y size */
#define NUM_CELLS_Y 40
#define NUM_CELLS_Y (40)
/** Delay between generations in ms */
#define GEN_DELAY 500
#define GEN_DELAY (500)
/** Symbol for dead cell */
#define CELL_DEAD (' ')
#define CELL_DEAD (' ')
/** Symbol for alive cell */
#define CELL_ALIVE ('#')
#define CELL_ALIVE ('#')
/**@}*/


Expand All @@ -50,6 +50,16 @@ void print_universe(int u);
int pop_count(int u);


/**********************************************************************//**
* Simple bus-wait helper.
*
* @param[in] time_ms Time in ms to wait (unsigned 32-bit).
**************************************************************************/
void delay_ms(uint32_t time_ms) {
neorv32_aux_delay_ms(neorv32_sysinfo_get_clk(), time_ms);
}


/**********************************************************************//**
* Conway's Game of Life.
*
Expand Down Expand Up @@ -168,7 +178,7 @@ int main(void) {
generation++;

// wait GEN_DELAY ms
neorv32_cpu_delay_ms(GEN_DELAY);
delay_ms(GEN_DELAY);
}

}
Expand Down
Loading

0 comments on commit 54581c5

Please sign in to comment.