Power Driver for stm32l1

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.
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi,

prototype of PWR driver is attached. It supports L1 and L4 on MSI/HSI.
Attachments
pwr.zip
(12.88 KiB) Downloaded 508 times
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi!

any feedback?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Power Driver for stm32l1

Post by Giovanni »

Hi,

Having checks on STM32-specific macros into the high level part is a problem. Another problem is that some drivers could be active and be compatible with stop/halt modes.

It is not a general solution.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi,

I will move STM32-specific checks to lld, not a problem.
Second issue hardly may be resolved without changes in drivers as we discussed earlier: counter or bit mask field.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Power Driver for stm32l1

Post by Giovanni »

Yes, it requires an architectural change in HAL, I am not sure yet about the best way to proceed.

For 4 weeks I will be busy with work or travelling so don't worry if I am not very reactive. In August I will be off for vacations :)

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi,

All STM32 specific checks moved to pwr_lld_common.h,
fixed min sleep/stop period bug,
added support ST based on RTC (will create new post for ST on RTC topic).

Sources are attached.
Attachments
pwr.zip
(11.16 KiB) Downloaded 519 times
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi,

shall we continue?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Power Driver for stm32l1

Post by Giovanni »

Hi,

I think the concept is not right yet, the driver is mutually exclusive with DAC, MAC, I2S, look at checks in pal_pwr.h.

Such a driver needs to know the state of other drivers, it requires some kind of system-wide registration system. It is not that simple.

Giovanni
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Do you mean this:

#if HAL_USE_I2S == TRUE
#error "PWR driver does not support I2S."
#endif

?

It is just a stub. I do not use these drivers, so not check these drivers state. There is no problem to add support of DAC, MAC and etc.
vrollei
Posts: 163
Joined: Sun Nov 13, 2016 8:44 am
Been thanked: 26 times

Re: Power Driver for stm32l1

Post by vrollei »

Hi,
I would like to suggest to discuss concept once more:

1. Power module can activate low power sleep/stop mode when all drivers are not active.
2. Drivers have to notify Power module on beginning and ending activities using Power module interface:
void pwrOnStartActivityNotification(void);
void pwrOnStopActivityNotification(void);
3. Notifications can be implemented using Driver State Machine transition:
- xxxStart() calls pwrOnStartActivityNotification()
- xxxStop() calls pwrOnStopActivityNotification()
4. Drivers with low power support should use different transition to notify Power module about activities (it is MCU and peripheral specific)

Additional note:
In OSAL_IRQ_HANDLER(ST_HANDLER) should be added call:
#if HAL_USE_PWR == TRUE
pwrOnExitIdleThread();
#endif

to prevent execution of chvt code on low mcu frequency.
Post Reply