libhal / SJSU-Dev2

Firmware platform written by San Jose State University for building application for embedded systems
Apache License 2.0
42 stars 63 forks source link

API 4 #1425

Closed kammce closed 3 years ago

kammce commented 3 years ago

This new API seeks to make modules of SJSU-Dev2:

The new API does the following:

The consequences of these changes are the following:

  1. Initialization steps for a module have been simplified. No longer Construct, Init, Config, Enable, Use. Now it is Construct, Config, Init, Use.
  2. Configuration options can be inspected later on without a virtual call which would add to the already large vtables.
  3. Removal of virtual calls drops flash size significantly. Many projects drop by 1k and more.
  4. Configuration for a module can be saved in ROM or be predefined in a constexpr static variable, making setting up a module as easy as a single assignment and a single function call, vs many function calls.
  5. The new access factories allow for verbose and greatly explanitory error messages when attempting to access a peripheral.
  6. The new access factories, if used, also ensure that only 1 instance of a peripheral is used at a time. If you use GetUart<1>().Write() in multiple locations, additional Uart peripherals are not created, but access to the same Uart peripheral is used each time.
  7. The removal of copy construction for modules means that application developers do not have to worry about accidently performing copies of modules with seperate and inconsistent state. This will also help prevent the peripheral factories from generating copies on accident.

Additional changes:

codecov[bot] commented 3 years ago

Codecov Report

Merging #1425 (c05085e) into master (6dc595e) will increase coverage by 1.0%. The diff coverage is 73.1%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #1425     +/-   ##
========================================
+ Coverage    59.1%   60.0%   +1.0%     
========================================
  Files          94      94             
  Lines        4598    4492    -106     
  Branches      980     965     -15     
========================================
- Hits         2713    2693     -20     
+ Misses       1627    1566     -61     
+ Partials      258     233     -25     
Impacted Files Coverage Δ
library/L1_Peripheral/adc.hpp 25.0% <0.0%> (+5.0%) :arrow_up:
library/L1_Peripheral/dac.hpp 0.0% <ø> (ø)
library/L1_Peripheral/gpio.hpp 33.4% <ø> (+1.2%) :arrow_up:
library/L1_Peripheral/i2c.hpp 54.9% <ø> (+3.4%) :arrow_up:
library/L1_Peripheral/interrupt.hpp 42.9% <0.0%> (-3.2%) :arrow_down:
library/L1_Peripheral/lpc17xx/pin.hpp 19.3% <0.0%> (+2.0%) :arrow_up:
library/L1_Peripheral/pwm.hpp 0.0% <ø> (ø)
library/L1_Peripheral/spi.hpp 0.0% <ø> (ø)
library/L1_Peripheral/stm32f10x/spi.hpp 0.0% <0.0%> (ø)
library/L1_Peripheral/stm32f4xx/gpio.hpp 76.2% <ø> (+3.5%) :arrow_up:
... and 66 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6dc595e...257509e. Read the comment docs.