InfiniTimeOrg / InfiniTime

Firmware for Pinetime smartwatch written in C++ and based on FreeRTOS
GNU General Public License v3.0
2.68k stars 916 forks source link

Hardware initialization, abstraction and controllers. #1583

Open Riksu9000 opened 1 year ago

Riksu9000 commented 1 year ago

Verification

Introduce the issue

The hardware is initialized in many places, controller classes, drivers, systemtask, displayapp. Keeping track of the hardware state can be difficult. What has been initialized and when. We need to define how and where the hardware should be initialized, and how info about the hardware, such as pins, is passed to the controller classes.

Relates to #1387 #1050 #1468

Preferred solution

For example, we could have a port init function, that initializes all hardware. The already configured pins could be passed to the controller classes. We could apply a discipline to only include hardware specific files in certain places.

Version

No response

JF002 commented 1 year ago

This is indeed something I tried to do in #1387 : implement all the hardware specific code at a single place, and ensure that all hardware specific code is correctly encapsulated so that all the application code in InfiniTime do not have to worry about the hardware details.

I tried to do all of this at once in #1387, but this is a big task. As you suggested, we could start by adding those port init functions to support various PineTime variants (such as the P8) could be a good start. So in the project, there would be a 'ports' folder that contains all the init code for the supported hardware, and the specific port file would be selected by CMake during the project generation.