corrected and verified can bus output
This commit is contained in:
@ -94,30 +94,28 @@ int main(void) {
|
||||
MX_SPI1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
// CAN_FilterTypeDef canfilterconfig;
|
||||
// canfilterconfig.FilterActivation = ENABLE;
|
||||
// canfilterconfig.FilterBank = 1; // which filter bank to use from the assigned ones
|
||||
// canfilterconfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
|
||||
// canfilterconfig.FilterIdHigh = 0x0000;
|
||||
// canfilterconfig.FilterIdLow = 0x0000;
|
||||
// canfilterconfig.FilterMaskIdHigh = 0x0000;
|
||||
// canfilterconfig.FilterMaskIdLow = 0x0000;
|
||||
// canfilterconfig.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||
// canfilterconfig.FilterScale = CAN_FILTERSCALE_32BIT;
|
||||
// canfilterconfig.SlaveStartFilterBank = 20; // how many filters to assign to the CAN1 (master can)
|
||||
// HAL_CAN_ConfigFilter(&hcan, &canfilterconfig);
|
||||
CAN_FilterTypeDef canfilterconfig;
|
||||
canfilterconfig.FilterActivation = ENABLE;
|
||||
canfilterconfig.FilterBank = 1; // which filter bank to use from the assigned ones
|
||||
canfilterconfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
|
||||
canfilterconfig.FilterIdHigh = 0x0000;
|
||||
canfilterconfig.FilterIdLow = 0x0000;
|
||||
canfilterconfig.FilterMaskIdHigh = 0x0000;
|
||||
canfilterconfig.FilterMaskIdLow = 0x0000;
|
||||
canfilterconfig.FilterMode = CAN_FILTERMODE_IDMASK;
|
||||
canfilterconfig.FilterScale = CAN_FILTERSCALE_32BIT;
|
||||
canfilterconfig.SlaveStartFilterBank = 20; // how many filters to assign to the CAN1 (master can)
|
||||
HAL_CAN_ConfigFilter(&hcan, &canfilterconfig);
|
||||
ftcan_init(&hcan);
|
||||
ftcan_add_filter(&hcan, 0x10, 0x0000);
|
||||
// if (HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK) {
|
||||
// Error_Handler();
|
||||
// }
|
||||
// ftcan_add_filter(&hcan, 0x10, 0x0000);
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
/* USER CODE BEGIN WHILE */
|
||||
while (1) {
|
||||
// spi2can(&hspi1, &hcan);
|
||||
spi2can(&hspi1, &hcan);
|
||||
HAL_Delay(100);
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
@ -171,11 +169,11 @@ static void MX_CAN_Init(void) {
|
||||
|
||||
/* USER CODE END CAN_Init 1 */
|
||||
hcan.Instance = CAN;
|
||||
hcan.Init.Prescaler = 8;
|
||||
hcan.Init.Prescaler = 2;
|
||||
hcan.Init.Mode = CAN_MODE_NORMAL;
|
||||
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
|
||||
hcan.Init.TimeSeg1 = CAN_BS1_2TQ;
|
||||
hcan.Init.TimeSeg2 = CAN_BS2_1TQ;
|
||||
hcan.Init.TimeSeg1 = CAN_BS1_13TQ;
|
||||
hcan.Init.TimeSeg2 = CAN_BS2_2TQ;
|
||||
hcan.Init.TimeTriggeredMode = DISABLE;
|
||||
hcan.Init.AutoBusOff = DISABLE;
|
||||
hcan.Init.AutoWakeUp = DISABLE;
|
||||
|
||||
Reference in New Issue
Block a user