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

Support for PB8/PA12 CAN pin mapping on STM32F042 #36

Open
sshsphere opened this issue May 21, 2024 · 1 comment
Open

Support for PB8/PA12 CAN pin mapping on STM32F042 #36

sshsphere opened this issue May 21, 2024 · 1 comment

Comments

@sshsphere
Copy link

It would be nice if this library natively supported use of PB8 (CAN RX) and PA12 (CAN TX) for the CAN interface.

This code generated from CubeIDE might be helpful:

__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_CAN;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_CAN;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

I added this option to the begin function in STM32_CAN.cpp and everything works perfectly

@pazi88
Copy link
Owner

pazi88 commented May 21, 2024

Ok. Good to know that it works. I'll see what I can do. Some use different way of setting up the pins that are used and in those you can only use the pin pairs that are currently available in the library. I need to think best way to do that.

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

No branches or pull requests

2 participants