-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
drivers/can: add board_candev_set_power() hook #21203
base: master
Are you sure you want to change the base?
Conversation
This provides a default (weak) implementation of void board_candev_set_power(candev_t *dev, bool active); that is a no-op, and adds calls to this function to each and every CAN controller driver. The idea is that a board can provide this, if it can power up and down the CAN transceivers, freeing applications from having to add board specific hacks to enable CAN transceivers. In addition, the following two helpers are added: can_t *candev2periph(candev_t *candev); candev_mcp2515_t *candev2mcp2515(candev_t *candev); These safely convert a `candev_t` pointer back to the underlying type, return `NULL` if the given `candev_t *` is not of the requested type. This aids in implementing `board_candev_set_power()`, as it provides a board with the means to figure out for which CAN controller the CAN transceiver needs to be enabled/disabled for.
Now that the CAN transceiver is controlled by the board hook in the CAN driver, we don't need the board specific hack any more.
@gdoffe: Would you mind to take a look at this as well, since you just now worked on the STM32 CAN driver? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the overall idea but I don't have the hardware to test.
Co-authored-by: Dylan Laduranty <[email protected]>
Co-authored-by: Dylan Laduranty <[email protected]>
This reminds me a bit of |
Indeed, this is trying to solve the same problem. What a mess the CAN stack in RIOT is 😅 I guess the correct thing to do would be to hook up that instead.
That would be nice, but non-trivial to do. Deep integration into the CAN driver by adding a some I wonder if the complexity |
I agree - the fact that it's so overengeneered that nobody is using it should be telling. |
Contribution description
This provides a default (weak) implementation of
that is a no-op, and adds calls to this function to each and every CAN controller driver. The idea is that a board can provide this, if it can power up and down the CAN transceivers, freeing applications from having to add board specific hacks to enable CAN transceivers.
In addition, the following two helpers are added:
These safely convert a
candev_t
pointer back to the underlying type, returnNULL
if the givencandev_t *
is not of the requested type. This aids in implementingboard_candev_set_power()
, as it provides a board with the means to figure out for which CAN controller the CAN transceiver needs to be enabled/disabled for.Finally, the new board hook is added for the
same54-xpro
and the board specific hacks fromtests/drivers/candev
are dropped.Testing procedure
Issues/PRs references
None