]> granicus.if.org Git - esp-idf/commitdiff
Bugfix I_DELAY macro
authorrobotrovsky <robotrovsky@users.noreply.github.com>
Thu, 23 Nov 2017 19:51:17 +0000 (20:51 +0100)
committerAngus Gratton <gus@projectgus.com>
Wed, 6 Dec 2017 23:02:45 +0000 (10:02 +1100)
When compiling

> const ulp_insn_t program[] = {
> I_DELAY(1)
> };

with the xtensa-esp32-elf-g++ compiler i always got the error:

> sorry, unimplemented: non-trivial designated initializers not supported
>
>        };

This was due to the different order in the macro and the struct. The struct has another order of the fields (opcode, unused, cycles) vs (cycles, unused, opcode):
>    struct {
>        uint32_t cycles : 16;       /*!< Number of cycles to sleep */
>        uint32_t unused : 12;       /*!< Unused */
>        uint32_t opcode : 4;        /*!< Opcode (OPCODE_DELAY) */
>    } delay;                        /*!< Format of DELAY instruction */

After updating the order in the macro it is possible to compile with the g++ compiler.

Merges https://github.com/espressif/esp-idf/pull/1310

components/ulp/include/esp32/ulp.h

index 302a47a0ca8f7a08f3bcd316e1c3d2a11539ce8f..ae539d84dae24280acd339a179772142f1e9987b 100644 (file)
@@ -266,9 +266,9 @@ _Static_assert(sizeof(ulp_insn_t) == 4, "ULP coprocessor instruction size should
  * Delay (nop) for a given number of cycles
  */
 #define I_DELAY(cycles_) { .delay = {\
-    .opcode = OPCODE_DELAY, \
+    .cycles = cycles_, \
     .unused = 0, \
-    .cycles = cycles_ } }
+    .opcode = OPCODE_DELAY } }
 
 /**
  * Halt the coprocessor.