Change CAN to 1 Mbaud instead of 666.667 Kbaud; put can_init in ifdef
This commit is contained in:
2
can.c
2
can.c
@ -144,7 +144,7 @@ void can_init(void)
|
|||||||
CanHandle.Init.Mode = CAN_MODE_NORMAL;
|
CanHandle.Init.Mode = CAN_MODE_NORMAL;
|
||||||
CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
CanHandle.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||||
CanHandle.Init.TimeSeg1 = CAN_BS1_6TQ;
|
CanHandle.Init.TimeSeg1 = CAN_BS1_6TQ;
|
||||||
CanHandle.Init.TimeSeg2 = CAN_BS2_5TQ;
|
CanHandle.Init.TimeSeg2 = CAN_BS2_1TQ;
|
||||||
CanHandle.Init.Prescaler = 4;
|
CanHandle.Init.Prescaler = 4;
|
||||||
|
|
||||||
if (HAL_CAN_Init(&CanHandle) != HAL_OK)
|
if (HAL_CAN_Init(&CanHandle) != HAL_OK)
|
||||||
|
7
main.cpp
7
main.cpp
@ -229,14 +229,15 @@ int main()
|
|||||||
//#define UART_DMA_CHANNEL DMA1_Channel2
|
//#define UART_DMA_CHANNEL DMA1_Channel2
|
||||||
//UART3_Init();
|
//UART3_Init();
|
||||||
|
|
||||||
|
#ifdef FEATURE_CAN
|
||||||
|
can_init();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef MOTOR_TEST
|
#ifdef MOTOR_TEST
|
||||||
int pwm = 0;
|
int pwm = 0;
|
||||||
int8_t dir = 1;
|
int8_t dir = 1;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
can_config();
|
|
||||||
MODIFY_REG(RCC->CR, RCC_CR_HSITRIM, (0x1aU << RCC_CR_HSITRIM_Pos));
|
|
||||||
|
|
||||||
#ifndef FEATURE_CAN
|
#ifndef FEATURE_CAN
|
||||||
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&command, sizeof(command));
|
HAL_UART_Receive_DMA(&huart2, (uint8_t *)&command, sizeof(command));
|
||||||
#endif // FEATURE_CAN
|
#endif // FEATURE_CAN
|
||||||
|
Reference in New Issue
Block a user