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

Draft: Initial FDCAN support #30

Merged
merged 1 commit into from
Oct 4, 2021
Merged

Conversation

luctius
Copy link
Collaborator

@luctius luctius commented Aug 30, 2021

Initial support for CAN and FDCAN.

The CAN and FDCAN are two modules, and I'm still unsure how to do this. Part of it is taken from BxCAN, and the idea is that with a bit of effort FDCAN could be a separate crate as well, but with how the Message RAM works this seems to be more difficult than with BxCAN.

@luctius luctius changed the title Initial FDCAN support DRAFT: Initial FDCAN support Aug 30, 2021
@luctius luctius changed the title DRAFT: Initial FDCAN support Draft: Initial FDCAN support Aug 30, 2021
@luctius luctius force-pushed the features/fdcan branch 2 times, most recently from 590da9a to 766b49a Compare August 30, 2021 10:31
@mgottschlag
Copy link
Contributor

mgottschlag commented Aug 31, 2021

I've written a tool to print the pin mappings for user-specified peripherals, as I did not find anything similar before. This tool results in the following output for CAN:

FDCAN1_RX:
  PA11 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PB8-BOOT0 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PD0 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
FDCAN1_TX:
  PA12 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PB9 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PD1 (STM32G431, STM32G441, STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
FDCAN2_RX:
  PB12 (STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PB5 (STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
FDCAN2_TX:
  PB13 (STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
  PB6 (STM32G471, STM32G473, STM32G474, STM32G483, STM32G484, STM32G491, STM32G4A1)
FDCAN3_RX:
  PA8 (STM32G473, STM32G474, STM32G483, STM32G484)
  PB3 (STM32G473, STM32G474, STM32G483, STM32G484)
FDCAN3_TX:
  PA15 (STM32G473, STM32G474, STM32G483, STM32G484)
  PB4 (STM32G473, STM32G474, STM32G483, STM32G484)

If this is helpful to you, see https://github.com/mgottschlag/stm32-pin-tools.

Is CAN limited to these specific pin pairs, or is it possible to mix any RX and TX pin, just like with other peripherals?

@luctius
Copy link
Collaborator Author

luctius commented Aug 31, 2021

Oh, that is helpful indeed, thanks!

Is CAN limited to these specific pin pairs, or is it possible to mix any RX and TX pin, just like with other peripherals?

Good point, I need to implement it more generally, though my first focus is to get this actually working ;-).

@luctius luctius marked this pull request as ready for review September 17, 2021 11:15
@luctius
Copy link
Collaborator Author

luctius commented Sep 17, 2021

FDCAN is working now; and I've reorganised things a bit.

Since the PR is rather big, some comments would be welcome.

I do think that some things can be simplified somewhat, but overall I think it is a good starting point.

@luctius luctius merged commit 6beea3b into stm32-rs:master Oct 4, 2021
@luctius luctius deleted the features/fdcan branch October 4, 2021 12:35
@richardeoin
Copy link
Member

I copied this FDCAN support to use on the STM32H7, and with a few minor tweaks I was able to get the basic echo example working on a STM32H735. PR here. As a courtesy I also made an issue on this repo #34 with some items I noticed whilst reading the code.

My preference would be to move this FDCAN support into a common crate at stm32-rs/fdcan so that bugfixes and developments can be used by all devices. If no one has any objections, I will create a skeleton project there with the intention of copying this FDCAN support over. Collaboration would be very welcome!

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.

3 participants