mirror of
https://github.com/stnolting/neorv32.git
synced 2025-04-23 21:57:33 -04:00
[sw] update example programs
This commit is contained in:
parent
2a28c8dea5
commit
370e515d1e
3 changed files with 6 additions and 24 deletions
|
@ -3,7 +3,7 @@
|
|||
// # ********************************************************************************************* #
|
||||
// # BSD 3-Clause License #
|
||||
// # #
|
||||
// # Copyright (c) 2023, Stephan Nolting. All rights reserved. #
|
||||
// # Copyright (c) 2024, Stephan Nolting. All rights reserved. #
|
||||
// # #
|
||||
// # Redistribution and use in source and binary forms, with or without modification, are #
|
||||
// # permitted provided that the following conditions are met: #
|
||||
|
@ -98,7 +98,7 @@ int main(void) {
|
|||
// enable TRNG
|
||||
neorv32_uart0_printf("\nTRNG FIFO depth: %i\n", neorv32_trng_get_fifo_depth());
|
||||
neorv32_uart0_printf("Starting TRNG...\n");
|
||||
neorv32_trng_enable(0); // no interrupts
|
||||
neorv32_trng_enable();
|
||||
neorv32_cpu_delay_ms(100); // TRNG "warm up"
|
||||
|
||||
while(1) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// # ********************************************************************************************* #
|
||||
// # BSD 3-Clause License #
|
||||
// # #
|
||||
// # Copyright (c) 2023, Stephan Nolting. All rights reserved. #
|
||||
// # Copyright (c) 2024, Stephan Nolting. All rights reserved. #
|
||||
// # #
|
||||
// # Redistribution and use in source and binary forms, with or without modification, are #
|
||||
// # permitted provided that the following conditions are met: #
|
||||
|
@ -52,17 +52,6 @@
|
|||
/**@}*/
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Watchdog FIRQ handler - executed when the WDT has reached half of
|
||||
* the configured timeout interval.
|
||||
**************************************************************************/
|
||||
void wdt_firq_handler(void) {
|
||||
|
||||
neorv32_cpu_csr_clr(CSR_MIP, 1<<WDT_FIRQ_PENDING); // clear/ack pending FIRQ
|
||||
neorv32_uart0_puts("WDT IRQ! Timeout imminent!\n");
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************//**
|
||||
* Main function
|
||||
*
|
||||
|
@ -109,14 +98,6 @@ int main() {
|
|||
}
|
||||
|
||||
|
||||
// configure and enable WDT interrupt
|
||||
// this IRQ will trigger when half of the configured WDT timeout interval has been reached
|
||||
neorv32_uart0_puts("Configuring WDT interrupt...\n");
|
||||
neorv32_rte_handler_install(WDT_RTE_ID, wdt_firq_handler);
|
||||
neorv32_cpu_csr_set(CSR_MIE, 1 << WDT_FIRQ_ENABLE); // enable WDT FIRQ channel
|
||||
neorv32_cpu_csr_set(CSR_MSTATUS, 1 << CSR_MSTATUS_MIE); // enable machine-mode interrupts
|
||||
|
||||
|
||||
// compute WDT timeout value
|
||||
// - the WDT counter increments at f_wdt = f_main / 4096
|
||||
uint32_t timeout = WDT_TIMEOUT_S * (NEORV32_SYSINFO->CLK / 4096);
|
||||
|
@ -146,5 +127,6 @@ int main() {
|
|||
neorv32_cpu_sleep();
|
||||
}
|
||||
|
||||
|
||||
return 0; // will never be reached
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// # ********************************************************************************************* #
|
||||
// # BSD 3-Clause License #
|
||||
// # #
|
||||
// # Copyright (c) 2023, Stephan Nolting. All rights reserved. #
|
||||
// # Copyright (c) 2024, Stephan Nolting. All rights reserved. #
|
||||
// # #
|
||||
// # Redistribution and use in source and binary forms, with or without modification, are #
|
||||
// # permitted provided that the following conditions are met: #
|
||||
|
@ -124,7 +124,7 @@ int main(void) {
|
|||
// check if TRNG was synthesized
|
||||
if (neorv32_trng_available()) {
|
||||
neorv32_uart0_printf("\nTRNG detected. Using TRNG for universe initialization.\n");
|
||||
neorv32_trng_enable(0);
|
||||
neorv32_trng_enable();
|
||||
trng_available = 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue