4 ms·
Maybe defining a "Port" trait and using the dynamic type instead of the static one is a solution.
by rhn_mk1 6y ago
Maybe defining a "Port" trait and using the dynamic type instead of the static one is a solution.
- rcxdude 6y agoPerhaps, but it sucks from a performance point of view. In embedded for a lot of operations you want the HAL to compile down to one or two instructions (GPIO being a classic example of this). Dynamic indirection is proportionally very expensive here (though in embedded a lot of the other costs normally associated with pointers are a lot less, since the memory hierarchy is very shallow).
- pas 6y agoenum_dispatch to the rescue! (or at least that is what it says on the tin: https://docs.rs/enum_dispatch/0.3.5/enum_dispatch/ https://docs.rs/enum_dispatch/0.3.5/enum_dispatch/ )