STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_can.c
Go to the documentation of this file.
1 
108 /* Includes ------------------------------------------------------------------*/
109 #include "stm32f7xx_hal.h"
110 
120 #ifdef HAL_CAN_MODULE_ENABLED
121 
122 
123 /* Private typedef -----------------------------------------------------------*/
124 /* Private define ------------------------------------------------------------*/
128 #define CAN_TIMEOUT_VALUE 10
129 
132 /* Private macro -------------------------------------------------------------*/
133 /* Private variables ---------------------------------------------------------*/
134 /* Private function prototypes -----------------------------------------------*/
138 static HAL_StatusTypeDef CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber);
139 static HAL_StatusTypeDef CAN_Transmit_IT(CAN_HandleTypeDef* hcan);
144 /* Exported functions --------------------------------------------------------*/
172 {
173  uint32_t InitStatus = CAN_INITSTATUS_FAILED;
174  uint32_t tickstart = 0;
175 
176  /* Check CAN handle */
177  if(hcan == NULL)
178  {
179  return HAL_ERROR;
180  }
181 
182  /* Check the parameters */
195 
196 
197  if(hcan->State == HAL_CAN_STATE_RESET)
198  {
199  /* Allocate lock resource and initialize it */
200  hcan->Lock = HAL_UNLOCKED;
201  /* Init the low level hardware */
202  HAL_CAN_MspInit(hcan);
203  }
204 
205  /* Initialize the CAN state*/
206  hcan->State = HAL_CAN_STATE_BUSY;
207 
208  /* Exit from sleep mode */
209  hcan->Instance->MCR &= (~(uint32_t)CAN_MCR_SLEEP);
210 
211  /* Request initialisation */
212  hcan->Instance->MCR |= CAN_MCR_INRQ ;
213 
214  /* Get tick */
215  tickstart = HAL_GetTick();
216 
217  /* Wait the acknowledge */
218  while((hcan->Instance->MSR & CAN_MSR_INAK) != CAN_MSR_INAK)
219  {
220  if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
221  {
223  /* Process unlocked */
224  __HAL_UNLOCK(hcan);
225  return HAL_TIMEOUT;
226  }
227  }
228 
229  /* Check acknowledge */
230  if ((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
231  {
232  /* Set the time triggered communication mode */
233  if (hcan->Init.TTCM == ENABLE)
234  {
235  hcan->Instance->MCR |= CAN_MCR_TTCM;
236  }
237  else
238  {
239  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_TTCM;
240  }
241 
242  /* Set the automatic bus-off management */
243  if (hcan->Init.ABOM == ENABLE)
244  {
245  hcan->Instance->MCR |= CAN_MCR_ABOM;
246  }
247  else
248  {
249  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_ABOM;
250  }
251 
252  /* Set the automatic wake-up mode */
253  if (hcan->Init.AWUM == ENABLE)
254  {
255  hcan->Instance->MCR |= CAN_MCR_AWUM;
256  }
257  else
258  {
259  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_AWUM;
260  }
261 
262  /* Set the no automatic retransmission */
263  if (hcan->Init.NART == ENABLE)
264  {
265  hcan->Instance->MCR |= CAN_MCR_NART;
266  }
267  else
268  {
269  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_NART;
270  }
271 
272  /* Set the receive FIFO locked mode */
273  if (hcan->Init.RFLM == ENABLE)
274  {
275  hcan->Instance->MCR |= CAN_MCR_RFLM;
276  }
277  else
278  {
279  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_RFLM;
280  }
281 
282  /* Set the transmit FIFO priority */
283  if (hcan->Init.TXFP == ENABLE)
284  {
285  hcan->Instance->MCR |= CAN_MCR_TXFP;
286  }
287  else
288  {
289  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_TXFP;
290  }
291 
292  /* Set the bit timing register */
293  hcan->Instance->BTR = (uint32_t)((uint32_t)hcan->Init.Mode) | \
294  ((uint32_t)hcan->Init.SJW) | \
295  ((uint32_t)hcan->Init.BS1) | \
296  ((uint32_t)hcan->Init.BS2) | \
297  ((uint32_t)hcan->Init.Prescaler - 1);
298 
299  /* Request leave initialisation */
300  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_INRQ;
301 
302  /* Get tick */
303  tickstart = HAL_GetTick();
304 
305  /* Wait the acknowledge */
306  while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
307  {
308  if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE)
309  {
311  /* Process unlocked */
312  __HAL_UNLOCK(hcan);
313  return HAL_TIMEOUT;
314  }
315  }
316 
317  /* Check acknowledged */
318  if ((hcan->Instance->MSR & CAN_MSR_INAK) != CAN_MSR_INAK)
319  {
320  InitStatus = CAN_INITSTATUS_SUCCESS;
321  }
322  }
323 
324  if(InitStatus == CAN_INITSTATUS_SUCCESS)
325  {
326  /* Set CAN error code to none */
328 
329  /* Initialize the CAN state */
330  hcan->State = HAL_CAN_STATE_READY;
331 
332  /* Return function status */
333  return HAL_OK;
334  }
335  else
336  {
337  /* Initialize the CAN state */
338  hcan->State = HAL_CAN_STATE_ERROR;
339 
340  /* Return function status */
341  return HAL_ERROR;
342  }
343 }
344 
355 {
356  uint32_t filternbrbitpos = 0;
357  CAN_TypeDef *can_ip;
358 
359  /* Check the parameters */
361  assert_param(IS_CAN_FILTER_MODE(sFilterConfig->FilterMode));
365  assert_param(IS_CAN_BANKNUMBER(sFilterConfig->BankNumber));
366 
367  filternbrbitpos = ((uint32_t)1) << sFilterConfig->FilterNumber;
368 #if defined (CAN3)
369  /* Check the CAN instance */
370  if(hcan->Instance == CAN3)
371  {
372  can_ip = CAN3;
373  }
374  else
375  {
376  can_ip = CAN1;
377  }
378 #else
379  can_ip = CAN1;
380 #endif
381 
382  /* Initialisation mode for the filter */
383  can_ip->FMR |= (uint32_t)CAN_FMR_FINIT;
384 
385  /* Select the start slave bank */
386  can_ip->FMR &= ~((uint32_t)CAN_FMR_CAN2SB);
387  can_ip->FMR |= (uint32_t)(sFilterConfig->BankNumber << 8);
388 
389  /* Filter Deactivation */
390  can_ip->FA1R &= ~(uint32_t)filternbrbitpos;
391 
392  /* Filter Scale */
393  if (sFilterConfig->FilterScale == CAN_FILTERSCALE_16BIT)
394  {
395  /* 16-bit scale for the filter */
396  can_ip->FS1R &= ~(uint32_t)filternbrbitpos;
397 
398  /* First 16-bit identifier and First 16-bit mask */
399  /* Or First 16-bit identifier and Second 16-bit identifier */
400  can_ip->sFilterRegister[sFilterConfig->FilterNumber].FR1 =
401  ((0x0000FFFF & (uint32_t)sFilterConfig->FilterMaskIdLow) << 16) |
402  (0x0000FFFF & (uint32_t)sFilterConfig->FilterIdLow);
403 
404  /* Second 16-bit identifier and Second 16-bit mask */
405  /* Or Third 16-bit identifier and Fourth 16-bit identifier */
406  can_ip->sFilterRegister[sFilterConfig->FilterNumber].FR2 =
407  ((0x0000FFFF & (uint32_t)sFilterConfig->FilterMaskIdHigh) << 16) |
408  (0x0000FFFF & (uint32_t)sFilterConfig->FilterIdHigh);
409  }
410 
411  if (sFilterConfig->FilterScale == CAN_FILTERSCALE_32BIT)
412  {
413  /* 32-bit scale for the filter */
414  can_ip->FS1R |= filternbrbitpos;
415 
416  /* 32-bit identifier or First 32-bit identifier */
417  can_ip->sFilterRegister[sFilterConfig->FilterNumber].FR1 =
418  ((0x0000FFFF & (uint32_t)sFilterConfig->FilterIdHigh) << 16) |
419  (0x0000FFFF & (uint32_t)sFilterConfig->FilterIdLow);
420 
421  /* 32-bit mask or Second 32-bit identifier */
422  can_ip->sFilterRegister[sFilterConfig->FilterNumber].FR2 =
423  ((0x0000FFFF & (uint32_t)sFilterConfig->FilterMaskIdHigh) << 16) |
424  (0x0000FFFF & (uint32_t)sFilterConfig->FilterMaskIdLow);
425  }
426 
427  /* Filter Mode */
428  if (sFilterConfig->FilterMode == CAN_FILTERMODE_IDMASK)
429  {
430  /*Id/Mask mode for the filter*/
431  can_ip->FM1R &= ~(uint32_t)filternbrbitpos;
432  }
433  else /* CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdList */
434  {
435  /*Identifier list mode for the filter*/
436  can_ip->FM1R |= (uint32_t)filternbrbitpos;
437  }
438 
439  /* Filter FIFO assignment */
440  if (sFilterConfig->FilterFIFOAssignment == CAN_FILTER_FIFO0)
441  {
442  /* FIFO 0 assignation for the filter */
443  can_ip->FFA1R &= ~(uint32_t)filternbrbitpos;
444  }
445 
446  if (sFilterConfig->FilterFIFOAssignment == CAN_FILTER_FIFO1)
447  {
448  /* FIFO 1 assignation for the filter */
449  can_ip->FFA1R |= (uint32_t)filternbrbitpos;
450  }
451 
452  /* Filter activation */
453  if (sFilterConfig->FilterActivation == ENABLE)
454  {
455  can_ip->FA1R |= filternbrbitpos;
456  }
457 
458  /* Leave the initialisation mode for the filter */
459  can_ip->FMR &= ~((uint32_t)CAN_FMR_FINIT);
460 
461  /* Return function status */
462  return HAL_OK;
463 }
464 
472 {
473  /* Check CAN handle */
474  if(hcan == NULL)
475  {
476  return HAL_ERROR;
477  }
478 
479  /* Check the parameters */
481 
482  /* Change CAN state */
483  hcan->State = HAL_CAN_STATE_BUSY;
484 
485  /* DeInit the low level hardware */
486  HAL_CAN_MspDeInit(hcan);
487 
488  /* Change CAN state */
489  hcan->State = HAL_CAN_STATE_RESET;
490 
491  /* Release Lock */
492  __HAL_UNLOCK(hcan);
493 
494  /* Return function status */
495  return HAL_OK;
496 }
497 
504 __weak void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
505 {
506  /* Prevent unused argument(s) compilation warning */
507  UNUSED(hcan);
508  /* NOTE : This function Should not be modified, when the callback is needed,
509  the HAL_CAN_MspInit could be implemented in the user file
510  */
511 }
512 
519 __weak void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan)
520 {
521  /* Prevent unused argument(s) compilation warning */
522  UNUSED(hcan);
523  /* NOTE : This function Should not be modified, when the callback is needed,
524  the HAL_CAN_MspDeInit could be implemented in the user file
525  */
526 }
527 
557 {
558  uint32_t transmitmailbox = CAN_TXSTATUS_NOMAILBOX;
559  uint32_t tickstart = 0;
560 
561  /* Check the parameters */
565 
566  if(((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) || \
567  ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) || \
568  ((hcan->Instance->TSR&CAN_TSR_TME2) == CAN_TSR_TME2))
569  {
570  /* Process locked */
571  __HAL_LOCK(hcan);
572 
573  if(hcan->State == HAL_CAN_STATE_BUSY_RX)
574  {
575  /* Change CAN state */
577  }
578  else
579  {
580  /* Change CAN state */
582  }
583 
584  /* Select one empty transmit mailbox */
585  if ((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0)
586  {
587  transmitmailbox = CAN_TXMAILBOX_0;
588  }
589  else if ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1)
590  {
591  transmitmailbox = CAN_TXMAILBOX_1;
592  }
593  else
594  {
595  transmitmailbox = CAN_TXMAILBOX_2;
596  }
597 
598  /* Set up the Id */
599  hcan->Instance->sTxMailBox[transmitmailbox].TIR &= CAN_TI0R_TXRQ;
600  if (hcan->pTxMsg->IDE == CAN_ID_STD)
601  {
603  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->StdId << 21) | \
604  hcan->pTxMsg->RTR);
605  }
606  else
607  {
609  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->ExtId << 3) | \
610  hcan->pTxMsg->IDE | \
611  hcan->pTxMsg->RTR);
612  }
613 
614  /* Set up the DLC */
615  hcan->pTxMsg->DLC &= (uint8_t)0x0000000FU;
616  hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= (uint32_t)0xFFFFFFF0U;
617  hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC;
618 
619  /* Set up the data field */
620  hcan->Instance->sTxMailBox[transmitmailbox].TDLR = (((uint32_t)hcan->pTxMsg->Data[3] << 24) |
621  ((uint32_t)hcan->pTxMsg->Data[2] << 16) |
622  ((uint32_t)hcan->pTxMsg->Data[1] << 8) |
623  ((uint32_t)hcan->pTxMsg->Data[0]));
624  hcan->Instance->sTxMailBox[transmitmailbox].TDHR = (((uint32_t)hcan->pTxMsg->Data[7] << 24) |
625  ((uint32_t)hcan->pTxMsg->Data[6] << 16) |
626  ((uint32_t)hcan->pTxMsg->Data[5] << 8) |
627  ((uint32_t)hcan->pTxMsg->Data[4]));
628  /* Request transmission */
629  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= CAN_TI0R_TXRQ;
630 
631  /* Get tick */
632  tickstart = HAL_GetTick();
633 
634  /* Check End of transmission flag */
635  while(!(__HAL_CAN_TRANSMIT_STATUS(hcan, transmitmailbox)))
636  {
637  /* Check for the Timeout */
638  if(Timeout != HAL_MAX_DELAY)
639  {
640  if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
641  {
643  /* Process unlocked */
644  __HAL_UNLOCK(hcan);
645  return HAL_TIMEOUT;
646  }
647  }
648  }
649  if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX)
650  {
651  /* Change CAN state */
653  }
654  else
655  {
656  /* Change CAN state */
657  hcan->State = HAL_CAN_STATE_READY;
658  }
659 
660  /* Process unlocked */
661  __HAL_UNLOCK(hcan);
662 
663  /* Return function status */
664  return HAL_OK;
665  }
666  else
667  {
668  /* Change CAN state */
669  hcan->State = HAL_CAN_STATE_ERROR;
670 
671  /* Return function status */
672  return HAL_ERROR;
673  }
674 }
675 
683 {
684  uint32_t transmitmailbox = CAN_TXSTATUS_NOMAILBOX;
685 
686  /* Check the parameters */
690 
691  if(((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) || \
692  ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) || \
693  ((hcan->Instance->TSR&CAN_TSR_TME2) == CAN_TSR_TME2))
694  {
695  /* Process Locked */
696  __HAL_LOCK(hcan);
697 
698  /* Select one empty transmit mailbox */
699  if((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0)
700  {
701  transmitmailbox = CAN_TXMAILBOX_0;
702  }
703  else if((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1)
704  {
705  transmitmailbox = CAN_TXMAILBOX_1;
706  }
707  else
708  {
709  transmitmailbox = CAN_TXMAILBOX_2;
710  }
711 
712  /* Set up the Id */
713  hcan->Instance->sTxMailBox[transmitmailbox].TIR &= CAN_TI0R_TXRQ;
714  if(hcan->pTxMsg->IDE == CAN_ID_STD)
715  {
717  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->StdId << 21) | \
718  hcan->pTxMsg->RTR);
719  }
720  else
721  {
723  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->ExtId << 3) | \
724  hcan->pTxMsg->IDE | \
725  hcan->pTxMsg->RTR);
726  }
727 
728  /* Set up the DLC */
729  hcan->pTxMsg->DLC &= (uint8_t)0x0000000FU;
730  hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= (uint32_t)0xFFFFFFF0U;
731  hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC;
732 
733  /* Set up the data field */
734  hcan->Instance->sTxMailBox[transmitmailbox].TDLR = (((uint32_t)hcan->pTxMsg->Data[3] << 24) |
735  ((uint32_t)hcan->pTxMsg->Data[2] << 16) |
736  ((uint32_t)hcan->pTxMsg->Data[1] << 8) |
737  ((uint32_t)hcan->pTxMsg->Data[0]));
738  hcan->Instance->sTxMailBox[transmitmailbox].TDHR = (((uint32_t)hcan->pTxMsg->Data[7] << 24) |
739  ((uint32_t)hcan->pTxMsg->Data[6] << 16) |
740  ((uint32_t)hcan->pTxMsg->Data[5] << 8) |
741  ((uint32_t)hcan->pTxMsg->Data[4]));
742 
743  if(hcan->State == HAL_CAN_STATE_BUSY_RX)
744  {
745  /* Change CAN state */
747  }
748  else
749  {
750  /* Change CAN state */
752  }
753 
754  /* Set CAN error code to none */
756 
757  /* Process Unlocked */
758  __HAL_UNLOCK(hcan);
759 
760  /* Enable Error warning, Error passive, Bus-off,
761  Last error and Error Interrupts */
763  CAN_IT_EPV |
764  CAN_IT_BOF |
765  CAN_IT_LEC |
766  CAN_IT_ERR |
767  CAN_IT_TME);
768 
769  /* Request transmission */
770  hcan->Instance->sTxMailBox[transmitmailbox].TIR |= CAN_TI0R_TXRQ;
771  }
772  else
773  {
774  /* Change CAN state */
775  hcan->State = HAL_CAN_STATE_ERROR;
776 
777  /* Return function status */
778  return HAL_ERROR;
779  }
780 
781  return HAL_OK;
782 }
783 
792 HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef* hcan, uint8_t FIFONumber, uint32_t Timeout)
793 {
794  uint32_t tickstart = 0;
795 
796  /* Check the parameters */
797  assert_param(IS_CAN_FIFO(FIFONumber));
798 
799  /* Process locked */
800  __HAL_LOCK(hcan);
801 
802  if(hcan->State == HAL_CAN_STATE_BUSY_TX)
803  {
804  /* Change CAN state */
806  }
807  else
808  {
809  /* Change CAN state */
811  }
812 
813  /* Get tick */
814  tickstart = HAL_GetTick();
815 
816  /* Check pending message */
817  while(__HAL_CAN_MSG_PENDING(hcan, FIFONumber) == 0)
818  {
819  /* Check for the Timeout */
820  if(Timeout != HAL_MAX_DELAY)
821  {
822  if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
823  {
825  /* Process unlocked */
826  __HAL_UNLOCK(hcan);
827  return HAL_TIMEOUT;
828  }
829  }
830  }
831 
832  /* Get the Id */
833  hcan->pRxMsg->IDE = (uint8_t)0x04 & hcan->Instance->sFIFOMailBox[FIFONumber].RIR;
834  if (hcan->pRxMsg->IDE == CAN_ID_STD)
835  {
836  hcan->pRxMsg->StdId = (uint32_t)0x000007FF & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 21);
837  }
838  else
839  {
840  hcan->pRxMsg->ExtId = (uint32_t)0x1FFFFFFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 3);
841  }
842 
843  hcan->pRxMsg->RTR = (uint8_t)0x02 & hcan->Instance->sFIFOMailBox[FIFONumber].RIR;
844  /* Get the DLC */
845  hcan->pRxMsg->DLC = (uint8_t)0x0F & hcan->Instance->sFIFOMailBox[FIFONumber].RDTR;
846  /* Get the FMI */
847  hcan->pRxMsg->FMI = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8);
848  /* Get the data field */
849  hcan->pRxMsg->Data[0] = (uint8_t)0xFF & hcan->Instance->sFIFOMailBox[FIFONumber].RDLR;
850  hcan->pRxMsg->Data[1] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 8);
851  hcan->pRxMsg->Data[2] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 16);
852  hcan->pRxMsg->Data[3] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 24);
853  hcan->pRxMsg->Data[4] = (uint8_t)0xFF & hcan->Instance->sFIFOMailBox[FIFONumber].RDHR;
854  hcan->pRxMsg->Data[5] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 8);
855  hcan->pRxMsg->Data[6] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 16);
856  hcan->pRxMsg->Data[7] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 24);
857 
858  /* Release the FIFO */
859  if(FIFONumber == CAN_FIFO0)
860  {
861  /* Release FIFO0 */
863  }
864  else /* FIFONumber == CAN_FIFO1 */
865  {
866  /* Release FIFO1 */
868  }
869 
870  if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX)
871  {
872  /* Change CAN state */
874  }
875  else
876  {
877  /* Change CAN state */
878  hcan->State = HAL_CAN_STATE_READY;
879  }
880 
881  /* Process unlocked */
882  __HAL_UNLOCK(hcan);
883 
884  /* Return function status */
885  return HAL_OK;
886 }
887 
895 HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber)
896 {
897  uint32_t tmp = 0;
898 
899  /* Check the parameters */
900  assert_param(IS_CAN_FIFO(FIFONumber));
901 
902  tmp = hcan->State;
903  if((tmp == HAL_CAN_STATE_READY) || (tmp == HAL_CAN_STATE_BUSY_TX))
904  {
905  /* Process locked */
906  __HAL_LOCK(hcan);
907 
908  if(hcan->State == HAL_CAN_STATE_BUSY_TX)
909  {
910  /* Change CAN state */
912  }
913  else
914  {
915  /* Change CAN state */
917  }
918 
919  /* Set CAN error code to none */
921 
922  /* Enable Error warning, Error passive, Bus-off,
923  Last error and Error Interrupts */
925  CAN_IT_EPV |
926  CAN_IT_BOF |
927  CAN_IT_LEC |
928  CAN_IT_ERR);
929 
930  /* Process unlocked */
931  __HAL_UNLOCK(hcan);
932 
933  if(FIFONumber == CAN_FIFO0)
934  {
935  /* Enable FIFO 0 message pending Interrupt */
937  }
938  else
939  {
940  /* Enable FIFO 1 message pending Interrupt */
942  }
943 
944  }
945  else
946  {
947  return HAL_BUSY;
948  }
949 
950  /* Return function status */
951  return HAL_OK;
952 }
953 
961 {
962  uint32_t tickstart = 0;
963 
964  /* Process locked */
965  __HAL_LOCK(hcan);
966 
967  /* Change CAN state */
968  hcan->State = HAL_CAN_STATE_BUSY;
969 
970  /* Request Sleep mode */
971  hcan->Instance->MCR = (((hcan->Instance->MCR) & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP);
972 
973  /* Sleep mode status */
974  if ((hcan->Instance->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) != CAN_MSR_SLAK)
975  {
976  /* Process unlocked */
977  __HAL_UNLOCK(hcan);
978 
979  /* Return function status */
980  return HAL_ERROR;
981  }
982 
983  /* Get tick */
984  tickstart = HAL_GetTick();
985 
986  /* Wait the acknowledge */
987  while((hcan->Instance->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) != CAN_MSR_SLAK)
988  {
989  if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
990  {
992  /* Process unlocked */
993  __HAL_UNLOCK(hcan);
994  return HAL_TIMEOUT;
995  }
996  }
997 
998  /* Change CAN state */
999  hcan->State = HAL_CAN_STATE_READY;
1000 
1001  /* Process unlocked */
1002  __HAL_UNLOCK(hcan);
1003 
1004  /* Return function status */
1005  return HAL_OK;
1006 }
1007 
1016 {
1017  uint32_t tickstart = 0;
1018 
1019  /* Process locked */
1020  __HAL_LOCK(hcan);
1021 
1022  /* Change CAN state */
1023  hcan->State = HAL_CAN_STATE_BUSY;
1024 
1025  /* Wake up request */
1026  hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_SLEEP;
1027 
1028  /* Get tick */
1029  tickstart = HAL_GetTick();
1030 
1031  /* Sleep mode status */
1032  while((hcan->Instance->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK)
1033  {
1034  if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE)
1035  {
1037  /* Process unlocked */
1038  __HAL_UNLOCK(hcan);
1039  return HAL_TIMEOUT;
1040  }
1041  }
1042  if((hcan->Instance->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK)
1043  {
1044  /* Process unlocked */
1045  __HAL_UNLOCK(hcan);
1046 
1047  /* Return function status */
1048  return HAL_ERROR;
1049  }
1050 
1051  /* Change CAN state */
1052  hcan->State = HAL_CAN_STATE_READY;
1053 
1054  /* Process unlocked */
1055  __HAL_UNLOCK(hcan);
1056 
1057  /* Return function status */
1058  return HAL_OK;
1059 }
1060 
1068 {
1069  uint32_t tmp1 = 0, tmp2 = 0, tmp3 = 0;
1070 
1071  /* Check End of transmission flag */
1073  {
1077  if(tmp1 || tmp2 || tmp3)
1078  {
1079  /* Call transmit function */
1080  CAN_Transmit_IT(hcan);
1081  }
1082  }
1083 
1084  tmp1 = __HAL_CAN_MSG_PENDING(hcan, CAN_FIFO0);
1085  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_FMP0);
1086  /* Check End of reception flag for FIFO0 */
1087  if((tmp1 != 0) && tmp2)
1088  {
1089  /* Call receive function */
1090  CAN_Receive_IT(hcan, CAN_FIFO0);
1091  }
1092 
1093  tmp1 = __HAL_CAN_MSG_PENDING(hcan, CAN_FIFO1);
1094  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_FMP1);
1095  /* Check End of reception flag for FIFO1 */
1096  if((tmp1 != 0) && tmp2)
1097  {
1098  /* Call receive function */
1099  CAN_Receive_IT(hcan, CAN_FIFO1);
1100  }
1101 
1102  tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_EWG);
1103  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_EWG);
1104  tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR);
1105  /* Check Error Warning Flag */
1106  if(tmp1 && tmp2 && tmp3)
1107  {
1108  /* Set CAN error code to EWG error */
1109  hcan->ErrorCode |= HAL_CAN_ERROR_EWG;
1110  }
1111 
1112  tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_EPV);
1113  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_EPV);
1114  tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR);
1115  /* Check Error Passive Flag */
1116  if(tmp1 && tmp2 && tmp3)
1117  {
1118  /* Set CAN error code to EPV error */
1119  hcan->ErrorCode |= HAL_CAN_ERROR_EPV;
1120  }
1121 
1122  tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_BOF);
1123  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_BOF);
1124  tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR);
1125  /* Check Bus-Off Flag */
1126  if(tmp1 && tmp2 && tmp3)
1127  {
1128  /* Set CAN error code to BOF error */
1129  hcan->ErrorCode |= HAL_CAN_ERROR_BOF;
1130  }
1131 
1132  tmp1 = HAL_IS_BIT_CLR(hcan->Instance->ESR, CAN_ESR_LEC);
1133  tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_LEC);
1134  tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR);
1135  /* Check Last error code Flag */
1136  if((!tmp1) && tmp2 && tmp3)
1137  {
1138  tmp1 = (hcan->Instance->ESR) & CAN_ESR_LEC;
1139  switch(tmp1)
1140  {
1141  case(CAN_ESR_LEC_0):
1142  /* Set CAN error code to STF error */
1143  hcan->ErrorCode |= HAL_CAN_ERROR_STF;
1144  break;
1145  case(CAN_ESR_LEC_1):
1146  /* Set CAN error code to FOR error */
1147  hcan->ErrorCode |= HAL_CAN_ERROR_FOR;
1148  break;
1149  case(CAN_ESR_LEC_1 | CAN_ESR_LEC_0):
1150  /* Set CAN error code to ACK error */
1151  hcan->ErrorCode |= HAL_CAN_ERROR_ACK;
1152  break;
1153  case(CAN_ESR_LEC_2):
1154  /* Set CAN error code to BR error */
1155  hcan->ErrorCode |= HAL_CAN_ERROR_BR;
1156  break;
1157  case(CAN_ESR_LEC_2 | CAN_ESR_LEC_0):
1158  /* Set CAN error code to BD error */
1159  hcan->ErrorCode |= HAL_CAN_ERROR_BD;
1160  break;
1161  case(CAN_ESR_LEC_2 | CAN_ESR_LEC_1):
1162  /* Set CAN error code to CRC error */
1163  hcan->ErrorCode |= HAL_CAN_ERROR_CRC;
1164  break;
1165  default:
1166  break;
1167  }
1168 
1169  /* Clear Last error code Flag */
1170  hcan->Instance->ESR &= ~(CAN_ESR_LEC);
1171  }
1172 
1173  /* Call the Error call Back in case of Errors */
1174  if(hcan->ErrorCode != HAL_CAN_ERROR_NONE)
1175  {
1176  /* Clear ERRI Flag */
1177  hcan->Instance->MSR = CAN_MSR_ERRI;
1178  /* Set the CAN state ready to be able to start again the process */
1179  hcan->State = HAL_CAN_STATE_READY;
1180  /* Call Error callback function */
1181  HAL_CAN_ErrorCallback(hcan);
1182  }
1183 }
1184 
1191 __weak void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan)
1192 {
1193  /* Prevent unused argument(s) compilation warning */
1194  UNUSED(hcan);
1195  /* NOTE : This function Should not be modified, when the callback is needed,
1196  the HAL_CAN_TxCpltCallback could be implemented in the user file
1197  */
1198 }
1199 
1206 __weak void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan)
1207 {
1208  /* Prevent unused argument(s) compilation warning */
1209  UNUSED(hcan);
1210  /* NOTE : This function Should not be modified, when the callback is needed,
1211  the HAL_CAN_RxCpltCallback could be implemented in the user file
1212  */
1213 }
1214 
1221 __weak void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)
1222 {
1223  /* Prevent unused argument(s) compilation warning */
1224  UNUSED(hcan);
1225  /* NOTE : This function Should not be modified, when the callback is needed,
1226  the HAL_CAN_ErrorCallback could be implemented in the user file
1227  */
1228 }
1229 
1257 {
1258  /* Return CAN state */
1259  return hcan->State;
1260 }
1261 
1268 uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan)
1269 {
1270  return hcan->ErrorCode;
1271 }
1272 
1282 static HAL_StatusTypeDef CAN_Transmit_IT(CAN_HandleTypeDef* hcan)
1283 {
1284  /* Disable Transmit mailbox empty Interrupt */
1286 
1287  if(hcan->State == HAL_CAN_STATE_BUSY_TX)
1288  {
1289  /* Disable Error warning, Error passive, Bus-off, Last error code
1290  and Error Interrupts */
1292  CAN_IT_EPV |
1293  CAN_IT_BOF |
1294  CAN_IT_LEC |
1295  CAN_IT_ERR );
1296  }
1297 
1298  if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX)
1299  {
1300  /* Change CAN state */
1301  hcan->State = HAL_CAN_STATE_BUSY_RX;
1302  }
1303  else
1304  {
1305  /* Change CAN state */
1306  hcan->State = HAL_CAN_STATE_READY;
1307  }
1308 
1309  /* Transmission complete callback */
1310  HAL_CAN_TxCpltCallback(hcan);
1311 
1312  return HAL_OK;
1313 }
1314 
1323 static HAL_StatusTypeDef CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber)
1324 {
1325  /* Get the Id */
1326  hcan->pRxMsg->IDE = (uint8_t)0x04 & hcan->Instance->sFIFOMailBox[FIFONumber].RIR;
1327  if (hcan->pRxMsg->IDE == CAN_ID_STD)
1328  {
1329  hcan->pRxMsg->StdId = (uint32_t)0x000007FF & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 21);
1330  }
1331  else
1332  {
1333  hcan->pRxMsg->ExtId = (uint32_t)0x1FFFFFFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 3);
1334  }
1335 
1336  hcan->pRxMsg->RTR = (uint8_t)0x02 & hcan->Instance->sFIFOMailBox[FIFONumber].RIR;
1337  /* Get the DLC */
1338  hcan->pRxMsg->DLC = (uint8_t)0x0F & hcan->Instance->sFIFOMailBox[FIFONumber].RDTR;
1339  /* Get the FMI */
1340  hcan->pRxMsg->FMI = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8);
1341  /* Get the data field */
1342  hcan->pRxMsg->Data[0] = (uint8_t)0xFF & hcan->Instance->sFIFOMailBox[FIFONumber].RDLR;
1343  hcan->pRxMsg->Data[1] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 8);
1344  hcan->pRxMsg->Data[2] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 16);
1345  hcan->pRxMsg->Data[3] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 24);
1346  hcan->pRxMsg->Data[4] = (uint8_t)0xFF & hcan->Instance->sFIFOMailBox[FIFONumber].RDHR;
1347  hcan->pRxMsg->Data[5] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 8);
1348  hcan->pRxMsg->Data[6] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 16);
1349  hcan->pRxMsg->Data[7] = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 24);
1350  /* Release the FIFO */
1351  /* Release FIFO0 */
1352  if (FIFONumber == CAN_FIFO0)
1353  {
1355 
1356  /* Disable FIFO 0 message pending Interrupt */
1358  }
1359  /* Release FIFO1 */
1360  else /* FIFONumber == CAN_FIFO1 */
1361  {
1363 
1364  /* Disable FIFO 1 message pending Interrupt */
1366  }
1367 
1368  if(hcan->State == HAL_CAN_STATE_BUSY_RX)
1369  {
1370  /* Disable Error warning, Error passive, Bus-off, Last error code
1371  and Error Interrupts */
1373  CAN_IT_EPV |
1374  CAN_IT_BOF |
1375  CAN_IT_LEC |
1376  CAN_IT_ERR);
1377  }
1378 
1379  if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX)
1380  {
1381  /* Disable CAN state */
1382  hcan->State = HAL_CAN_STATE_BUSY_TX;
1383  }
1384  else
1385  {
1386  /* Change CAN state */
1387  hcan->State = HAL_CAN_STATE_READY;
1388  }
1389 
1390  /* Receive complete callback */
1391  HAL_CAN_RxCpltCallback(hcan);
1392 
1393  /* Return function status */
1394  return HAL_OK;
1395 }
1396 
1401 #endif /* HAL_CAN_MODULE_ENABLED */
1402 
1410 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define IS_CAN_FILTER_FIFO(FIFO)
#define CAN_FILTERSCALE_32BIT
#define IS_CAN_ALL_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8787
CAN_FIFOMailBox_TypeDef sFIFOMailBox[2]
Definition: stm32f745xx.h:287
#define __HAL_CAN_FIFO_RELEASE(__HANDLE__, __FIFONUMBER__)
Release the specified receive FIFO.
#define CAN_FIFO0
#define CAN_MSR_SLAK
Definition: stm32f745xx.h:1760
#define IS_CAN_FILTER_NUMBER(NUMBER)
uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan)
#define IS_CAN_FILTER_MODE(MODE)
#define CAN_FILTERMODE_IDMASK
#define assert_param(expr)
Include module&#39;s header file.
#define CAN_ESR_LEC
Definition: stm32f745xx.h:1830
#define HAL_CAN_ERROR_BD
#define CAN3
Definition: stm32f765xx.h:1499
#define CAN_MSR_INAK
Definition: stm32f745xx.h:1759
#define CAN_MCR_ABOM
Definition: stm32f745xx.h:1754
CAN handle Structure definition.
#define CAN1
Definition: stm32f745xx.h:1282
__IO uint32_t FFA1R
Definition: stm32f745xx.h:294
#define CAN_FILTERSCALE_16BIT
#define CAN_IT_ERR
#define CAN_TSR_TME0
Definition: stm32f745xx.h:1788
__IO uint32_t ErrorCode
#define CAN_FLAG_EWG
#define __HAL_UNLOCK(__HANDLE__)
#define HAL_CAN_ERROR_EPV
#define __HAL_CAN_DISABLE_IT(__HANDLE__, __INTERRUPT__)
Disable the specified CAN interrupts.
__IO uint32_t MSR
Definition: stm32f745xx.h:278
#define CAN_FLAG_EPV
__IO uint32_t ESR
Definition: stm32f745xx.h:283
HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef *hcan)
#define IS_CAN_FIFO(FIFO)
if(LCD_Lock==DISABLE)
Definition: lcd_log.c:249
#define CAN_FMR_CAN2SB
Definition: stm32f745xx.h:1977
__IO uint32_t MCR
Definition: stm32f745xx.h:277
HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef *hcan)
#define CAN_FILTER_FIFO1
HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef *hcan)
#define CAN_MSR_ERRI
Definition: stm32f745xx.h:1761
HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef *hcan, CAN_FilterConfTypeDef *sFilterConfig)
#define CAN_IT_EWG
#define CAN_IT_FMP1
void HAL_CAN_MspInit(CAN_HandleTypeDef *hcan)
#define HAL_CAN_ERROR_EWG
#define IS_CAN_SJW(SJW)
__IO uint32_t TDHR
Definition: stm32f745xx.h:246
__IO uint32_t FS1R
Definition: stm32f745xx.h:292
#define __HAL_LOCK(__HANDLE__)
void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *hcan)
#define IS_CAN_BS1(BS1)
void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef *hcan)
#define CAN_FLAG_BOF
#define CAN_INITSTATUS_SUCCESS
#define CAN_IT_TME
CAN_TypeDef * Instance
#define NULL
Definition: usbd_def.h:53
#define IS_CAN_MODE(MODE)
Controller Area Network.
Definition: stm32f745xx.h:275
#define HAL_MAX_DELAY
HAL_CAN_StateTypeDef
HAL State structures definition.
#define CAN_TSR_TME1
Definition: stm32f745xx.h:1789
#define CAN_ESR_LEC_2
Definition: stm32f745xx.h:1833
#define CAN_ESR_LEC_0
Definition: stm32f745xx.h:1831
CAN filter configuration structure definition.
#define CAN_TXSTATUS_NOMAILBOX
#define CAN_ESR_LEC_1
Definition: stm32f745xx.h:1832
#define IS_CAN_FILTER_SCALE(SCALE)
This file contains all the functions prototypes for the HAL module driver.
#define HAL_IS_BIT_CLR(REG, BIT)
#define CAN_MCR_INRQ
Definition: stm32f745xx.h:1748
#define IS_CAN_BANKNUMBER(BANKNUMBER)
#define HAL_CAN_ERROR_CRC
#define CAN_IT_BOF
#define CAN_TXMAILBOX_2
#define CAN_IT_FMP0
#define CAN_MCR_SLEEP
Definition: stm32f745xx.h:1749
#define CAN_MCR_NART
Definition: stm32f745xx.h:1752
CAN_InitTypeDef Init
__IO uint32_t TDTR
Definition: stm32f745xx.h:244
#define CAN_FMR_FINIT
Definition: stm32f745xx.h:1976
#define CAN_MCR_TXFP
Definition: stm32f745xx.h:1750
#define CAN_ID_STD
#define CAN_TXMAILBOX_0
#define CAN_INITSTATUS_FAILED
__IO uint32_t FM1R
Definition: stm32f745xx.h:290
#define CAN_IT_LEC
#define UNUSED(x)
CAN_TxMailBox_TypeDef sTxMailBox[3]
Definition: stm32f745xx.h:286
#define CAN_TXMAILBOX_1
__IO uint32_t BTR
Definition: stm32f745xx.h:284
#define CAN_MCR_RFLM
Definition: stm32f745xx.h:1751
__IO uint32_t TDLR
Definition: stm32f745xx.h:245
#define __HAL_CAN_ENABLE_IT(__HANDLE__, __INTERRUPT__)
Enable the specified CAN interrupts.
HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef *hcan)
void HAL_CAN_MspDeInit(CAN_HandleTypeDef *hcan)
HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef *hcan)
#define IS_CAN_IDTYPE(IDTYPE)
#define CAN_MCR_TTCM
Definition: stm32f745xx.h:1755
#define HAL_CAN_ERROR_FOR
#define IS_CAN_EXTID(EXTID)
HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef *hcan, uint32_t Timeout)
#define CAN_TI0R_TXRQ
Definition: stm32f745xx.h:1857
__IO uint32_t TIR
Definition: stm32f745xx.h:243
#define __HAL_CAN_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
Check if the specified CAN interrupt source is enabled or disabled.
__IO uint32_t FA1R
Definition: stm32f745xx.h:296
#define IS_FUNCTIONAL_STATE(STATE)
Definition: stm32f7xx.h:163
#define HAL_CAN_ERROR_BOF
HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef *hcan)
#define IS_CAN_PRESCALER(PRESCALER)
HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef *hcan, uint8_t FIFONumber)
#define HAL_CAN_ERROR_STF
#define IS_CAN_DLC(DLC)
#define __HAL_CAN_MSG_PENDING(__HANDLE__, __FIFONUMBER__)
Return the number of pending received messages.
#define HAL_CAN_ERROR_NONE
#define CAN_FIFO1
#define HAL_CAN_ERROR_ACK
#define __HAL_CAN_TRANSMIT_STATUS(__HANDLE__, __TRANSMITMAILBOX__)
Check the transmission status of a CAN Frame.
#define CAN_TSR_TME2
Definition: stm32f745xx.h:1790
void HAL_CAN_IRQHandler(CAN_HandleTypeDef *hcan)
#define IS_CAN_RTR(RTR)
__IO HAL_CAN_StateTypeDef State
#define CAN_IT_EPV
HAL_StatusTypeDef
HAL Status structures definition.
__IO uint32_t TSR
Definition: stm32f745xx.h:279
#define CAN_MCR_AWUM
Definition: stm32f745xx.h:1753
uint32_t HAL_GetTick(void)
Provides a tick value in millisecond.
__IO uint32_t FMR
Definition: stm32f745xx.h:289
#define __HAL_CAN_GET_FLAG(__HANDLE__, __FLAG__)
Check whether the specified CAN flag is set or not.
void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan)
HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef *hcan, uint8_t FIFONumber, uint32_t Timeout)
#define CAN_FILTER_FIFO0
#define HAL_CAN_ERROR_BR
#define IS_CAN_STDID(STDID)
CanTxMsgTypeDef * pTxMsg
#define IS_CAN_BS2(BS2)
CanRxMsgTypeDef * pRxMsg
HAL_LockTypeDef Lock
CAN_FilterRegister_TypeDef sFilterRegister[28]
Definition: stm32f745xx.h:298