Skip to content

Commit

Permalink
config.h: move the CAN_INTERFACE and CAN_CLOCK_SPEED to the config.h
Browse files Browse the repository at this point in the history
Move CAN_INTERFACE and CAN_CLOCK_SPEED to the config file as the CAN
clock can vary based on HW implementation.

Better to add it here than to keep adding defines into the
usbd_gs_can.h file.

CAN_INTERFACE can vary based on the number of channels you are using
so also makes sense to add here even though most chips use the same
interface ID.
  • Loading branch information
ryedwards authored and marckleinebudde committed Nov 9, 2022
1 parent 8f9fa77 commit 8a9cdf1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
25 changes: 25 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ THE SOFTWARE.
#define USBD_PRODUCT_STRING_FS (uint8_t*) "candleLight USB to CAN adapter"
#define USBD_MANUFACTURER_STRING (uint8_t*) "bytewerk"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLight firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

#define CAN_S_Pin GPIO_PIN_13
#define CAN_S_GPIO_Port GPIOC

Expand All @@ -70,6 +74,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "makerbase"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "CANable-MKS firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LEDRX_GPIO_Port GPIOA
Expand All @@ -87,6 +94,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "cantact.io"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "cantact firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LEDRX_GPIO_Port GPIOB
Expand All @@ -104,6 +114,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "canable.io"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "canable firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LEDRX_GPIO_Port GPIOB
Expand All @@ -121,6 +134,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "Roboter Club Aachen"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "usb2can firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LED4_GPIO_Port GPIOA
Expand Down Expand Up @@ -148,6 +164,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "STMicroelectronics"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "CANAlyze firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LEDRX_GPIO_Port GPIOB
Expand All @@ -165,6 +184,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "chacaltech"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "cannette firmware upgrade interface"

#define CAN_INTERFACE CAN
#define CAN_CLOCK_SPEED 48000000

// SILENT pin not connected

#define LEDRX_GPIO_Port GPIOA
Expand Down Expand Up @@ -192,6 +214,9 @@ THE SOFTWARE.
#define USBD_MANUFACTURER_STRING (uint8_t*) "misc"
#define DFU_INTERFACE_STRING_FS (uint8_t*) "STM32F4VE firmware upgrade interface"

#define CAN_INTERFACE CAN1
#define CAN_CLOCK_SPEED 42000000

#define CAN_S_Pin GPIO_PIN_10
#define CAN_S_GPIO_Port GPIOA

Expand Down
12 changes: 4 additions & 8 deletions include/usbd_gs_can.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,11 @@ extern USBD_ClassTypeDef USBD_GS_CAN;


#if defined(STM32F0)
# define USB_INTERFACE USB
# define USB_INTERRUPT USB_IRQn
# define CAN_INTERFACE CAN
# define CAN_CLOCK_SPEED 48000000
# define USB_INTERFACE USB
# define USB_INTERRUPT USB_IRQn
#elif defined(STM32F4)
# define USB_INTERFACE USB_OTG_FS
# define USB_INTERRUPT OTG_FS_IRQn
# define CAN_INTERFACE CAN1
# define CAN_CLOCK_SPEED 42000000
# define USB_INTERFACE USB_OTG_FS
# define USB_INTERRUPT OTG_FS_IRQn

// RX FIFO is defined in words, so divide bytes by 4
// RX FIFO size chosen according to reference manual RM0368 which suggests
Expand Down

0 comments on commit 8a9cdf1

Please sign in to comment.