Page 1 of 1

ULP I_DELAY causes compile error

Posted: Mon Aug 28, 2017 5:12 am
by cruzxia
I am trying to setup ULP to run when in deep sleep.
When I compile the I_DELAY causes a compiler error.

Here is my test code:

Code: Select all

 assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig");
     memset(RTC_SLOW_MEM, 0, CONFIG_ULP_COPROC_RESERVE_MEM);
	const ulp_insn_t program[] = {
		I_MOVI(R1, 1024),
		M_LABEL(1),
		I_DELAY(32000),
		I_SUBI(R1, R1, 1),
		M_BXZ(3),
		I_RSHI(R3, R1, 5),  // R3 = R1 / 32 
		I_ST(R1, R3, 16),
		M_BX(1),
		M_LABEL(3),
		I_MOVI(R2, 42),
		I_MOVI(R3, 15),
		I_ST(R2, R3, 0),
		I_WAKE(),
		I_END(),
		I_HALT(),
	};
	
    size_t size = sizeof(program) / sizeof(ulp_insn_t);
    ulp_process_macros_and_load(0, program, &size);
    ulp_run(0);
    esp_deep_sleep_enable_ulp_wakeup();
    esp_deep_sleep_start();
I get the following compile error:
UlpFunc.cpp:25: sorry, unimplemented non-trivial designated initializers not supported
UlpFunc.cpp:25: sorry, unimplemented non-trivial designated initializers not supported
Error compiling libraries

if I remove I_DELAY(32000), from the code it compiles ok

dose anyone have any suggestions on how to fix this.

Re: ULP I_DELAY causes compile error

Posted: Mon Aug 28, 2017 6:06 am
by ESP_igrr
It seems you are compiling this as C++ code. Unfortunately, designated initializers are not part of C++ standard. You need to compile this as a C code, then this will compile without issue.

Re: ULP I_DELAY causes compile error

Posted: Tue Aug 29, 2017 7:31 am
by cruzxia
Thanks for that, It compiles now.
:D