Skip to content

Changed HAL_MspInit to mbed_main #6023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
#include "min_battery_voltage.h"
#include "battery_charger_i2c.h"

/** Defining HAL_MspInit strong function
/** Defining mbed_main strong function
* in user defined file as described in documentation
*/

void HAL_MspInit(void)
void mbed_main(void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mbed_main: User's code to be executed before main(). . Should not be defined in the targets

What problem is here? Why a target code needs kernel to be initialized ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #5995: our C030 board requires configuration of a voltage level in its battery charger chip if it is to work reliably. This battery charger chip is only configurable over I2C. The [standard ST] I2C drivers make calls to wait_us(), which is an RTOS function. So our target code needs to do this configuration call after the RTOS has been initialised and before entry to main(). Is there such a hook, other than mbed_main()?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there such a hook, other than mbed_main()?

No, there is not.

target code should use what it has, target code, in this case us ticker functionality.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I guess it is a rule that target code should not use RTOS calls. Is that written down somewhere, just so that I can have the discussion with ST (whose code it is)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grepping around a little, there are calls to wait_ms() and wait_us() all over the place in the target code so I don't see how it can be a rule that target code should not use RTOS calls. The other option would be to introduce a hook for target configuration to occur after the RTOS has been initialised, since I can see that being generally useful. I will raise a separate issue for this.

{
set_minimum_battery_voltage();
}
Expand Down