TUKS MCU Introductory course / TUKS-COURSE-2-LED
Embed: (wiki syntax)

« Back to documentation index

stm32l4xx_hal_can.c File Reference

stm32l4xx_hal_can.c File Reference

CAN HAL module driver. This file provides firmware functions to manage the following functionalities of the Controller Area Network (CAN) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State and Error functions. More...

Go to the source code of this file.

Functions

static HAL_StatusTypeDef CAN_Receive_IT (CAN_HandleTypeDef *hcan, uint8_t FIFONumber)
 Receive a correct CAN frame.
static HAL_StatusTypeDef CAN_Transmit_IT (CAN_HandleTypeDef *hcan)
 Initiate and transmit a CAN frame message.
HAL_StatusTypeDef HAL_CAN_Init (CAN_HandleTypeDef *hcan)
 Initialize the CAN peripheral according to the specified parameters in the CAN_InitStruct structure and initialize the associated handle.
HAL_StatusTypeDef HAL_CAN_ConfigFilter (CAN_HandleTypeDef *hcan, CAN_FilterConfTypeDef *sFilterConfig)
 Configure the CAN reception filter according to the specified parameters in the CAN_FilterInitStruct.
HAL_StatusTypeDef HAL_CAN_DeInit (CAN_HandleTypeDef *hcan)
 DeInitialize the CAN peripheral registers to their default reset values.
__weak void HAL_CAN_MspInit (CAN_HandleTypeDef *hcan)
 Initialize the CAN MSP.
__weak void HAL_CAN_MspDeInit (CAN_HandleTypeDef *hcan)
 DeInitialize the CAN MSP.
HAL_StatusTypeDef HAL_CAN_Transmit (CAN_HandleTypeDef *hcan, uint32_t Timeout)
 Initiate and transmit a CAN frame message.
HAL_StatusTypeDef HAL_CAN_Transmit_IT (CAN_HandleTypeDef *hcan)
 Initiate and transmit a CAN frame message in Interrupt mode.
HAL_StatusTypeDef HAL_CAN_Receive (CAN_HandleTypeDef *hcan, uint8_t FIFONumber, uint32_t Timeout)
 Receive a correct CAN frame.
HAL_StatusTypeDef HAL_CAN_Receive_IT (CAN_HandleTypeDef *hcan, uint8_t FIFONumber)
 Receive a correct CAN frame in Interrupt mode.
HAL_StatusTypeDef HAL_CAN_Sleep (CAN_HandleTypeDef *hcan)
 Enter the Sleep (low power) mode.
HAL_StatusTypeDef HAL_CAN_WakeUp (CAN_HandleTypeDef *hcan)
 Wake up the CAN peripheral from sleep mode (after that the CAN peripheral is in the normal mode).
void HAL_CAN_IRQHandler (CAN_HandleTypeDef *hcan)
 Handle CAN interrupt request.
__weak void HAL_CAN_TxCpltCallback (CAN_HandleTypeDef *hcan)
 Transmission complete callback in non-blocking mode.
__weak void HAL_CAN_RxCpltCallback (CAN_HandleTypeDef *hcan)
 Reception complete callback in non-blocking mode.
__weak void HAL_CAN_ErrorCallback (CAN_HandleTypeDef *hcan)
 Error CAN callback.
HAL_CAN_StateTypeDef HAL_CAN_GetState (CAN_HandleTypeDef *hcan)
 Return the CAN handle state.
uint32_t HAL_CAN_GetError (CAN_HandleTypeDef *hcan)
 Return the CAN error code.

Detailed Description

CAN HAL module driver. This file provides firmware functions to manage the following functionalities of the Controller Area Network (CAN) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral Control functions + Peripheral State and Error functions.

Author:
MCD Application Team
Version:
V1.5.1
Date:
31-May-2016
  ==============================================================================    
                        ##### How to use this driver #####
  ==============================================================================
    [..]            
      (#) Enable the CAN controller interface clock using 
          __HAL_RCC_CAN1_CLK_ENABLE() for CAN1.
       
      (#) CAN pins configuration
        (++) Enable the clock for the CAN GPIOs using the following function:
             __HAL_RCC_GPIOx_CLK_ENABLE();   
        (++) Connect and configure the involved CAN pins using the 
              following function HAL_GPIO_Init(); 
              
      (#) Initialize and configure the CAN using HAL_CAN_Init() function.   
                 
      (#) Transmit the desired CAN frame using HAL_CAN_Transmit() or 
          HAL_CAN_Transmit_IT() function.
           
      (#) Receive a CAN frame using HAL_CAN_Receive() or HAL_CAN_Receive_IT() function.

     *** Polling mode IO operation ***
     =================================
     [..]    
       (+) Start the CAN peripheral transmission and wait the end of this operation 
           using HAL_CAN_Transmit(), at this stage user can specify the value of timeout
           according to his end application
       (+) Start the CAN peripheral reception and wait the end of this operation 
           using HAL_CAN_Receive(), at this stage user can specify the value of timeout
           according to his end application 
       
     *** Interrupt mode IO operation ***    
     ===================================
     [..]    
       (+) Start the CAN peripheral transmission using HAL_CAN_Transmit_IT()
       (+) Start the CAN peripheral reception using HAL_CAN_Receive_IT()         
       (+) Use HAL_CAN_IRQHandler() called under the used CAN Interrupt subroutine
       (+) At CAN end of transmission HAL_CAN_TxCpltCallback() function is executed and user can 
            add his own code by customization of function pointer HAL_CAN_TxCpltCallback 
       (+) In case of CAN Error, HAL_CAN_ErrorCallback() function is executed and user can 
            add his own code by customization of function pointer HAL_CAN_ErrorCallback
 
     *** CAN HAL driver macros list ***
     ============================================= 
     [..]
       Below the list of most used macros in CAN HAL driver.
       
      (+) __HAL_CAN_ENABLE_IT: Enable the specified CAN interrupts
      (+) __HAL_CAN_DISABLE_IT: Disable the specified CAN interrupts
      (+) __HAL_CAN_GET_IT_SOURCE: Check if the specified CAN interrupt source is enabled or disabled
      (+) __HAL_CAN_CLEAR_FLAG: Clear the CAN's pending flags
      (+) __HAL_CAN_GET_FLAG: Get the selected CAN's flag status
      
     [..] 
      (@) You can refer to the CAN HAL driver header file for more useful macros 
                
  
Attention:

© COPYRIGHT(c) 2016 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file stm32l4xx_hal_can.c.