ULP I_DELAY causes compile error

cruzxia
Posts: 3
Joined: Mon Aug 28, 2017 4:49 am

ULP I_DELAY causes compile error

Postby cruzxia » Mon Aug 28, 2017 5:12 am

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.

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: ULP I_DELAY causes compile error

Postby ESP_igrr » Mon Aug 28, 2017 6:06 am

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.

cruzxia
Posts: 3
Joined: Mon Aug 28, 2017 4:49 am

Re: ULP I_DELAY causes compile error

Postby cruzxia » Tue Aug 29, 2017 7:31 am

Thanks for that, It compiles now.
:D

Who is online

Users browsing this forum: No registered users and 127 guests