Skip to content

Commit

Permalink
Fix for F303
Browse files Browse the repository at this point in the history
  • Loading branch information
pazi88 committed Mar 21, 2024
1 parent 6b027a2 commit a30339c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/compile-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- fqbn: "Nucleo_144"
- fqbn: "GenF0:pnum=GENERIC_F042F6PX"
- fqbn: "GenF1:pnum=GENERIC_F103C8TX"
- fqbn: "GenF3:pnum=GENERIC_F303RETX"
- fqbn: "GenF4:pnum=GENERIC_F412RETX"
- fqbn: "GenF4:pnum=GENERIC_F407VETX"

Expand Down
15 changes: 0 additions & 15 deletions STM32_CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,12 @@ void STM32_CAN::begin( bool retransmission ) {
}
#endif


#if defined(STM32F0xx)
// NVIC configuration for CAN1
HAL_NVIC_SetPriority(CEC_CAN_IRQn, 15, 0);
HAL_NVIC_EnableIRQ(CEC_CAN_IRQn);
#else
// NVIC configuration for CAN1 Reception complete interrupt
HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 15, 0); // 15 is lowest possible priority
HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn );
// NVIC configuration for CAN1 Transmission complete interrupt
HAL_NVIC_SetPriority(CAN1_TX_IRQn, 15, 0); // 15 is lowest possible priority
HAL_NVIC_EnableIRQ(CAN1_TX_IRQn);
#endif

n_pCanHandle->Instance = CAN1;
}
Expand Down Expand Up @@ -767,11 +760,7 @@ void STM32_CAN::enableMBInterrupts()
{
if (n_pCanHandle->Instance == CAN1)
{
#if defined(STM32F0xx)
HAL_NVIC_EnableIRQ(CEC_CAN_IRQn);
#else
HAL_NVIC_EnableIRQ(CAN1_TX_IRQn);
#endif
}
#ifdef CAN2
else if (n_pCanHandle->Instance == CAN2)
Expand All @@ -791,11 +780,7 @@ void STM32_CAN::disableMBInterrupts()
{
if (n_pCanHandle->Instance == CAN1)
{
#if defined(STM32F0xx)
HAL_NVIC_EnableIRQ(CEC_CAN_IRQn);
#else
HAL_NVIC_DisableIRQ(CAN1_TX_IRQn);
#endif
}
#ifdef CAN2
else if (n_pCanHandle->Instance == CAN2)
Expand Down
15 changes: 15 additions & 0 deletions STM32_CAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ to same folder with sketch and haven #define HAL_CAN_MODULE_ENABLED there. See e
#ifndef STM32_CAN_H
#define STM32_CAN_H

// couple of workarounds
#if defined(STM32F3xx)
#define GPIO_AF9_CAN1 GPIO_AF9_CAN
#define CAN1_RX0_IRQn CAN_RX0_IRQn
#define CAN1_TX_IRQn CAN_TX_IRQn
#define GPIO_SPEED_FREQ_VERY_HIGH GPIO_SPEED_FREQ_HIGH
#define CAN1_TX_IRQHandler CAN_TX_IRQHandler
#define CAN1_RX0_IRQHandler CAN_RX0_IRQHandler
#endif

#if defined(STM32F0xx)
#define CAN1_TX_IRQn CEC_CAN_IRQn
#define CAN1_RX0_IRQn CEC_CAN_IRQn
#endif

#include <Arduino.h>

// This struct is directly copied from Teensy FlexCAN library to retain compatibility with it. Not all are in use with STM32.
Expand Down

1 comment on commit a30339c

@pazi88
Copy link
Owner Author

@pazi88 pazi88 commented on a30339c Mar 21, 2024

Choose a reason for hiding this comment

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

fixes #15

Please sign in to comment.