From 8a9cdf107608197fde7a1ff55e8a077873aabb6a Mon Sep 17 00:00:00 2001 From: Ryan Edwards Date: Mon, 31 Oct 2022 21:51:33 -0400 Subject: [PATCH] config.h: move the CAN_INTERFACE and CAN_CLOCK_SPEED to the config.h 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. --- include/config.h | 25 +++++++++++++++++++++++++ include/usbd_gs_can.h | 12 ++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/config.h b/include/config.h index 0b38312..b2a388f 100644 --- a/include/config.h +++ b/include/config.h @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/include/usbd_gs_can.h b/include/usbd_gs_can.h index 405d6ad..e09043e 100644 --- a/include/usbd_gs_can.h +++ b/include/usbd_gs_can.h @@ -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