Loading files
62cb1048fThis file is pinned to the selected release. Download the original to open it in your design tool.
/*****************************************************************************
main.cpp
Copyright (c) 2020 Raphael DINGE
*Tab=3***********************************************************************/
/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
#include "%module.name%.h"
#include "erb/module_fnc.h"
#include "erb/def.h"
#include "erb/config.h"
#include "erb/Monitor.h"
erb_DISABLE_WARNINGS_DAISY
#include "daisy.h"
#include <stm32h750xx.h>
erb_RESTORE_WARNINGS
#if defined (erb_SEMIHOSTING)
extern "C" void initialise_monitor_handles ();
#endif
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
/*
==============================================================================
Name : main
==============================================================================
*/
int main ()
{
#if defined (erb_SEMIHOSTING)
if (CoreDebug->DHCSR & 0x01)
{
initialise_monitor_handles ();
printf ("erb: semihosting activated\n");
}
#endif
// Enable FZ (flush-to-zero) denormal behavior
uint32_t fpscr = __get_FPSCR ();
fpscr |= 0x01000000; // FZ bit
__set_FPSCR (fpscr);
// Init system
daisy::System system;
daisy::System::Config config;
config.Boost ();
auto program_memory_section = daisy::System::GetProgramMemoryRegion ();
auto boot_version = daisy::System::GetBootloaderVersion ();
// When using the bootloader prior to v6, clocks have been already configured
if (
(boot_version == daisy::System::BootInfo::Version::LT_v6_0)
&& (program_memory_section != daisy::System::MemoryRegion::INTERNAL_FLASH)
)
{
config.skip_clocks = true;
}
system.Init (config);
#if (erb_SDRAM_USE_FLAG)
// Init SDRAM
// When using the bootloader priori to v6, SDRAM has been already configured
if (
(boot_version != daisy::System::BootInfo::Version::LT_v6_0)
|| (
(boot_version == daisy::System::BootInfo::Version::LT_v6_0)
&& (program_memory_section == daisy::System::MemoryRegion::INTERNAL_FLASH)
)
)
{
SdramHandle sdram;
sdram.Init ();
}
#endif
//-------------------------------------------------------------------------
%module.name% module;
// The Daisy Seed stack, sitting on SRAM is 512K only.
// When more memory is needed, move the big buffers like
// delay lines or samples to the SDRAM, which is 64M.
// Since we have some heap allocations, we keep a bit of margin
// and complain when we reach 128K of stack space.
static_assert (sizeof (module) < 128 * 1024 /* 128 */, "");
// The SDRAM is compararively slow compared to the SRAM,
// So try to keep all memory that is accessed often in SRAM.
// Check 'erb::make_sdram_object' to put your buffers in
// SDRAM.
erb::module_init (module);
#if (erb_MONITOR)
erb::Monitor::use ().init ();
#endif
module.ui.board.run ([&](){
using BoardType = decltype (module.ui.board);
#if (erb_MONITOR)
erb::Monitor::use ().audio_enter ();
#endif
module.ui.board.impl_preprocess ();
% board_preprocess%
% controls_preprocess%
module.process ();
% controls_postprocess%
% board_postprocess%
module.ui.board.impl_postprocess ();
#if (erb_MONITOR)
erb::Monitor::use ().audio_exit ();
#endif
});
const auto tick_freq = daisy::System::GetTickFreq ();
for (;;)
{
auto ts_beg = daisy::System::GetTick ();
erb::module_idle (module);
module.ui.board.impl_idle ();
#if (erb_MONITOR)
erb::Monitor::use ().idle ();
#endif
// busy wait so that the idle loop is at least 6ms
while (daisy::System::GetTick () - ts_beg < tick_freq * 6 / 1000) {}
}
}