Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 2 months ago.
mbed_main()
where is the mbed source code to the function mbed_main ? It's not in the library source code. Is it in a library I need to download, if so, where?
1 Answer
10 years, 2 months ago.
Why do you need it? I am not even sure why that function still exists, it is called before main, but I have no idea what the advantage is compared to just putting that code in the beginning of your main function.
Anyway it is defined here: http://mbed.org/users/mbed_official/code/mbed-src/file/c80ac197fa6a/common/retarget.cpp. It has a default, weak, empty implementation. So if you don't do anything with it it should just work. But why do you need it / what kind of problem do you observe?
I'm using the library source for the TARGET_NUCLEO_F401RE board and I'm redefining the pin assignments as this is different pin assignments than the NUCLEO board but the same processor. It seems that perhaps mbed_main is using different pin assignments that what I've defined in my main(). I know my pin assignments work because they work using the IAR and KEIL compiler and I can run my code. I've looked at the retarget.cpp file and it appears that I don't have to make any changes if I'm using the GCC_ARM compiler, is this correct? Also, I did comment the mbed_sdk_init() function in the mbed_overrides.c file thinking this would prevent mbed definitions to no avail. I have configured my pins in PinNames.h and defined their functionality in applicable files (analogin_api.c, pwmout_api.c, etc) all located in the /libraries/mbed/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/ directory.
posted by 23 Sep 2014But mbed inits have nothing to do with pin assignments, thats done by: http://mbed.org/users/mbed_official/code/mbed-src/file/c80ac197fa6a/targets/hal/TARGET_STM/TARGET_NUCLEO_F401RE/PinNames.h. If you mean system init (crystal mainly), thats done here: http://mbed.org/users/mbed_official/code/mbed-src/file/c80ac197fa6a/targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/system_stm32f4xx.c
Although it is strange it doesnt work on GCC_ARM, but does work on others.
posted by 23 Sep 2014