This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: HERCULES_SAFETY_MCU_DEMOS
Hi,
While porting code for little endian system (bitfield used in) to Hercules(BIG endian), bifields are effected while porting from little to big
in my case bitfields usage is crucial. May I know how to resolve this issue?
Hello,
There are separate source code folders as well as executables for all the different supported parts. There is no need to manually port the demo code between parts.
Most header files define constructs that are 32-bit-addressible. Any header file that does support bitfield access also includes appropriate control variables to select the endianness, for example in spi.h:
typedef volatile struct spiBase { uint32_t GCR0; /**< 0x0000: Global Control 0 */ #if ((__little_endian__ == 1) || (__LITTLE_ENDIAN__ == 1)) uint32_t GCR1 : 8U; /**< 0x0007: Global Control 1 */ uint32_t PD : 1U; /**< 0x0006: Power down bit */ uint32_t : 7U; uint32_t LB : 1U; /**< 0x0005: Loop back bit */ uint32_t : 7U; uint32_t ENA : 1U; /**< 0x0004: SPI Enable bit */ uint32_t : 7U; uint32_t INT0 : 16U; /**< 0x000A: Interrupt Enable bits */ uint32_t DMAREQEN : 1U; /**< 0x0009: DMA Request enable */ uint32_t : 7U; uint32_t ENAHIGHZ : 1U; /**< 0x0008: Enable HIGHZ outputs */ uint32_t : 7U; #else uint32_t : 7U; uint32_t ENA : 1U; /**< 0x0004: SPI Enable bit */ uint32_t : 7U; uint32_t LB : 1U; /**< 0x0005: Loop back bit */ uint32_t : 7U; uint32_t PD : 1U; /**< 0x0006: Power down bit */ uint32_t GCR1 : 8U; /**< 0x0007: Global Control 1 */ uint32_t : 7U; uint32_t ENAHIGHZ : 1U; /**< 0x0008: Enable HIGHZ outputs */ uint32_t : 7U; uint32_t DMAREQEN : 1U; /**< 0x0009: DMA Request enable */ uint32_t INT0 : 16U; /**< 0x000A: Interrupt Enable bits */ #endif