Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Minor SW framework edits to fix c++ warnings #964

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sw/example/hello_cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ int main() {
neorv32_rte_print_logo();

// say hello
neorv32_uart0_puts("Hello world! :)\n");
neorv32_uart0_printf("Hello C++! :)\n");

// print the IDs of the two statically declared instances of DemoClass
demo1.print_id();
Expand Down
5 changes: 4 additions & 1 deletion sw/example/hello_cpp/makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Modify this variable to fit your NEORV32 setup (neorv32 home folder)
NEORV32_HOME ?= ../../..

include $(NEORV32_HOME)/sw/common/common.mk

# Use c++ compiler and define c++ standard
override CC = $(RISCV_PREFIX)g++
override USER_FLAGS += -std=c++11
1 change: 1 addition & 0 deletions sw/lib/include/neorv32.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ typedef union {
#include "neorv32_xip.h"
#include "neorv32_xirq.h"


#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 6 additions & 1 deletion sw/lib/include/neorv32_cpu_amo.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ inline uint32_t __attribute__ ((always_inline)) neorv32_cpu_amosc(uint32_t addr,
}


// prototypes
/**********************************************************************//**
* @name Prototypes
**************************************************************************/
/**@{*/
uint32_t neorv32_cpu_amoswapw(uint32_t addr, uint32_t wdata);
uint32_t neorv32_cpu_amoaddw(uint32_t addr, uint32_t wdata);
uint32_t neorv32_cpu_amoandw(uint32_t addr, uint32_t wdata);
Expand All @@ -84,5 +87,7 @@ int32_t neorv32_cpu_amomaxw(uint32_t addr, int32_t wdata);
uint32_t neorv32_cpu_amomaxuw(uint32_t addr, uint32_t wdata);
int32_t neorv32_cpu_amominw(uint32_t addr, int32_t wdata);
uint32_t neorv32_cpu_amominuw(uint32_t addr, uint32_t wdata);
/**@}*/


#endif // neorv32_cpu_amo_h
51 changes: 2 additions & 49 deletions sw/lib/include/neorv32_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,54 +19,6 @@
#include <stdint.h>


/**********************************************************************//**
* @name UART0 legacy compatibility wrappers
**************************************************************************/
/**@{*/
#define neorv32_uart0_available() neorv32_uart_available(NEORV32_UART0)
#define neorv32_uart0_get_rx_fifo_depth() neorv32_uart_get_rx_fifo_depth(NEORV32_UART0)
#define neorv32_uart0_get_tx_fifo_depth() neorv32_uart_get_tx_fifo_depth(NEORV32_UART0)
#define neorv32_uart0_setup(baudrate, irq_mask) neorv32_uart_setup(NEORV32_UART0, baudrate, irq_mask)
#define neorv32_uart0_disable() neorv32_uart_disable(NEORV32_UART0)
#define neorv32_uart0_enable() neorv32_uart_enable(NEORV32_UART0)
#define neorv32_uart0_rtscts_disable() neorv32_uart_rtscts_disable(NEORV32_UART0)
#define neorv32_uart0_rtscts_enable() neorv32_uart_rtscts_enable(NEORV32_UART0)
#define neorv32_uart0_putc(c) neorv32_uart_putc(NEORV32_UART0, c)
#define neorv32_uart0_rx_clear() neorv32_uart_rx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_clear() neorv32_uart_tx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_busy() neorv32_uart_tx_busy(NEORV32_UART0)
#define neorv32_uart0_getc() neorv32_uart_getc(NEORV32_UART0)
#define neorv32_uart0_char_received() neorv32_uart_char_received(NEORV32_UART0)
#define neorv32_uart0_char_received_get() neorv32_uart_char_received_get(NEORV32_UART0)
#define neorv32_uart0_puts(s) neorv32_uart_puts(NEORV32_UART0, s)
#define neorv32_uart0_printf(...) neorv32_uart_printf(NEORV32_UART0, __VA_ARGS__)
#define neorv32_uart0_scan(buffer, max_size, echo) neorv32_uart_scan(NEORV32_UART0, buffer, max_size, echo)
/**@}*/

/**********************************************************************//**
* @name UART1 legacy compatibility wrappers
**************************************************************************/
/**@{*/
#define neorv32_uart1_available() neorv32_uart_available(NEORV32_UART1)
#define neorv32_uart1_get_rx_fifo_depth() neorv32_uart_get_rx_fifo_depth(NEORV32_UART1)
#define neorv32_uart1_get_tx_fifo_depth() neorv32_uart_get_tx_fifo_depth(NEORV32_UART1)
#define neorv32_uart1_setup(baudrate, irq_mask) neorv32_uart_setup(NEORV32_UART1, baudrate, irq_mask)
#define neorv32_uart1_disable() neorv32_uart_disable(NEORV32_UART1)
#define neorv32_uart1_enable() neorv32_uart_enable(NEORV32_UART1)
#define neorv32_uart1_rtscts_disable() neorv32_uart_rtscts_disable(NEORV32_UART1)
#define neorv32_uart1_rtscts_enable() neorv32_uart_rtscts_enable(NEORV32_UART1)
#define neorv32_uart1_putc(c) neorv32_uart_putc(NEORV32_UART1, c)
#define neorv32_uart1_rx_clear() neorv32_uart_rx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_clear() neorv32_uart_tx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_busy() neorv32_uart_tx_busy(NEORV32_UART1)
#define neorv32_uart1_getc() neorv32_uart_getc(NEORV32_UART1)
#define neorv32_uart1_char_received() neorv32_uart_char_received(NEORV32_UART1)
#define neorv32_uart1_char_received_get() neorv32_uart_char_received_get(NEORV32_UART1)
#define neorv32_uart1_puts(s) neorv32_uart_puts(NEORV32_UART1, s)
#define neorv32_uart1_printf(...) neorv32_uart_printf(NEORV32_UART1, __VA_ARGS__)
#define neorv32_uart1_scan(buffer, max_size, echo) neorv32_uart_scan(NEORV32_UART1, buffer, max_size, echo)
/**@}*/

/**********************************************************************//**
* @name GPIO aliases
**************************************************************************/
Expand All @@ -77,8 +29,9 @@
#define OUTPUT_HI OUTPUT[1]
/**@}*/


/**********************************************************************//**
* @name Atomic LR/SC aliases
* @name Atomic LR/SC instructions
**************************************************************************/
/**@{*/
#define neorv32_cpu_load_reservate_word(addr, wdata) neorv32_cpu_amolr(addr, wdata)
Expand Down
44 changes: 44 additions & 0 deletions sw/lib/include/neorv32_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,48 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ec
/**@}*/


/**********************************************************************//**
* @name UART wrappers for easy access
**************************************************************************/
/**@{*/
#define neorv32_uart0_available() neorv32_uart_available(NEORV32_UART0)
#define neorv32_uart0_get_rx_fifo_depth() neorv32_uart_get_rx_fifo_depth(NEORV32_UART0)
#define neorv32_uart0_get_tx_fifo_depth() neorv32_uart_get_tx_fifo_depth(NEORV32_UART0)
#define neorv32_uart0_setup(baudrate, irq_mask) neorv32_uart_setup(NEORV32_UART0, baudrate, irq_mask)
#define neorv32_uart0_disable() neorv32_uart_disable(NEORV32_UART0)
#define neorv32_uart0_enable() neorv32_uart_enable(NEORV32_UART0)
#define neorv32_uart0_rtscts_disable() neorv32_uart_rtscts_disable(NEORV32_UART0)
#define neorv32_uart0_rtscts_enable() neorv32_uart_rtscts_enable(NEORV32_UART0)
#define neorv32_uart0_putc(c) neorv32_uart_putc(NEORV32_UART0, c)
#define neorv32_uart0_rx_clear() neorv32_uart_rx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_clear() neorv32_uart_tx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_busy() neorv32_uart_tx_busy(NEORV32_UART0)
#define neorv32_uart0_getc() neorv32_uart_getc(NEORV32_UART0)
#define neorv32_uart0_char_received() neorv32_uart_char_received(NEORV32_UART0)
#define neorv32_uart0_char_received_get() neorv32_uart_char_received_get(NEORV32_UART0)
#define neorv32_uart0_puts(s) neorv32_uart_puts(NEORV32_UART0, s)
#define neorv32_uart0_printf(...) neorv32_uart_printf(NEORV32_UART0, __VA_ARGS__)
#define neorv32_uart0_scan(buffer, max_size, echo) neorv32_uart_scan(NEORV32_UART0, buffer, max_size, echo)

#define neorv32_uart1_available() neorv32_uart_available(NEORV32_UART1)
#define neorv32_uart1_get_rx_fifo_depth() neorv32_uart_get_rx_fifo_depth(NEORV32_UART1)
#define neorv32_uart1_get_tx_fifo_depth() neorv32_uart_get_tx_fifo_depth(NEORV32_UART1)
#define neorv32_uart1_setup(baudrate, irq_mask) neorv32_uart_setup(NEORV32_UART1, baudrate, irq_mask)
#define neorv32_uart1_disable() neorv32_uart_disable(NEORV32_UART1)
#define neorv32_uart1_enable() neorv32_uart_enable(NEORV32_UART1)
#define neorv32_uart1_rtscts_disable() neorv32_uart_rtscts_disable(NEORV32_UART1)
#define neorv32_uart1_rtscts_enable() neorv32_uart_rtscts_enable(NEORV32_UART1)
#define neorv32_uart1_putc(c) neorv32_uart_putc(NEORV32_UART1, c)
#define neorv32_uart1_rx_clear() neorv32_uart_rx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_clear() neorv32_uart_tx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_busy() neorv32_uart_tx_busy(NEORV32_UART1)
#define neorv32_uart1_getc() neorv32_uart_getc(NEORV32_UART1)
#define neorv32_uart1_char_received() neorv32_uart_char_received(NEORV32_UART1)
#define neorv32_uart1_char_received_get() neorv32_uart_char_received_get(NEORV32_UART1)
#define neorv32_uart1_puts(s) neorv32_uart_puts(NEORV32_UART1, s)
#define neorv32_uart1_printf(...) neorv32_uart_printf(NEORV32_UART1, __VA_ARGS__)
#define neorv32_uart1_scan(buffer, max_size, echo) neorv32_uart_scan(NEORV32_UART1, buffer, max_size, echo)
/**@}*/


#endif // neorv32_uart_h
2 changes: 1 addition & 1 deletion sw/lib/source/neorv32_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @see https://stnolting.github.io/neorv32/sw/files.html
*/

#include <neorv32_aux.h>
#include "neorv32.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_cfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

#include "neorv32.h"
#include "neorv32_cfs.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include "neorv32.h"
#include "neorv32_cpu.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_cpu_amo.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include "neorv32.h"
#include "neorv32_cpu_amo.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_cpu_cfu.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include "neorv32.h"
#include "neorv32_cpu_cfu.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_crc.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_dma.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_gpio.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_gptmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_gptmr.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_mtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_mtime.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_neoled.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_neoled.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_onewire.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_onewire.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_pwm.h"


/**********************************************************************//**
Expand Down
17 changes: 9 additions & 8 deletions sw/lib/source/neorv32_rte.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/

#include "neorv32.h"
#include "neorv32_rte.h"


/**********************************************************************//**
Expand Down Expand Up @@ -186,7 +185,9 @@ static void __attribute__((__naked__,aligned(4))) __neorv32_rte_core(void) {
}

// call handler
asm volatile ("jalr ra, 0(%[dst])" : : [dst] "r" (handler_base));
typedef void handler_t();
handler_t* handler = (handler_t*)handler_base;
handler();

// compute return address (for exceptions only)
// do not alter return address if instruction access exception (fatal?)
Expand Down Expand Up @@ -251,14 +252,14 @@ static void __attribute__((__naked__,aligned(4))) __neorv32_rte_core(void) {

/**********************************************************************//**
* NEORV32 runtime environment (RTE):
* Read register from application context.
* Read register from application context (on stack).
*
* @param[in] x Register number (0..31, corresponds to register x0..x31).
* @return Content of register x.
**************************************************************************/
uint32_t neorv32_rte_context_get(int x) {

// MSCRATCH CSR contain the stack pointer of the interrupted program
// MSCRATCH CSR contains the stack pointer of the interrupted program
uint32_t tmp = neorv32_cpu_csr_read(CSR_MSCRATCH);
#ifdef __riscv_32e
tmp += (x & 15) << 2;
Expand All @@ -271,14 +272,14 @@ uint32_t neorv32_rte_context_get(int x) {

/**********************************************************************//**
* NEORV32 runtime environment (RTE):
* Write register in application context.
* Write register to application context (on stack).
*
* @param[in] x Register number (0..31, corresponds to register x0..x31).
* @param[in] data Data to be written to register x.
**************************************************************************/
void neorv32_rte_context_put(int x, uint32_t data) {

// MSCRATCH CSR contain the stack pointer of the interrupted program
// MSCRATCH CSR contains the stack pointer of the interrupted program
uint32_t tmp = neorv32_cpu_csr_read(CSR_MSCRATCH);
#ifdef __riscv_32e
tmp += (x & 15) << 2;
Expand Down Expand Up @@ -641,7 +642,7 @@ void neorv32_rte_print_hw_config(void) {
void __neorv32_rte_print_hex_word(uint32_t num) {

int i;
static const char hex_symbols[16] = "0123456789ABCDEF";
static const char hex_symbols[] = "0123456789ABCDEF";

if (neorv32_uart0_available() != 0) { // cannot output anything if UART0 is not implemented
neorv32_uart0_putc('0');
Expand Down Expand Up @@ -721,7 +722,7 @@ void neorv32_rte_print_logo(void) {
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0300, 0xc630}
};

int x, y, z;
unsigned int x, y, z;
uint16_t tmp;
char c;

Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_sdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_sdi.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_slink.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_slink.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_spi.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_trng.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_trng.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_twi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_twi.h"


/**********************************************************************//**
Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_uart.h"
#include <string.h>
#include <stdarg.h>

Expand Down
1 change: 0 additions & 1 deletion sw/lib/source/neorv32_wdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/

#include "neorv32.h"
#include "neorv32_wdt.h"


/**********************************************************************//**
Expand Down
Loading