stm32-rs / stm32l4xx-hal

A Hardware abstraction layer for the stm32l432xx series chips written in rust.
156 stars 103 forks source link

Replace `Date` and `Time` types with `time` crate. #310

Closed reitermarkus closed 2 years ago

reitermarkus commented 2 years ago

Similar to stm32f4xx-hal.

korken89 commented 2 years ago

Hi,

Please expand on what is the improvement related to this PR?

reitermarkus commented 2 years ago

Instead of custom Date and Time types, use the types from the time crate. A combined DateTime type is much more ergonomic to work with than a (Date, Time) tuple, e.g. when calculating time difference.

reitermarkus commented 2 years ago

The same was done for the F4 and F7 HALs.

https://github.com/stm32-rs/stm32f4xx-hal/pull/436 https://github.com/stm32-rs/stm32f7xx-hal/pull/162

korken89 commented 2 years ago

I see, ergonomics is always nice. Next question, how does this time crate impact code size compared to what is used today? Having a look at the time crate its not clear.

reitermarkus commented 2 years ago

code size compared to what is used today

Time today is 17 bytes, time::Time is 8 bytes. Date today is 16 bytes, time::Date is 4 bytes. Other than that there's not much you can do today other than access the struct fields.

korken89 commented 2 years ago

Sounds good, no major change then!