Skip to content
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

CAN driver for Stm32g0 FDCAN #813

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

CAN driver for Stm32g0 FDCAN #813

wants to merge 13 commits into from

Conversation

balazsracz
Copy link
Collaborator

Abstracts the TCAN4550 driver into a generic Bosch MCAN driver and a specialization for the TCAN4550.
Adds new specialization for the STM32 FDCAN controller.

Makes Register a strongly typed enum and updates all usages.
Starts prepping for a message buffer of a different size.
Refactors the TCAN's global insterrupt status clear code into a device-specific function.
- Fixes TX message buffer size.
- Forks some registers that are different in the TCAN and STM32 FDCAN
- Makes message buffer reads and writes be word oriented.
Rearranges the enums. Updates register_read/write for the 4550.
Renames MCANCan to MCAN.

Adds todos for some refactoring.
Copy link
Owner

@bakerstu bakerstu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs a lot of cleanup, which we already had a discussion about. It is probably good enough to merge though, and get some runtime on the STM32G0 MCAN. We'll have to come back and refactor this later for to converge for other MCAN based devices.

RSVD11, ///< reserved
RSVD12, ///< reserved
RSVD13, ///< reserved
// From here on the register offsets differ between
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commentary about STM32 differences belongs in the STM32MCAN.hxx file.

};

template<unsigned DATA_BYTES>
struct MCANCommonDefs {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brace style

/// @param rx_timeout_bits timeout in CAN bit periods for rx interrupt
void init(const char *spi_name, uint32_t freq, uint32_t baud,
uint16_t rx_timeout_bits);
/// These registers exist in the Bosch MCAN but not with the same layout in the
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commentary belongs in the STM32MCAN file(s).

* @file TCAN4550Can.hxx
* This file implements the CAN driver for the TCAN4550 CAN Controller.
* @file MCAN.hxx
* This file implements a generic CAN driver for the MCAN controller IP.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is a good idea to summarize here what should eventually be moved out of this file related to TCAN4550 and/or STM32MCAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants