diff --git a/include/config.h b/include/config.h index 7aa24db..2aefc0e 100644 --- a/include/config.h +++ b/include/config.h @@ -53,6 +53,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "bytewerk" #define DFU_INTERFACE_STRING_FS (uint8_t*) "candleLight firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -74,6 +76,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "makerbase" #define DFU_INTERFACE_STRING_FS (uint8_t*) "CANable-MKS firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -94,6 +98,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "ConvertDevice" #define DFU_INTERFACE_STRING_FS (uint8_t*) "ConvertDevice xCAN firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -113,6 +119,9 @@ THE SOFTWARE. #define USBD_PRODUCT_STRING_FS (uint8_t*) "ConvertDevice xCANFD" #define USBD_MANUFACTURER_STRING (uint8_t*) "ConvertDevice" #define DFU_INTERFACE_STRING_FS (uint8_t*) "ConvertDevice xCANFD firmware upgrade interface" + + #define TIM2_CLOCK_SPEED 64000000 + #define CAN_INTERFACE FDCAN1 #define CAN_CLOCK_SPEED 64000000 #define NUM_CAN_CHANNEL 1 @@ -141,6 +150,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "DSD TECH" #define DFU_INTERFACE_STRING_FS (uint8_t*) "SH-C30A firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -161,6 +172,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "FYSETC" #define DFU_INTERFACE_STRING_FS (uint8_t*) "UCAN firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -181,6 +194,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "cantact.io" #define DFU_INTERFACE_STRING_FS (uint8_t*) "cantact firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -201,6 +216,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "canable.io" #define DFU_INTERFACE_STRING_FS (uint8_t*) "canable firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -221,6 +238,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "Roboter Club Aachen" #define DFU_INTERFACE_STRING_FS (uint8_t*) "usb2can firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -251,6 +270,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "STMicroelectronics" #define DFU_INTERFACE_STRING_FS (uint8_t*) "CANAlyze firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -271,6 +292,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "chacaltech" #define DFU_INTERFACE_STRING_FS (uint8_t*) "cannette firmware upgrade interface" + #define TIM2_CLOCK_SPEED 48000000 + #define CAN_INTERFACE CAN #define CAN_CLOCK_SPEED 48000000 @@ -300,6 +323,9 @@ THE SOFTWARE. #define USBD_PRODUCT_STRING_FS (uint8_t*) "budgetcan gs_usb" #define USBD_MANUFACTURER_STRING (uint8_t*) "budgetcan" #define DFU_INTERFACE_STRING_FS (uint8_t*) "budgetcan firmware upgrade interface" + + #define TIM2_CLOCK_SPEED 64000000 + #define CAN_INTERFACE FDCAN1 #define CAN_INTERFACE2 FDCAN2 #define CAN_CLOCK_SPEED 64000000 @@ -334,6 +360,8 @@ THE SOFTWARE. #define USBD_MANUFACTURER_STRING (uint8_t*) "misc" #define DFU_INTERFACE_STRING_FS (uint8_t*) "STM32F4VE firmware upgrade interface" + #define TIM2_CLOCK_SPEED 96000000 + #define CAN_INTERFACE CAN1 #define CAN_CLOCK_SPEED 42000000 diff --git a/src/timer.c b/src/timer.c index fd40fe1..33e0860 100644 --- a/src/timer.c +++ b/src/timer.c @@ -24,8 +24,9 @@ THE SOFTWARE. */ -#include "timer.h" +#include "config.h" #include "hal_include.h" +#include "timer.h" void timer_init(void) { @@ -38,7 +39,7 @@ void timer_init(void) TIM2->CCMR1 = 0; TIM2->CCMR2 = 0; TIM2->CCER = 0; - TIM2->PSC = 48-1; // run @48MHz/480 = 1MHz = 1us + TIM2->PSC = (TIM2_CLOCK_SPEED / 1000000) - 1; // run @1MHz = 1us TIM2->ARR = 0xFFFFFFFF; TIM2->CR1 |= TIM_CR1_CEN; TIM2->EGR = TIM_EGR_UG;