Selective peripheral reset on startup

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Selective peripheral reset on startup

Postby steved » Tue Feb 20, 2018 6:15 pm

I have an application where I need to start a Chibi-based program while keeping some of the peripherals operational. The main obstacle to this is the fact that everything gets reset in hal_lld.c.

For now I've solved this in an application-specific way (involving some conditionals in hal_lld.c), but a more general way is obviously preferable.
All the affected code is in hal_lld_init(), so maybe a simple solution would to be an option to override this routine with a project-specific one. Or is there a better way?

(I've also disabled much of the clock configuration for now, but that's in board.c so much more controllable)

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Selective peripheral reset on startup

Postby Giovanni » Tue Feb 20, 2018 7:01 pm

Hi,

I tried something about this in the H7 clock initialization. It is possible to do not init anything but assume frequencies to be set to specific values. Perhaps the concept could be expanded and back-ported to older devices.

Giovanni

steved
Posts: 825
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 135 times

Re: Selective peripheral reset on startup

Postby steved » Wed Feb 21, 2018 6:31 pm

The clocks are straightforward, because its just a matter of modifying the __early_init() function in board.c (at the simplet level - just remove the call to stm32_clock_init() ).
The I/O and peripherals are more problematic with the existing structure, since they are all reset in hal_lld.c.

I've implemented my idea of making hal_lld_init() a weak function, so that it can be overridden. I think this small change would be useful for the few situations where it matters, while not adding lots of complication for everyone else.
The only other related change is that hal_lld_backup_domain_init() has to be made global, so that it can still be called from an overridden hal_lld_init().
So far, this works well for me (using F767).


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 8 guests