AnsweredAssumed Answered

__IO, gcc and core_cm0.h

Question asked by gregson.peter on Mar 4, 2015
Latest reply on Nov 7, 2016 by Md Mubdiul Hasan
Hello,

I am porting the Custom HID demo project that is included with STM32_USB-FS-Device_Lib_V4.0.0 library to work with my gcc-based toolchain.  I have previously successfully ported other code (specifically, from Olimex for the EW-ARM 5.11 toolchain) to work with my toolchain with little difficulty.  

Both the new code and the previously ported code uses the __IO directive in places, and the library routines such as stm32f10x_adc.c also use it and were properly compiled and built in the previously ported code.  However, the new code throws a large number of errors when it tries to compile usb_pwr.c.  The first such error is:

In file included from ./inc/usb_lib.h:37:0,
                 from src/usb_pwr.c:31:
./inc/usb_regs.h:617:1: error: unknown type name '__IO'
./inc/usb_regs.h:617:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'wIstr'
In file included from ./inc/usb_lib.h:39:0,
                 from src/usb_pwr.c:31:

I can make these and a large number of my subsequent errors go away by putting

#define __IO volatile

in usb_pwr.c.  However, this makes that function non-standard which I don't want to do.

After much searching I found that an identical definition is provided in the CMSIS/Include directory in core_cm0.h.  

Where and how is this header normally included in the demo code?  Or is it included in the toolchain configuration?  It must be included somewhere to compile the demo.  I would like to duplicate that inclusion in my port or toolchain without modifying the distributed STM32_USB-FS-Device_Lib_V4.0.0 because that might give me major issues when that distribution is upgraded.

Any help would be appreciated.

Best regards,

Peter

Outcomes