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

add support for multichannel and CAN-FD #139

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

Conversation

marckleinebudde
Copy link
Contributor

@marckleinebudde marckleinebudde commented Nov 17, 2022

This PR should add multichannel and CAN-FD support. Currently it's WIP.

src/main.c Outdated Show resolved Hide resolved
src/main.c Outdated
struct gs_host_frame *msgbuf = calloc(CAN_QUEUE_SIZE, sizeof(struct gs_host_frame));
assert_basic(msgbuf);
can_init(channel, CAN_INTERFACE);
can_disable(channel);

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we come up with a better way of handling the init? Rather have some type of indexed table with [channel][CAN_INTERFACE] instead of having to add defines here for each new channel.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean a read only array of structs, with a struct describing the HW configuration of a single channel. Sounds good. Which information do we need per channel?

src/usbd_gs_can.c Show resolved Hide resolved
memcpy(&param_u32, hcan->ep0_buf, sizeof(param_u32));
if (set_term(req->wValue, param_u32) == GS_CAN_TERMINATION_UNSUPPORTED) {
USBD_CtlError(pdev, req);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Termination GPIO is channel based. Should we stub that out here as part of the multichannel change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should come after we thought about per channel configuration.

@marckleinebudde marckleinebudde force-pushed the multichannel branch 3 times, most recently from d1e0c57 to 203cfac Compare November 20, 2022 19:34
@marckleinebudde
Copy link
Contributor Author

It's not yet stable, canfdtest -vg can0 stops after some minutes.

include/can-common.h Outdated Show resolved Hide resolved
@marckleinebudde
Copy link
Contributor Author

marckleinebudde commented Nov 20, 2022

changes:

  • renamed can-common.* to can_common.*

@marckleinebudde
Copy link
Contributor Author

marckleinebudde commented Nov 20, 2022

changes:

  • fixed includes

@marckleinebudde
Copy link
Contributor Author

changes:

  • import latest struct gs_host_frame with flex arrays from Linux kernel
  • USB: add some support for CAN-FD

@marckleinebudde marckleinebudde changed the title add support for multichannel add support for multichannel and CAN-FD Nov 21, 2022
@marckleinebudde
Copy link
Contributor Author

marckleinebudde commented Dec 5, 2022

FYI: @lichtfeind will now work on STM32G0 support.

include/usbd_gs_can.h Outdated Show resolved Hide resolved
@marckleinebudde marckleinebudde force-pushed the multichannel branch 4 times, most recently from a8a5d83 to 48b2f1d Compare June 10, 2024 09:51
HAL_GPIO_Init(LEDRX_GPIO_Port, &GPIO_InitStruct);

/* FDCAN */

Copy link

Choose a reason for hiding this comment

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

FWIW - To get this to work with Adafruit "CAN Pal" TJA1051T/3 breakout board( https://www.adafruit.com/product/5708 ) , I needed to connected the transceiver silent (SLNT) pin to GND.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In your board file you can implement the struct BoardConfig::phy_power_set callback and pull the transceiver's silent pin into the correct direction depending on the value of the enable parameter.

@trentatsa
Copy link

@marckleinebudde, is CANFD fully supported on G0 based devices ? I have recently purchased candleLight FD from linux automation and im looking for something that works out the box.

@marckleinebudde
Copy link
Contributor Author

@marckleinebudde, is CANFD fully supported on G0 based devices ? I have recently purchased candleLight FD from linux automation and im looking for something that works out the box.

The device comes pre-flashed with a working firmware.

@pramilo
Copy link

pramilo commented Nov 14, 2024

Hi all

Can you pls clarify if this has finally been merged to main_dev - or - if we need to get code from [marckleinebudde]'s (https://github.com/marckleinebudde) fork?

The discussion seems to indicate support for the G0 is mature, but it's unclear if/what's been merged to this main branch.

Thanks,

@marckleinebudde
Copy link
Contributor Author

It's not mainline. Please use https://github.com/marckleinebudde/candleLight_fw/tree/multichannel for now

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.