2022-08-04 12:36 AM
good afternoon friends.
I am learning to work with SUN.
I want to receive parcels from 2 addresses. In principle, it works, but the values from two addresses are written to one array.
How to make it so that values from different addresses are written to different arrays?
void MX_CAN_Init(void)
{
/* USER CODE BEGIN CAN_Init 0 */
CAN_FilterTypeDef sFilterConfig;
CAN_FilterTypeDef sFilterConfig_pravite;
/* USER CODE END CAN_Init 0 */
/* USER CODE BEGIN CAN_Init 1 */
/* USER CODE END CAN_Init 1 */
hcan.Instance = CAN1;
hcan.Init.Prescaler = 8;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan.Init.TimeSeg1 = CAN_BS1_3TQ;
hcan.Init.TimeSeg2 = CAN_BS2_5TQ;
hcan.Init.TimeTriggeredMode = DISABLE;
hcan.Init.AutoBusOff = DISABLE;
hcan.Init.AutoWakeUp = DISABLE;
hcan.Init.AutoRetransmission = DISABLE;
hcan.Init.ReceiveFifoLocked = ENABLE;
hcan.Init.TransmitFifoPriority = ENABLE;
if (HAL_CAN_Init(&hcan) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN CAN_Init 2 */
sFilterConfig.FilterBank = 0;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterIdLow = (uint16_t)(0x18FEEE00 << 3) | 0x04;
sFilterConfig.FilterMaskIdHigh = (uint16_t)(0x18FEEE00 >> 13);
sFilterConfig.FilterMaskIdLow = (uint16_t)(0x18FEEE00 << 3) | 0x04;
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
sFilterConfig.SlaveStartFilterBank = 14;
sFilterConfig_pravite = sFilterConfig;
sFilterConfig_pravite.FilterBank = 1;
sFilterConfig_pravite.FilterIdHigh = (uint16_t)(0x0CF00300 >> 13);
sFilterConfig_pravite.FilterIdLow = (uint16_t)(0x0CF00300 << 3) | 0x04;
sFilterConfig_pravite.FilterMaskIdHigh = (uint16_t)(0x0CF00300 >> 13);
sFilterConfig_pravite.FilterMaskIdLow = (uint16_t)(0x0CF00300 << 3) | 0x04;
sFilterConfig_pravite.FilterIdHigh = (uint16_t)(0x18FEEE00 >> 13);
if(HAL_CAN_ConfigFilter(&hcan, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
if(HAL_CAN_ConfigFilter(&hcan, &sFilterConfig_pravite) != HAL_OK)
{
Error_Handler();
}
/* USER CODE END CAN_Init 2 */
}
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
if(HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxDataa) == HAL_OK)
{
HAL_GPIO_TogglePin(LED_plate_GPIO_Port, LED_plate_Pin);
}
}
2022-08-04 12:45 AM
Perhaps starts by filling the structures properly, and directing different messages to different FIFOs.
Or as you pull the data into a holding buffer decode the address and then direct it into the appropriate queue in your implementation.
2022-08-04 12:50 AM
help how to do it?