[MAINTAINERS] Low Level Driver organization changes

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.
User avatar
Giovanni
Site Admin
Posts: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 744 times
Been thanked: 620 times
Contact:

[MAINTAINERS] Low Level Driver organization changes

Postby Giovanni » Sat Dec 08, 2018 12:32 pm

Hi,

Historically in ChibiOS/HAL low level drivers contained the type definitions for both the HLD and the LLD parts. This impacted drivers in several ways:

- Code duplicated in each LLD.
- Changes in HLD always mandated changes in LLDs.
- Alignment problems between the various ports.
- Added effort in creating LLDs.

Now things are going to change:
- Type definitions will be moved in HLD, this will make sure that LLDs are not necessarily impacted by changes.
- LLDs will just export two structures: xxx_lld_driver_fields and xxx_lld_config_fields containing the fields to be added to XXXDriver and XXXConfig.

So far only ADC, DAC, I2S, RTC, SPI, TRNG, WSPI drivers have been updated to the new model, please make sure that your ports are aligned to the new model in trunk. I will inform in this thread when more drivers will be updated.

Changes in STM32 drivers took few minutes, I will gladly assist you in adapting your drivers if required.

Sorry for the forced change but the project has to evolve in order to go ahead, overall codebase will greatly benefit from this.

Giovanni

faisal
Posts: 260
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 34 times

Re: [MAINTAINERS] Low Level Driver organization changes

Postby faisal » Mon Dec 10, 2018 10:11 pm

Giovanni wrote:Sorry for the forced change but the project has to evolve in order to go ahead, overall codebase will greatly benefit from this.


The code base is already a gem and well respected in the relevant communities as very high quality. This is a good change for the future of ChibiOS/HAL.

User avatar
tfAteba
Posts: 526
Joined: Fri Oct 16, 2015 11:03 pm
Location: Chartres, France
Has thanked: 80 times
Been thanked: 46 times

Re: [MAINTAINERS] Low Level Driver organization changes

Postby tfAteba » Tue Dec 11, 2018 10:35 am

Hello Giovanni,

I will start the migration as soon has possible :), but before I need to See the changes that you have made.
regards,

Theo.

faisal
Posts: 260
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 34 times

Re: [MAINTAINERS] Low Level Driver organization changes

Postby faisal » Fri Feb 22, 2019 2:57 am

Changed driver struct names in the upper layer driver. For example, in hal_dac.h:

Code: Select all

/**
 * @brief   Type of a structure representing an DAC driver.
 */
typedef struct hal_dac_driver DACDriver;

/**
 * @brief   Type of a structure representing an DAC driver configuration.
 */
typedef struct hal_dac_config DACConfig;

/**
 * @brief   Type of a DAC conversion group.
 */
typedef struct hal_dac_conversion_group DACConversionGroup;


Lowercase hal_<peripheral>_driver, hal_<peripheral>_config, and so on. Just curious, why the change ?

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

Re: [MAINTAINERS] Low Level Driver organization changes

Postby Giovanni » Fri Feb 22, 2019 8:17 am

xFaisal,
The change is not just that, now the xxxConfig and xxxDriver structures are defined in the upper layer, the LLD extra fields are exported by the LLD into a macro. This way, when there is a change affecting just the HLD, there is no need to rework all LLDs.

xTheo,
Look at the files under os/hal/templates, the change is more clearly visible looking at templates rather than STM32 implementations.

Giovanni

faisal
Posts: 260
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 35 times
Been thanked: 34 times

Re: [MAINTAINERS] Low Level Driver organization changes

Postby faisal » Fri Feb 22, 2019 11:53 pm

Giovanni wrote:xFaisal,
The change is not just that, now the xxxConfig and xxxDriver structures are defined in the upper layer, the LLD extra fields are exported by the LLD into a macro. This way, when there is a change affecting just the HLD, there is no need to rework all LLDs.

xTheo,
Look at the files under os/hal/templates, the change is more clearly visible looking at templates rather than STM32 implementations.

Giovanni


Oh, I understood that part of it.

I was just wondering about the new naming convention. Previously, user applications would use the xxxConfig and xxxDriver structures in their top level application. Is the correct convention to now use hal_<peripheral>_driver and hal_<peripheral>_config?

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

Re: [MAINTAINERS] Low Level Driver organization changes

Postby Giovanni » Sat Feb 23, 2019 9:36 am

Hi,

That is the structure name, not the type name, I decided to not have conflicting names, ss non-API it is right to not use camel case. Driver and config are still xxxDriver and xxxConfig, from the application pov nothing changed.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 2 guests