From 2c7b7934eda7faeaa75bc50848ccde371604990d Mon Sep 17 00:00:00 2001 From: rusefi Date: Tue, 16 Oct 2018 21:31:48 -0400 Subject: [PATCH] options --- firmware/hw_layer/can_hw.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/firmware/hw_layer/can_hw.cpp b/firmware/hw_layer/can_hw.cpp index 6fda5fa9a5..bd4f45d11b 100644 --- a/firmware/hw_layer/can_hw.cpp +++ b/firmware/hw_layer/can_hw.cpp @@ -14,11 +14,6 @@ #include "string.h" #include "obd2.h" -#if EFI_PROD_CODE || defined(__DOXYGEN__) - - -#endif /* EFI_PROD_CODE */ - #if EFI_CAN_SUPPORT || defined(__DOXYGEN__) #include "pin_repository.h" @@ -49,10 +44,19 @@ static THD_WORKING_AREA(canTreadStack, UTILITY_THREAD_STACK_SIZE); * 29 bit would be CAN_TI0R_EXID (?) but we do not mention it here * CAN_TI0R_STID "Standard Identifier or Extended Identifier"? not mentioned as well */ -static const CANConfig canConfig = { +static const CANConfig canConfig500 = { CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP, CAN_BTR_SJW(0) | CAN_BTR_TS2(1) | CAN_BTR_TS1(8) | CAN_BTR_BRP(6) }; +/* + * speed = 42000000 / (BRP + 1) / (1 + TS1 + 1 + TS2 + 1) + * 42000000 / 7 / 6 = 1000000 + * + */ +static const CANConfig canConfig1000 = { +CAN_MCR_ABOM | CAN_MCR_AWUM | CAN_MCR_TXFP, +CAN_BTR_SJW(0) | CAN_BTR_TS2(1) | CAN_BTR_TS1(2) | CAN_BTR_BRP(6) }; + static CANRxFrame rxBuffer; CANTxFrame txmsg; @@ -315,10 +319,10 @@ void initCan(void) { #if STM32_CAN_USE_CAN2 || defined(__DOXYGEN__) // CAN1 is required for CAN2 - canStart(&CAND1, &canConfig); - canStart(&CAND2, &canConfig); + canStart(&CAND1, &canConfig500); + canStart(&CAND2, &canConfig500); #else - canStart(&CAND1, &canConfig); + canStart(&CAND1, &canConfig500); #endif /* STM32_CAN_USE_CAN2 */ chThdCreateStatic(canTreadStack, sizeof(canTreadStack), NORMALPRIO, (tfunc_t) canThread, NULL);