Mouse code for the MacroRat
mbed-dev/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_can.c@46:b156ef445742, 2017-06-03 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sat Jun 03 00:22:44 2017 +0000
- Revision:
- 46:b156ef445742
- Parent:
- 18:6a4db94011d3
Final code for internal battlebot competition.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /** |
sahilmgandhi | 18:6a4db94011d3 | 2 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @file stm32f2xx_hal_can.c |
sahilmgandhi | 18:6a4db94011d3 | 4 | * @author MCD Application Team |
sahilmgandhi | 18:6a4db94011d3 | 5 | * @version V1.1.3 |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @date 29-June-2016 |
sahilmgandhi | 18:6a4db94011d3 | 7 | * @brief This file provides firmware functions to manage the following |
sahilmgandhi | 18:6a4db94011d3 | 8 | * functionalities of the Controller Area Network (CAN) peripheral: |
sahilmgandhi | 18:6a4db94011d3 | 9 | * + Initialization and de-initialization functions |
sahilmgandhi | 18:6a4db94011d3 | 10 | * + IO operation functions |
sahilmgandhi | 18:6a4db94011d3 | 11 | * + Peripheral Control functions |
sahilmgandhi | 18:6a4db94011d3 | 12 | * + Peripheral State and Error functions |
sahilmgandhi | 18:6a4db94011d3 | 13 | * |
sahilmgandhi | 18:6a4db94011d3 | 14 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 15 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 16 | ##### How to use this driver ##### |
sahilmgandhi | 18:6a4db94011d3 | 17 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 18 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 19 | (#) Enable the CAN controller interface clock using |
sahilmgandhi | 18:6a4db94011d3 | 20 | __HAL_RCC_CAN1_CLK_ENABLE() for CAN1 and __HAL_RCC_CAN2_CLK_ENABLE() for CAN2 |
sahilmgandhi | 18:6a4db94011d3 | 21 | -@- In case you are using CAN2 only, you have to enable the CAN1 clock. |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | (#) CAN pins configuration |
sahilmgandhi | 18:6a4db94011d3 | 24 | (++) Enable the clock for the CAN GPIOs using the following function: |
sahilmgandhi | 18:6a4db94011d3 | 25 | __GPIOx_CLK_ENABLE() |
sahilmgandhi | 18:6a4db94011d3 | 26 | (++) Connect and configure the involved CAN pins to AF9 using the |
sahilmgandhi | 18:6a4db94011d3 | 27 | following function HAL_GPIO_Init() |
sahilmgandhi | 18:6a4db94011d3 | 28 | |
sahilmgandhi | 18:6a4db94011d3 | 29 | (#) Initialize and configure the CAN using CAN_Init() function. |
sahilmgandhi | 18:6a4db94011d3 | 30 | |
sahilmgandhi | 18:6a4db94011d3 | 31 | (#) Transmit the desired CAN frame using HAL_CAN_Transmit() function. |
sahilmgandhi | 18:6a4db94011d3 | 32 | |
sahilmgandhi | 18:6a4db94011d3 | 33 | (#) Receive a CAN frame using HAL_CAN_Receive() function. |
sahilmgandhi | 18:6a4db94011d3 | 34 | |
sahilmgandhi | 18:6a4db94011d3 | 35 | *** Polling mode IO operation *** |
sahilmgandhi | 18:6a4db94011d3 | 36 | ================================= |
sahilmgandhi | 18:6a4db94011d3 | 37 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 38 | (+) Start the CAN peripheral transmission and wait the end of this operation |
sahilmgandhi | 18:6a4db94011d3 | 39 | using HAL_CAN_Transmit(), at this stage user can specify the value of timeout |
sahilmgandhi | 18:6a4db94011d3 | 40 | according to his end application |
sahilmgandhi | 18:6a4db94011d3 | 41 | (+) Start the CAN peripheral reception and wait the end of this operation |
sahilmgandhi | 18:6a4db94011d3 | 42 | using HAL_CAN_Receive(), at this stage user can specify the value of timeout |
sahilmgandhi | 18:6a4db94011d3 | 43 | according to his end application |
sahilmgandhi | 18:6a4db94011d3 | 44 | |
sahilmgandhi | 18:6a4db94011d3 | 45 | *** Interrupt mode IO operation *** |
sahilmgandhi | 18:6a4db94011d3 | 46 | =================================== |
sahilmgandhi | 18:6a4db94011d3 | 47 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 48 | (+) Start the CAN peripheral transmission using HAL_CAN_Transmit_IT() |
sahilmgandhi | 18:6a4db94011d3 | 49 | (+) Start the CAN peripheral reception using HAL_CAN_Receive_IT() |
sahilmgandhi | 18:6a4db94011d3 | 50 | (+) Use HAL_CAN_IRQHandler() called under the used CAN Interrupt subroutine |
sahilmgandhi | 18:6a4db94011d3 | 51 | (+) At CAN end of transmission HAL_CAN_TxCpltCallback() function is executed and user can |
sahilmgandhi | 18:6a4db94011d3 | 52 | add his own code by customization of function pointer HAL_CAN_TxCpltCallback |
sahilmgandhi | 18:6a4db94011d3 | 53 | (+) In case of CAN Error, HAL_CAN_ErrorCallback() function is executed and user can |
sahilmgandhi | 18:6a4db94011d3 | 54 | add his own code by customization of function pointer HAL_CAN_ErrorCallback |
sahilmgandhi | 18:6a4db94011d3 | 55 | |
sahilmgandhi | 18:6a4db94011d3 | 56 | *** CAN HAL driver macros list *** |
sahilmgandhi | 18:6a4db94011d3 | 57 | ============================================= |
sahilmgandhi | 18:6a4db94011d3 | 58 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 59 | Below the list of most used macros in CAN HAL driver. |
sahilmgandhi | 18:6a4db94011d3 | 60 | |
sahilmgandhi | 18:6a4db94011d3 | 61 | (+) __HAL_CAN_ENABLE_IT: Enable the specified CAN interrupts |
sahilmgandhi | 18:6a4db94011d3 | 62 | (+) __HAL_CAN_DISABLE_IT: Disable the specified CAN interrupts |
sahilmgandhi | 18:6a4db94011d3 | 63 | (+) __HAL_CAN_GET_IT_SOURCE: Check if the specified CAN interrupt source is enabled or disabled |
sahilmgandhi | 18:6a4db94011d3 | 64 | (+) __HAL_CAN_CLEAR_FLAG: Clear the CAN's pending flags |
sahilmgandhi | 18:6a4db94011d3 | 65 | (+) __HAL_CAN_GET_FLAG: Get the selected CAN's flag status |
sahilmgandhi | 18:6a4db94011d3 | 66 | |
sahilmgandhi | 18:6a4db94011d3 | 67 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 68 | (@) You can refer to the CAN HAL driver header file for more useful macros |
sahilmgandhi | 18:6a4db94011d3 | 69 | |
sahilmgandhi | 18:6a4db94011d3 | 70 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 71 | |
sahilmgandhi | 18:6a4db94011d3 | 72 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 73 | * @attention |
sahilmgandhi | 18:6a4db94011d3 | 74 | * |
sahilmgandhi | 18:6a4db94011d3 | 75 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
sahilmgandhi | 18:6a4db94011d3 | 76 | * |
sahilmgandhi | 18:6a4db94011d3 | 77 | * Redistribution and use in source and binary forms, with or without modification, |
sahilmgandhi | 18:6a4db94011d3 | 78 | * are permitted provided that the following conditions are met: |
sahilmgandhi | 18:6a4db94011d3 | 79 | * 1. Redistributions of source code must retain the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 80 | * this list of conditions and the following disclaimer. |
sahilmgandhi | 18:6a4db94011d3 | 81 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 82 | * this list of conditions and the following disclaimer in the documentation |
sahilmgandhi | 18:6a4db94011d3 | 83 | * and/or other materials provided with the distribution. |
sahilmgandhi | 18:6a4db94011d3 | 84 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
sahilmgandhi | 18:6a4db94011d3 | 85 | * may be used to endorse or promote products derived from this software |
sahilmgandhi | 18:6a4db94011d3 | 86 | * without specific prior written permission. |
sahilmgandhi | 18:6a4db94011d3 | 87 | * |
sahilmgandhi | 18:6a4db94011d3 | 88 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
sahilmgandhi | 18:6a4db94011d3 | 89 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
sahilmgandhi | 18:6a4db94011d3 | 90 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
sahilmgandhi | 18:6a4db94011d3 | 91 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
sahilmgandhi | 18:6a4db94011d3 | 92 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
sahilmgandhi | 18:6a4db94011d3 | 93 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
sahilmgandhi | 18:6a4db94011d3 | 94 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
sahilmgandhi | 18:6a4db94011d3 | 95 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
sahilmgandhi | 18:6a4db94011d3 | 96 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
sahilmgandhi | 18:6a4db94011d3 | 97 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sahilmgandhi | 18:6a4db94011d3 | 98 | * |
sahilmgandhi | 18:6a4db94011d3 | 99 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 100 | */ |
sahilmgandhi | 18:6a4db94011d3 | 101 | |
sahilmgandhi | 18:6a4db94011d3 | 102 | /* Includes ------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 103 | #include "stm32f2xx_hal.h" |
sahilmgandhi | 18:6a4db94011d3 | 104 | |
sahilmgandhi | 18:6a4db94011d3 | 105 | /** @addtogroup STM32F2xx_HAL_Driver |
sahilmgandhi | 18:6a4db94011d3 | 106 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 107 | */ |
sahilmgandhi | 18:6a4db94011d3 | 108 | |
sahilmgandhi | 18:6a4db94011d3 | 109 | /** @defgroup CAN CAN |
sahilmgandhi | 18:6a4db94011d3 | 110 | * @brief CAN driver modules |
sahilmgandhi | 18:6a4db94011d3 | 111 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 112 | */ |
sahilmgandhi | 18:6a4db94011d3 | 113 | |
sahilmgandhi | 18:6a4db94011d3 | 114 | #ifdef HAL_CAN_MODULE_ENABLED |
sahilmgandhi | 18:6a4db94011d3 | 115 | |
sahilmgandhi | 18:6a4db94011d3 | 116 | /* Private typedef -----------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 117 | /* Private define ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 118 | /** @addtogroup CAN_Private_Constants |
sahilmgandhi | 18:6a4db94011d3 | 119 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 120 | */ |
sahilmgandhi | 18:6a4db94011d3 | 121 | #define CAN_TIMEOUT_VALUE 10U |
sahilmgandhi | 18:6a4db94011d3 | 122 | /** |
sahilmgandhi | 18:6a4db94011d3 | 123 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 124 | */ |
sahilmgandhi | 18:6a4db94011d3 | 125 | /* Private macro -------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 126 | /* Private variables ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 127 | /* Private function prototypes -----------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 128 | /** @addtogroup CAN_Private_Functions |
sahilmgandhi | 18:6a4db94011d3 | 129 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 130 | */ |
sahilmgandhi | 18:6a4db94011d3 | 131 | static HAL_StatusTypeDef CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber); |
sahilmgandhi | 18:6a4db94011d3 | 132 | static HAL_StatusTypeDef CAN_Transmit_IT(CAN_HandleTypeDef* hcan); |
sahilmgandhi | 18:6a4db94011d3 | 133 | /** |
sahilmgandhi | 18:6a4db94011d3 | 134 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 135 | */ |
sahilmgandhi | 18:6a4db94011d3 | 136 | |
sahilmgandhi | 18:6a4db94011d3 | 137 | /* Exported functions --------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 138 | /** @defgroup CAN_Exported_Functions CAN Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 139 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 140 | */ |
sahilmgandhi | 18:6a4db94011d3 | 141 | |
sahilmgandhi | 18:6a4db94011d3 | 142 | /** @defgroup CAN_Exported_Functions_Group1 Initialization and de-initialization functions |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @brief Initialization and Configuration functions |
sahilmgandhi | 18:6a4db94011d3 | 144 | * |
sahilmgandhi | 18:6a4db94011d3 | 145 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 146 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 147 | ##### Initialization and de-initialization functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 148 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 149 | [..] This section provides functions allowing to: |
sahilmgandhi | 18:6a4db94011d3 | 150 | (+) Initialize and configure the CAN. |
sahilmgandhi | 18:6a4db94011d3 | 151 | (+) De-initialize the CAN. |
sahilmgandhi | 18:6a4db94011d3 | 152 | |
sahilmgandhi | 18:6a4db94011d3 | 153 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 154 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 155 | */ |
sahilmgandhi | 18:6a4db94011d3 | 156 | |
sahilmgandhi | 18:6a4db94011d3 | 157 | /** |
sahilmgandhi | 18:6a4db94011d3 | 158 | * @brief Initializes the CAN peripheral according to the specified |
sahilmgandhi | 18:6a4db94011d3 | 159 | * parameters in the CAN_InitStruct. |
sahilmgandhi | 18:6a4db94011d3 | 160 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 161 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 162 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 163 | */ |
sahilmgandhi | 18:6a4db94011d3 | 164 | HAL_StatusTypeDef HAL_CAN_Init(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 165 | { |
sahilmgandhi | 18:6a4db94011d3 | 166 | uint32_t InitStatus = 3U; |
sahilmgandhi | 18:6a4db94011d3 | 167 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 168 | |
sahilmgandhi | 18:6a4db94011d3 | 169 | /* Check CAN handle */ |
sahilmgandhi | 18:6a4db94011d3 | 170 | if(hcan == NULL) |
sahilmgandhi | 18:6a4db94011d3 | 171 | { |
sahilmgandhi | 18:6a4db94011d3 | 172 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 173 | } |
sahilmgandhi | 18:6a4db94011d3 | 174 | |
sahilmgandhi | 18:6a4db94011d3 | 175 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 176 | assert_param(IS_CAN_ALL_INSTANCE(hcan->Instance)); |
sahilmgandhi | 18:6a4db94011d3 | 177 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.TTCM)); |
sahilmgandhi | 18:6a4db94011d3 | 178 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.ABOM)); |
sahilmgandhi | 18:6a4db94011d3 | 179 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.AWUM)); |
sahilmgandhi | 18:6a4db94011d3 | 180 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.NART)); |
sahilmgandhi | 18:6a4db94011d3 | 181 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.RFLM)); |
sahilmgandhi | 18:6a4db94011d3 | 182 | assert_param(IS_FUNCTIONAL_STATE(hcan->Init.TXFP)); |
sahilmgandhi | 18:6a4db94011d3 | 183 | assert_param(IS_CAN_MODE(hcan->Init.Mode)); |
sahilmgandhi | 18:6a4db94011d3 | 184 | assert_param(IS_CAN_SJW(hcan->Init.SJW)); |
sahilmgandhi | 18:6a4db94011d3 | 185 | assert_param(IS_CAN_BS1(hcan->Init.BS1)); |
sahilmgandhi | 18:6a4db94011d3 | 186 | assert_param(IS_CAN_BS2(hcan->Init.BS2)); |
sahilmgandhi | 18:6a4db94011d3 | 187 | assert_param(IS_CAN_PRESCALER(hcan->Init.Prescaler)); |
sahilmgandhi | 18:6a4db94011d3 | 188 | |
sahilmgandhi | 18:6a4db94011d3 | 189 | |
sahilmgandhi | 18:6a4db94011d3 | 190 | if(hcan->State == HAL_CAN_STATE_RESET) |
sahilmgandhi | 18:6a4db94011d3 | 191 | { |
sahilmgandhi | 18:6a4db94011d3 | 192 | /* Allocate lock resource and initialize it */ |
sahilmgandhi | 18:6a4db94011d3 | 193 | hcan->Lock = HAL_UNLOCKED; |
sahilmgandhi | 18:6a4db94011d3 | 194 | /* Init the low level hardware */ |
sahilmgandhi | 18:6a4db94011d3 | 195 | HAL_CAN_MspInit(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 196 | } |
sahilmgandhi | 18:6a4db94011d3 | 197 | |
sahilmgandhi | 18:6a4db94011d3 | 198 | /* Initialize the CAN state*/ |
sahilmgandhi | 18:6a4db94011d3 | 199 | hcan->State = HAL_CAN_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 200 | |
sahilmgandhi | 18:6a4db94011d3 | 201 | /* Exit from sleep mode */ |
sahilmgandhi | 18:6a4db94011d3 | 202 | hcan->Instance->MCR &= (~(uint32_t)CAN_MCR_SLEEP); |
sahilmgandhi | 18:6a4db94011d3 | 203 | |
sahilmgandhi | 18:6a4db94011d3 | 204 | /* Request initialisation */ |
sahilmgandhi | 18:6a4db94011d3 | 205 | hcan->Instance->MCR |= CAN_MCR_INRQ ; |
sahilmgandhi | 18:6a4db94011d3 | 206 | |
sahilmgandhi | 18:6a4db94011d3 | 207 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 208 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 209 | |
sahilmgandhi | 18:6a4db94011d3 | 210 | /* Wait the acknowledge */ |
sahilmgandhi | 18:6a4db94011d3 | 211 | while((hcan->Instance->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) |
sahilmgandhi | 18:6a4db94011d3 | 212 | { |
sahilmgandhi | 18:6a4db94011d3 | 213 | if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE) |
sahilmgandhi | 18:6a4db94011d3 | 214 | { |
sahilmgandhi | 18:6a4db94011d3 | 215 | hcan->State= HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 216 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 217 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 218 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 219 | } |
sahilmgandhi | 18:6a4db94011d3 | 220 | } |
sahilmgandhi | 18:6a4db94011d3 | 221 | |
sahilmgandhi | 18:6a4db94011d3 | 222 | /* Check acknowledge */ |
sahilmgandhi | 18:6a4db94011d3 | 223 | if ((hcan->Instance->MSR & CAN_MSR_INAK) != CAN_MSR_INAK) |
sahilmgandhi | 18:6a4db94011d3 | 224 | { |
sahilmgandhi | 18:6a4db94011d3 | 225 | InitStatus = CAN_INITSTATUS_FAILED; |
sahilmgandhi | 18:6a4db94011d3 | 226 | } |
sahilmgandhi | 18:6a4db94011d3 | 227 | else |
sahilmgandhi | 18:6a4db94011d3 | 228 | { |
sahilmgandhi | 18:6a4db94011d3 | 229 | /* Set the time triggered communication mode */ |
sahilmgandhi | 18:6a4db94011d3 | 230 | if (hcan->Init.TTCM == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 231 | { |
sahilmgandhi | 18:6a4db94011d3 | 232 | hcan->Instance->MCR |= CAN_MCR_TTCM; |
sahilmgandhi | 18:6a4db94011d3 | 233 | } |
sahilmgandhi | 18:6a4db94011d3 | 234 | else |
sahilmgandhi | 18:6a4db94011d3 | 235 | { |
sahilmgandhi | 18:6a4db94011d3 | 236 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_TTCM; |
sahilmgandhi | 18:6a4db94011d3 | 237 | } |
sahilmgandhi | 18:6a4db94011d3 | 238 | |
sahilmgandhi | 18:6a4db94011d3 | 239 | /* Set the automatic bus-off management */ |
sahilmgandhi | 18:6a4db94011d3 | 240 | if (hcan->Init.ABOM == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 241 | { |
sahilmgandhi | 18:6a4db94011d3 | 242 | hcan->Instance->MCR |= CAN_MCR_ABOM; |
sahilmgandhi | 18:6a4db94011d3 | 243 | } |
sahilmgandhi | 18:6a4db94011d3 | 244 | else |
sahilmgandhi | 18:6a4db94011d3 | 245 | { |
sahilmgandhi | 18:6a4db94011d3 | 246 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_ABOM; |
sahilmgandhi | 18:6a4db94011d3 | 247 | } |
sahilmgandhi | 18:6a4db94011d3 | 248 | |
sahilmgandhi | 18:6a4db94011d3 | 249 | /* Set the automatic wake-up mode */ |
sahilmgandhi | 18:6a4db94011d3 | 250 | if (hcan->Init.AWUM == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 251 | { |
sahilmgandhi | 18:6a4db94011d3 | 252 | hcan->Instance->MCR |= CAN_MCR_AWUM; |
sahilmgandhi | 18:6a4db94011d3 | 253 | } |
sahilmgandhi | 18:6a4db94011d3 | 254 | else |
sahilmgandhi | 18:6a4db94011d3 | 255 | { |
sahilmgandhi | 18:6a4db94011d3 | 256 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_AWUM; |
sahilmgandhi | 18:6a4db94011d3 | 257 | } |
sahilmgandhi | 18:6a4db94011d3 | 258 | |
sahilmgandhi | 18:6a4db94011d3 | 259 | /* Set the no automatic retransmission */ |
sahilmgandhi | 18:6a4db94011d3 | 260 | if (hcan->Init.NART == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 261 | { |
sahilmgandhi | 18:6a4db94011d3 | 262 | hcan->Instance->MCR |= CAN_MCR_NART; |
sahilmgandhi | 18:6a4db94011d3 | 263 | } |
sahilmgandhi | 18:6a4db94011d3 | 264 | else |
sahilmgandhi | 18:6a4db94011d3 | 265 | { |
sahilmgandhi | 18:6a4db94011d3 | 266 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_NART; |
sahilmgandhi | 18:6a4db94011d3 | 267 | } |
sahilmgandhi | 18:6a4db94011d3 | 268 | |
sahilmgandhi | 18:6a4db94011d3 | 269 | /* Set the receive FIFO locked mode */ |
sahilmgandhi | 18:6a4db94011d3 | 270 | if (hcan->Init.RFLM == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 271 | { |
sahilmgandhi | 18:6a4db94011d3 | 272 | hcan->Instance->MCR |= CAN_MCR_RFLM; |
sahilmgandhi | 18:6a4db94011d3 | 273 | } |
sahilmgandhi | 18:6a4db94011d3 | 274 | else |
sahilmgandhi | 18:6a4db94011d3 | 275 | { |
sahilmgandhi | 18:6a4db94011d3 | 276 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_RFLM; |
sahilmgandhi | 18:6a4db94011d3 | 277 | } |
sahilmgandhi | 18:6a4db94011d3 | 278 | |
sahilmgandhi | 18:6a4db94011d3 | 279 | /* Set the transmit FIFO priority */ |
sahilmgandhi | 18:6a4db94011d3 | 280 | if (hcan->Init.TXFP == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 281 | { |
sahilmgandhi | 18:6a4db94011d3 | 282 | hcan->Instance->MCR |= CAN_MCR_TXFP; |
sahilmgandhi | 18:6a4db94011d3 | 283 | } |
sahilmgandhi | 18:6a4db94011d3 | 284 | else |
sahilmgandhi | 18:6a4db94011d3 | 285 | { |
sahilmgandhi | 18:6a4db94011d3 | 286 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_TXFP; |
sahilmgandhi | 18:6a4db94011d3 | 287 | } |
sahilmgandhi | 18:6a4db94011d3 | 288 | |
sahilmgandhi | 18:6a4db94011d3 | 289 | /* Set the bit timing register */ |
sahilmgandhi | 18:6a4db94011d3 | 290 | hcan->Instance->BTR = (uint32_t)((uint32_t)hcan->Init.Mode) | \ |
sahilmgandhi | 18:6a4db94011d3 | 291 | ((uint32_t)hcan->Init.SJW) | \ |
sahilmgandhi | 18:6a4db94011d3 | 292 | ((uint32_t)hcan->Init.BS1) | \ |
sahilmgandhi | 18:6a4db94011d3 | 293 | ((uint32_t)hcan->Init.BS2) | \ |
sahilmgandhi | 18:6a4db94011d3 | 294 | ((uint32_t)hcan->Init.Prescaler - 1U); |
sahilmgandhi | 18:6a4db94011d3 | 295 | |
sahilmgandhi | 18:6a4db94011d3 | 296 | /* Request leave initialisation */ |
sahilmgandhi | 18:6a4db94011d3 | 297 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_INRQ; |
sahilmgandhi | 18:6a4db94011d3 | 298 | |
sahilmgandhi | 18:6a4db94011d3 | 299 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 300 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 301 | |
sahilmgandhi | 18:6a4db94011d3 | 302 | /* Wait the acknowledge */ |
sahilmgandhi | 18:6a4db94011d3 | 303 | while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) |
sahilmgandhi | 18:6a4db94011d3 | 304 | { |
sahilmgandhi | 18:6a4db94011d3 | 305 | if((HAL_GetTick() - tickstart ) > CAN_TIMEOUT_VALUE) |
sahilmgandhi | 18:6a4db94011d3 | 306 | { |
sahilmgandhi | 18:6a4db94011d3 | 307 | hcan->State= HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 308 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 309 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 310 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 311 | } |
sahilmgandhi | 18:6a4db94011d3 | 312 | } |
sahilmgandhi | 18:6a4db94011d3 | 313 | |
sahilmgandhi | 18:6a4db94011d3 | 314 | /* Check acknowledged */ |
sahilmgandhi | 18:6a4db94011d3 | 315 | if ((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) |
sahilmgandhi | 18:6a4db94011d3 | 316 | { |
sahilmgandhi | 18:6a4db94011d3 | 317 | InitStatus = CAN_INITSTATUS_FAILED; |
sahilmgandhi | 18:6a4db94011d3 | 318 | } |
sahilmgandhi | 18:6a4db94011d3 | 319 | else |
sahilmgandhi | 18:6a4db94011d3 | 320 | { |
sahilmgandhi | 18:6a4db94011d3 | 321 | InitStatus = CAN_INITSTATUS_SUCCESS; |
sahilmgandhi | 18:6a4db94011d3 | 322 | } |
sahilmgandhi | 18:6a4db94011d3 | 323 | } |
sahilmgandhi | 18:6a4db94011d3 | 324 | |
sahilmgandhi | 18:6a4db94011d3 | 325 | if(InitStatus == CAN_INITSTATUS_SUCCESS) |
sahilmgandhi | 18:6a4db94011d3 | 326 | { |
sahilmgandhi | 18:6a4db94011d3 | 327 | /* Set CAN error code to none */ |
sahilmgandhi | 18:6a4db94011d3 | 328 | hcan->ErrorCode = HAL_CAN_ERROR_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 329 | |
sahilmgandhi | 18:6a4db94011d3 | 330 | /* Initialize the CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 331 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 332 | |
sahilmgandhi | 18:6a4db94011d3 | 333 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 334 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 335 | } |
sahilmgandhi | 18:6a4db94011d3 | 336 | else |
sahilmgandhi | 18:6a4db94011d3 | 337 | { |
sahilmgandhi | 18:6a4db94011d3 | 338 | /* Initialize the CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 339 | hcan->State = HAL_CAN_STATE_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 340 | |
sahilmgandhi | 18:6a4db94011d3 | 341 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 342 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 343 | } |
sahilmgandhi | 18:6a4db94011d3 | 344 | } |
sahilmgandhi | 18:6a4db94011d3 | 345 | |
sahilmgandhi | 18:6a4db94011d3 | 346 | /** |
sahilmgandhi | 18:6a4db94011d3 | 347 | * @brief Configures the CAN reception filter according to the specified |
sahilmgandhi | 18:6a4db94011d3 | 348 | * parameters in the CAN_FilterInitStruct. |
sahilmgandhi | 18:6a4db94011d3 | 349 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 350 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 351 | * @param sFilterConfig: pointer to a CAN_FilterConfTypeDef structure that |
sahilmgandhi | 18:6a4db94011d3 | 352 | * contains the filter configuration information. |
sahilmgandhi | 18:6a4db94011d3 | 353 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 354 | */ |
sahilmgandhi | 18:6a4db94011d3 | 355 | HAL_StatusTypeDef HAL_CAN_ConfigFilter(CAN_HandleTypeDef* hcan, CAN_FilterConfTypeDef* sFilterConfig) |
sahilmgandhi | 18:6a4db94011d3 | 356 | { |
sahilmgandhi | 18:6a4db94011d3 | 357 | uint32_t filternbrbitpos = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 358 | |
sahilmgandhi | 18:6a4db94011d3 | 359 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 360 | assert_param(IS_CAN_FILTER_NUMBER(sFilterConfig->FilterNumber)); |
sahilmgandhi | 18:6a4db94011d3 | 361 | assert_param(IS_CAN_FILTER_MODE(sFilterConfig->FilterMode)); |
sahilmgandhi | 18:6a4db94011d3 | 362 | assert_param(IS_CAN_FILTER_SCALE(sFilterConfig->FilterScale)); |
sahilmgandhi | 18:6a4db94011d3 | 363 | assert_param(IS_CAN_FILTER_FIFO(sFilterConfig->FilterFIFOAssignment)); |
sahilmgandhi | 18:6a4db94011d3 | 364 | assert_param(IS_FUNCTIONAL_STATE(sFilterConfig->FilterActivation)); |
sahilmgandhi | 18:6a4db94011d3 | 365 | assert_param(IS_CAN_BANKNUMBER(sFilterConfig->BankNumber)); |
sahilmgandhi | 18:6a4db94011d3 | 366 | |
sahilmgandhi | 18:6a4db94011d3 | 367 | filternbrbitpos = ((uint32_t)1U) << sFilterConfig->FilterNumber; |
sahilmgandhi | 18:6a4db94011d3 | 368 | |
sahilmgandhi | 18:6a4db94011d3 | 369 | /* Initialisation mode for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 370 | CAN1->FMR |= (uint32_t)CAN_FMR_FINIT; |
sahilmgandhi | 18:6a4db94011d3 | 371 | |
sahilmgandhi | 18:6a4db94011d3 | 372 | /* Select the start slave bank */ |
sahilmgandhi | 18:6a4db94011d3 | 373 | CAN1->FMR &= ~((uint32_t)CAN_FMR_CAN2SB); |
sahilmgandhi | 18:6a4db94011d3 | 374 | CAN1->FMR |= (uint32_t)(sFilterConfig->BankNumber << 8U); |
sahilmgandhi | 18:6a4db94011d3 | 375 | |
sahilmgandhi | 18:6a4db94011d3 | 376 | /* Filter Deactivation */ |
sahilmgandhi | 18:6a4db94011d3 | 377 | CAN1->FA1R &= ~(uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 378 | |
sahilmgandhi | 18:6a4db94011d3 | 379 | /* Filter Scale */ |
sahilmgandhi | 18:6a4db94011d3 | 380 | if (sFilterConfig->FilterScale == CAN_FILTERSCALE_16BIT) |
sahilmgandhi | 18:6a4db94011d3 | 381 | { |
sahilmgandhi | 18:6a4db94011d3 | 382 | /* 16-bit scale for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 383 | CAN1->FS1R &= ~(uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 384 | |
sahilmgandhi | 18:6a4db94011d3 | 385 | /* First 16-bit identifier and First 16-bit mask */ |
sahilmgandhi | 18:6a4db94011d3 | 386 | /* Or First 16-bit identifier and Second 16-bit identifier */ |
sahilmgandhi | 18:6a4db94011d3 | 387 | CAN1->sFilterRegister[sFilterConfig->FilterNumber].FR1 = |
sahilmgandhi | 18:6a4db94011d3 | 388 | ((0x0000FFFFU & (uint32_t)sFilterConfig->FilterMaskIdLow) << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 389 | (0x0000FFFFU & (uint32_t)sFilterConfig->FilterIdLow); |
sahilmgandhi | 18:6a4db94011d3 | 390 | |
sahilmgandhi | 18:6a4db94011d3 | 391 | /* Second 16-bit identifier and Second 16-bit mask */ |
sahilmgandhi | 18:6a4db94011d3 | 392 | /* Or Third 16-bit identifier and Fourth 16-bit identifier */ |
sahilmgandhi | 18:6a4db94011d3 | 393 | CAN1->sFilterRegister[sFilterConfig->FilterNumber].FR2 = |
sahilmgandhi | 18:6a4db94011d3 | 394 | ((0x0000FFFFU & (uint32_t)sFilterConfig->FilterMaskIdHigh) << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 395 | (0x0000FFFFU & (uint32_t)sFilterConfig->FilterIdHigh); |
sahilmgandhi | 18:6a4db94011d3 | 396 | } |
sahilmgandhi | 18:6a4db94011d3 | 397 | |
sahilmgandhi | 18:6a4db94011d3 | 398 | if (sFilterConfig->FilterScale == CAN_FILTERSCALE_32BIT) |
sahilmgandhi | 18:6a4db94011d3 | 399 | { |
sahilmgandhi | 18:6a4db94011d3 | 400 | /* 32-bit scale for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 401 | CAN1->FS1R |= filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 402 | /* 32-bit identifier or First 32-bit identifier */ |
sahilmgandhi | 18:6a4db94011d3 | 403 | CAN1->sFilterRegister[sFilterConfig->FilterNumber].FR1 = |
sahilmgandhi | 18:6a4db94011d3 | 404 | ((0x0000FFFFU & (uint32_t)sFilterConfig->FilterIdHigh) << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 405 | (0x0000FFFFU & (uint32_t)sFilterConfig->FilterIdLow); |
sahilmgandhi | 18:6a4db94011d3 | 406 | /* 32-bit mask or Second 32-bit identifier */ |
sahilmgandhi | 18:6a4db94011d3 | 407 | CAN1->sFilterRegister[sFilterConfig->FilterNumber].FR2 = |
sahilmgandhi | 18:6a4db94011d3 | 408 | ((0x0000FFFFU & (uint32_t)sFilterConfig->FilterMaskIdHigh) << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 409 | (0x0000FFFFU & (uint32_t)sFilterConfig->FilterMaskIdLow); |
sahilmgandhi | 18:6a4db94011d3 | 410 | } |
sahilmgandhi | 18:6a4db94011d3 | 411 | |
sahilmgandhi | 18:6a4db94011d3 | 412 | /* Filter Mode */ |
sahilmgandhi | 18:6a4db94011d3 | 413 | if (sFilterConfig->FilterMode == CAN_FILTERMODE_IDMASK) |
sahilmgandhi | 18:6a4db94011d3 | 414 | { |
sahilmgandhi | 18:6a4db94011d3 | 415 | /*Id/Mask mode for the filter*/ |
sahilmgandhi | 18:6a4db94011d3 | 416 | CAN1->FM1R &= ~(uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 417 | } |
sahilmgandhi | 18:6a4db94011d3 | 418 | else /* CAN_FilterInitStruct->CAN_FilterMode == CAN_FilterMode_IdList */ |
sahilmgandhi | 18:6a4db94011d3 | 419 | { |
sahilmgandhi | 18:6a4db94011d3 | 420 | /*Identifier list mode for the filter*/ |
sahilmgandhi | 18:6a4db94011d3 | 421 | CAN1->FM1R |= (uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 422 | } |
sahilmgandhi | 18:6a4db94011d3 | 423 | |
sahilmgandhi | 18:6a4db94011d3 | 424 | /* Filter FIFO assignment */ |
sahilmgandhi | 18:6a4db94011d3 | 425 | if (sFilterConfig->FilterFIFOAssignment == CAN_FILTER_FIFO0) |
sahilmgandhi | 18:6a4db94011d3 | 426 | { |
sahilmgandhi | 18:6a4db94011d3 | 427 | /* FIFO 0 assignation for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 428 | CAN1->FFA1R &= ~(uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 429 | } |
sahilmgandhi | 18:6a4db94011d3 | 430 | |
sahilmgandhi | 18:6a4db94011d3 | 431 | if (sFilterConfig->FilterFIFOAssignment == CAN_FILTER_FIFO1) |
sahilmgandhi | 18:6a4db94011d3 | 432 | { |
sahilmgandhi | 18:6a4db94011d3 | 433 | /* FIFO 1 assignation for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 434 | CAN1->FFA1R |= (uint32_t)filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 435 | } |
sahilmgandhi | 18:6a4db94011d3 | 436 | |
sahilmgandhi | 18:6a4db94011d3 | 437 | /* Filter activation */ |
sahilmgandhi | 18:6a4db94011d3 | 438 | if (sFilterConfig->FilterActivation == ENABLE) |
sahilmgandhi | 18:6a4db94011d3 | 439 | { |
sahilmgandhi | 18:6a4db94011d3 | 440 | CAN1->FA1R |= filternbrbitpos; |
sahilmgandhi | 18:6a4db94011d3 | 441 | } |
sahilmgandhi | 18:6a4db94011d3 | 442 | |
sahilmgandhi | 18:6a4db94011d3 | 443 | /* Leave the initialisation mode for the filter */ |
sahilmgandhi | 18:6a4db94011d3 | 444 | CAN1->FMR &= ~((uint32_t)CAN_FMR_FINIT); |
sahilmgandhi | 18:6a4db94011d3 | 445 | |
sahilmgandhi | 18:6a4db94011d3 | 446 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 447 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 448 | } |
sahilmgandhi | 18:6a4db94011d3 | 449 | |
sahilmgandhi | 18:6a4db94011d3 | 450 | /** |
sahilmgandhi | 18:6a4db94011d3 | 451 | * @brief Deinitializes the CANx peripheral registers to their default reset values. |
sahilmgandhi | 18:6a4db94011d3 | 452 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 453 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 454 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 455 | */ |
sahilmgandhi | 18:6a4db94011d3 | 456 | HAL_StatusTypeDef HAL_CAN_DeInit(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 457 | { |
sahilmgandhi | 18:6a4db94011d3 | 458 | /* Check CAN handle */ |
sahilmgandhi | 18:6a4db94011d3 | 459 | if(hcan == NULL) |
sahilmgandhi | 18:6a4db94011d3 | 460 | { |
sahilmgandhi | 18:6a4db94011d3 | 461 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 462 | } |
sahilmgandhi | 18:6a4db94011d3 | 463 | |
sahilmgandhi | 18:6a4db94011d3 | 464 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 465 | assert_param(IS_CAN_ALL_INSTANCE(hcan->Instance)); |
sahilmgandhi | 18:6a4db94011d3 | 466 | |
sahilmgandhi | 18:6a4db94011d3 | 467 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 468 | hcan->State = HAL_CAN_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 469 | |
sahilmgandhi | 18:6a4db94011d3 | 470 | /* DeInit the low level hardware */ |
sahilmgandhi | 18:6a4db94011d3 | 471 | HAL_CAN_MspDeInit(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 472 | |
sahilmgandhi | 18:6a4db94011d3 | 473 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 474 | hcan->State = HAL_CAN_STATE_RESET; |
sahilmgandhi | 18:6a4db94011d3 | 475 | |
sahilmgandhi | 18:6a4db94011d3 | 476 | /* Release Lock */ |
sahilmgandhi | 18:6a4db94011d3 | 477 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 478 | |
sahilmgandhi | 18:6a4db94011d3 | 479 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 480 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 481 | } |
sahilmgandhi | 18:6a4db94011d3 | 482 | |
sahilmgandhi | 18:6a4db94011d3 | 483 | /** |
sahilmgandhi | 18:6a4db94011d3 | 484 | * @brief Initializes the CAN MSP. |
sahilmgandhi | 18:6a4db94011d3 | 485 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 486 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 487 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 488 | */ |
sahilmgandhi | 18:6a4db94011d3 | 489 | __weak void HAL_CAN_MspInit(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 490 | { |
sahilmgandhi | 18:6a4db94011d3 | 491 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 492 | UNUSED(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 493 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 494 | the HAL_CAN_MspInit could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 495 | */ |
sahilmgandhi | 18:6a4db94011d3 | 496 | } |
sahilmgandhi | 18:6a4db94011d3 | 497 | |
sahilmgandhi | 18:6a4db94011d3 | 498 | /** |
sahilmgandhi | 18:6a4db94011d3 | 499 | * @brief DeInitializes the CAN MSP. |
sahilmgandhi | 18:6a4db94011d3 | 500 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 501 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 502 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 503 | */ |
sahilmgandhi | 18:6a4db94011d3 | 504 | __weak void HAL_CAN_MspDeInit(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 505 | { |
sahilmgandhi | 18:6a4db94011d3 | 506 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 507 | UNUSED(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 508 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 509 | the HAL_CAN_MspDeInit could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 510 | */ |
sahilmgandhi | 18:6a4db94011d3 | 511 | } |
sahilmgandhi | 18:6a4db94011d3 | 512 | |
sahilmgandhi | 18:6a4db94011d3 | 513 | /** |
sahilmgandhi | 18:6a4db94011d3 | 514 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 515 | */ |
sahilmgandhi | 18:6a4db94011d3 | 516 | |
sahilmgandhi | 18:6a4db94011d3 | 517 | /** @defgroup CAN_Exported_Functions_Group2 IO operation functions |
sahilmgandhi | 18:6a4db94011d3 | 518 | * @brief IO operation functions |
sahilmgandhi | 18:6a4db94011d3 | 519 | * |
sahilmgandhi | 18:6a4db94011d3 | 520 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 521 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 522 | ##### IO operation functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 523 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 524 | [..] This section provides functions allowing to: |
sahilmgandhi | 18:6a4db94011d3 | 525 | (+) Transmit a CAN frame message. |
sahilmgandhi | 18:6a4db94011d3 | 526 | (+) Receive a CAN frame message. |
sahilmgandhi | 18:6a4db94011d3 | 527 | (+) Enter CAN peripheral in sleep mode. |
sahilmgandhi | 18:6a4db94011d3 | 528 | (+) Wake up the CAN peripheral from sleep mode. |
sahilmgandhi | 18:6a4db94011d3 | 529 | |
sahilmgandhi | 18:6a4db94011d3 | 530 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 531 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 532 | */ |
sahilmgandhi | 18:6a4db94011d3 | 533 | |
sahilmgandhi | 18:6a4db94011d3 | 534 | /** |
sahilmgandhi | 18:6a4db94011d3 | 535 | * @brief Initiates and transmits a CAN frame message. |
sahilmgandhi | 18:6a4db94011d3 | 536 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 537 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 538 | * @param Timeout: Specify Timeout value |
sahilmgandhi | 18:6a4db94011d3 | 539 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 540 | */ |
sahilmgandhi | 18:6a4db94011d3 | 541 | HAL_StatusTypeDef HAL_CAN_Transmit(CAN_HandleTypeDef* hcan, uint32_t Timeout) |
sahilmgandhi | 18:6a4db94011d3 | 542 | { |
sahilmgandhi | 18:6a4db94011d3 | 543 | uint32_t transmitmailbox = 5U; |
sahilmgandhi | 18:6a4db94011d3 | 544 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 545 | |
sahilmgandhi | 18:6a4db94011d3 | 546 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 547 | assert_param(IS_CAN_IDTYPE(hcan->pTxMsg->IDE)); |
sahilmgandhi | 18:6a4db94011d3 | 548 | assert_param(IS_CAN_RTR(hcan->pTxMsg->RTR)); |
sahilmgandhi | 18:6a4db94011d3 | 549 | assert_param(IS_CAN_DLC(hcan->pTxMsg->DLC)); |
sahilmgandhi | 18:6a4db94011d3 | 550 | |
sahilmgandhi | 18:6a4db94011d3 | 551 | if(((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) || \ |
sahilmgandhi | 18:6a4db94011d3 | 552 | ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) || \ |
sahilmgandhi | 18:6a4db94011d3 | 553 | ((hcan->Instance->TSR&CAN_TSR_TME2) == CAN_TSR_TME2)) |
sahilmgandhi | 18:6a4db94011d3 | 554 | { |
sahilmgandhi | 18:6a4db94011d3 | 555 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 556 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 557 | |
sahilmgandhi | 18:6a4db94011d3 | 558 | if(hcan->State == HAL_CAN_STATE_BUSY_RX) |
sahilmgandhi | 18:6a4db94011d3 | 559 | { |
sahilmgandhi | 18:6a4db94011d3 | 560 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 561 | hcan->State = HAL_CAN_STATE_BUSY_TX_RX; |
sahilmgandhi | 18:6a4db94011d3 | 562 | } |
sahilmgandhi | 18:6a4db94011d3 | 563 | else |
sahilmgandhi | 18:6a4db94011d3 | 564 | { |
sahilmgandhi | 18:6a4db94011d3 | 565 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 566 | hcan->State = HAL_CAN_STATE_BUSY_TX; |
sahilmgandhi | 18:6a4db94011d3 | 567 | } |
sahilmgandhi | 18:6a4db94011d3 | 568 | |
sahilmgandhi | 18:6a4db94011d3 | 569 | /* Select one empty transmit mailbox */ |
sahilmgandhi | 18:6a4db94011d3 | 570 | if ((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) |
sahilmgandhi | 18:6a4db94011d3 | 571 | { |
sahilmgandhi | 18:6a4db94011d3 | 572 | transmitmailbox = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 573 | } |
sahilmgandhi | 18:6a4db94011d3 | 574 | else if ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) |
sahilmgandhi | 18:6a4db94011d3 | 575 | { |
sahilmgandhi | 18:6a4db94011d3 | 576 | transmitmailbox = 1U; |
sahilmgandhi | 18:6a4db94011d3 | 577 | } |
sahilmgandhi | 18:6a4db94011d3 | 578 | else |
sahilmgandhi | 18:6a4db94011d3 | 579 | { |
sahilmgandhi | 18:6a4db94011d3 | 580 | transmitmailbox = 2U; |
sahilmgandhi | 18:6a4db94011d3 | 581 | } |
sahilmgandhi | 18:6a4db94011d3 | 582 | |
sahilmgandhi | 18:6a4db94011d3 | 583 | /* Set up the Id */ |
sahilmgandhi | 18:6a4db94011d3 | 584 | hcan->Instance->sTxMailBox[transmitmailbox].TIR &= CAN_TI0R_TXRQ; |
sahilmgandhi | 18:6a4db94011d3 | 585 | if (hcan->pTxMsg->IDE == CAN_ID_STD) |
sahilmgandhi | 18:6a4db94011d3 | 586 | { |
sahilmgandhi | 18:6a4db94011d3 | 587 | assert_param(IS_CAN_STDID(hcan->pTxMsg->StdId)); |
sahilmgandhi | 18:6a4db94011d3 | 588 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->StdId << 21U) | \ |
sahilmgandhi | 18:6a4db94011d3 | 589 | hcan->pTxMsg->RTR); |
sahilmgandhi | 18:6a4db94011d3 | 590 | } |
sahilmgandhi | 18:6a4db94011d3 | 591 | else |
sahilmgandhi | 18:6a4db94011d3 | 592 | { |
sahilmgandhi | 18:6a4db94011d3 | 593 | assert_param(IS_CAN_EXTID(hcan->pTxMsg->ExtId)); |
sahilmgandhi | 18:6a4db94011d3 | 594 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->ExtId << 3U) | \ |
sahilmgandhi | 18:6a4db94011d3 | 595 | hcan->pTxMsg->IDE | \ |
sahilmgandhi | 18:6a4db94011d3 | 596 | hcan->pTxMsg->RTR); |
sahilmgandhi | 18:6a4db94011d3 | 597 | } |
sahilmgandhi | 18:6a4db94011d3 | 598 | |
sahilmgandhi | 18:6a4db94011d3 | 599 | /* Set up the DLC */ |
sahilmgandhi | 18:6a4db94011d3 | 600 | hcan->pTxMsg->DLC &= (uint8_t)0x0000000FU; |
sahilmgandhi | 18:6a4db94011d3 | 601 | hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= (uint32_t)0xFFFFFFF0U; |
sahilmgandhi | 18:6a4db94011d3 | 602 | hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC; |
sahilmgandhi | 18:6a4db94011d3 | 603 | |
sahilmgandhi | 18:6a4db94011d3 | 604 | /* Set up the data field */ |
sahilmgandhi | 18:6a4db94011d3 | 605 | hcan->Instance->sTxMailBox[transmitmailbox].TDLR = (((uint32_t)hcan->pTxMsg->Data[3U] << 24U) | |
sahilmgandhi | 18:6a4db94011d3 | 606 | ((uint32_t)hcan->pTxMsg->Data[2U] << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 607 | ((uint32_t)hcan->pTxMsg->Data[1U] << 8U) | |
sahilmgandhi | 18:6a4db94011d3 | 608 | ((uint32_t)hcan->pTxMsg->Data[0U])); |
sahilmgandhi | 18:6a4db94011d3 | 609 | hcan->Instance->sTxMailBox[transmitmailbox].TDHR = (((uint32_t)hcan->pTxMsg->Data[7U] << 24U) | |
sahilmgandhi | 18:6a4db94011d3 | 610 | ((uint32_t)hcan->pTxMsg->Data[6U] << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 611 | ((uint32_t)hcan->pTxMsg->Data[5U] << 8U) | |
sahilmgandhi | 18:6a4db94011d3 | 612 | ((uint32_t)hcan->pTxMsg->Data[4U])); |
sahilmgandhi | 18:6a4db94011d3 | 613 | /* Request transmission */ |
sahilmgandhi | 18:6a4db94011d3 | 614 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= CAN_TI0R_TXRQ; |
sahilmgandhi | 18:6a4db94011d3 | 615 | |
sahilmgandhi | 18:6a4db94011d3 | 616 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 617 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 618 | |
sahilmgandhi | 18:6a4db94011d3 | 619 | /* Check End of transmission flag */ |
sahilmgandhi | 18:6a4db94011d3 | 620 | while(!(__HAL_CAN_TRANSMIT_STATUS(hcan, transmitmailbox))) |
sahilmgandhi | 18:6a4db94011d3 | 621 | { |
sahilmgandhi | 18:6a4db94011d3 | 622 | /* Check for the Timeout */ |
sahilmgandhi | 18:6a4db94011d3 | 623 | if(Timeout != HAL_MAX_DELAY) |
sahilmgandhi | 18:6a4db94011d3 | 624 | { |
sahilmgandhi | 18:6a4db94011d3 | 625 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
sahilmgandhi | 18:6a4db94011d3 | 626 | { |
sahilmgandhi | 18:6a4db94011d3 | 627 | hcan->State = HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 628 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 629 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 630 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 631 | } |
sahilmgandhi | 18:6a4db94011d3 | 632 | } |
sahilmgandhi | 18:6a4db94011d3 | 633 | } |
sahilmgandhi | 18:6a4db94011d3 | 634 | if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX) |
sahilmgandhi | 18:6a4db94011d3 | 635 | { |
sahilmgandhi | 18:6a4db94011d3 | 636 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 637 | hcan->State = HAL_CAN_STATE_BUSY_RX; |
sahilmgandhi | 18:6a4db94011d3 | 638 | } |
sahilmgandhi | 18:6a4db94011d3 | 639 | else |
sahilmgandhi | 18:6a4db94011d3 | 640 | { |
sahilmgandhi | 18:6a4db94011d3 | 641 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 642 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 643 | } |
sahilmgandhi | 18:6a4db94011d3 | 644 | |
sahilmgandhi | 18:6a4db94011d3 | 645 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 646 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 647 | |
sahilmgandhi | 18:6a4db94011d3 | 648 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 649 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 650 | } |
sahilmgandhi | 18:6a4db94011d3 | 651 | else |
sahilmgandhi | 18:6a4db94011d3 | 652 | { |
sahilmgandhi | 18:6a4db94011d3 | 653 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 654 | hcan->State = HAL_CAN_STATE_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 655 | |
sahilmgandhi | 18:6a4db94011d3 | 656 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 657 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 658 | } |
sahilmgandhi | 18:6a4db94011d3 | 659 | } |
sahilmgandhi | 18:6a4db94011d3 | 660 | |
sahilmgandhi | 18:6a4db94011d3 | 661 | /** |
sahilmgandhi | 18:6a4db94011d3 | 662 | * @brief Initiates and transmits a CAN frame message. |
sahilmgandhi | 18:6a4db94011d3 | 663 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 664 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 665 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 666 | */ |
sahilmgandhi | 18:6a4db94011d3 | 667 | HAL_StatusTypeDef HAL_CAN_Transmit_IT(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 668 | { |
sahilmgandhi | 18:6a4db94011d3 | 669 | uint32_t transmitmailbox = 5U; |
sahilmgandhi | 18:6a4db94011d3 | 670 | |
sahilmgandhi | 18:6a4db94011d3 | 671 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 672 | assert_param(IS_CAN_IDTYPE(hcan->pTxMsg->IDE)); |
sahilmgandhi | 18:6a4db94011d3 | 673 | assert_param(IS_CAN_RTR(hcan->pTxMsg->RTR)); |
sahilmgandhi | 18:6a4db94011d3 | 674 | assert_param(IS_CAN_DLC(hcan->pTxMsg->DLC)); |
sahilmgandhi | 18:6a4db94011d3 | 675 | |
sahilmgandhi | 18:6a4db94011d3 | 676 | if(((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) || \ |
sahilmgandhi | 18:6a4db94011d3 | 677 | ((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) || \ |
sahilmgandhi | 18:6a4db94011d3 | 678 | ((hcan->Instance->TSR&CAN_TSR_TME2) == CAN_TSR_TME2)) |
sahilmgandhi | 18:6a4db94011d3 | 679 | { |
sahilmgandhi | 18:6a4db94011d3 | 680 | /* Process Locked */ |
sahilmgandhi | 18:6a4db94011d3 | 681 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 682 | |
sahilmgandhi | 18:6a4db94011d3 | 683 | /* Select one empty transmit mailbox */ |
sahilmgandhi | 18:6a4db94011d3 | 684 | if((hcan->Instance->TSR&CAN_TSR_TME0) == CAN_TSR_TME0) |
sahilmgandhi | 18:6a4db94011d3 | 685 | { |
sahilmgandhi | 18:6a4db94011d3 | 686 | transmitmailbox = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 687 | } |
sahilmgandhi | 18:6a4db94011d3 | 688 | else if((hcan->Instance->TSR&CAN_TSR_TME1) == CAN_TSR_TME1) |
sahilmgandhi | 18:6a4db94011d3 | 689 | { |
sahilmgandhi | 18:6a4db94011d3 | 690 | transmitmailbox = 1U; |
sahilmgandhi | 18:6a4db94011d3 | 691 | } |
sahilmgandhi | 18:6a4db94011d3 | 692 | else |
sahilmgandhi | 18:6a4db94011d3 | 693 | { |
sahilmgandhi | 18:6a4db94011d3 | 694 | transmitmailbox = 2U; |
sahilmgandhi | 18:6a4db94011d3 | 695 | } |
sahilmgandhi | 18:6a4db94011d3 | 696 | |
sahilmgandhi | 18:6a4db94011d3 | 697 | /* Set up the Id */ |
sahilmgandhi | 18:6a4db94011d3 | 698 | hcan->Instance->sTxMailBox[transmitmailbox].TIR &= CAN_TI0R_TXRQ; |
sahilmgandhi | 18:6a4db94011d3 | 699 | if(hcan->pTxMsg->IDE == CAN_ID_STD) |
sahilmgandhi | 18:6a4db94011d3 | 700 | { |
sahilmgandhi | 18:6a4db94011d3 | 701 | assert_param(IS_CAN_STDID(hcan->pTxMsg->StdId)); |
sahilmgandhi | 18:6a4db94011d3 | 702 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->StdId << 21U) | \ |
sahilmgandhi | 18:6a4db94011d3 | 703 | hcan->pTxMsg->RTR); |
sahilmgandhi | 18:6a4db94011d3 | 704 | } |
sahilmgandhi | 18:6a4db94011d3 | 705 | else |
sahilmgandhi | 18:6a4db94011d3 | 706 | { |
sahilmgandhi | 18:6a4db94011d3 | 707 | assert_param(IS_CAN_EXTID(hcan->pTxMsg->ExtId)); |
sahilmgandhi | 18:6a4db94011d3 | 708 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= ((hcan->pTxMsg->ExtId << 3U) | \ |
sahilmgandhi | 18:6a4db94011d3 | 709 | hcan->pTxMsg->IDE | \ |
sahilmgandhi | 18:6a4db94011d3 | 710 | hcan->pTxMsg->RTR); |
sahilmgandhi | 18:6a4db94011d3 | 711 | } |
sahilmgandhi | 18:6a4db94011d3 | 712 | |
sahilmgandhi | 18:6a4db94011d3 | 713 | /* Set up the DLC */ |
sahilmgandhi | 18:6a4db94011d3 | 714 | hcan->pTxMsg->DLC &= (uint8_t)0x0000000FU; |
sahilmgandhi | 18:6a4db94011d3 | 715 | hcan->Instance->sTxMailBox[transmitmailbox].TDTR &= (uint32_t)0xFFFFFFF0U; |
sahilmgandhi | 18:6a4db94011d3 | 716 | hcan->Instance->sTxMailBox[transmitmailbox].TDTR |= hcan->pTxMsg->DLC; |
sahilmgandhi | 18:6a4db94011d3 | 717 | |
sahilmgandhi | 18:6a4db94011d3 | 718 | /* Set up the data field */ |
sahilmgandhi | 18:6a4db94011d3 | 719 | hcan->Instance->sTxMailBox[transmitmailbox].TDLR = (((uint32_t)hcan->pTxMsg->Data[3U] << 24U) | |
sahilmgandhi | 18:6a4db94011d3 | 720 | ((uint32_t)hcan->pTxMsg->Data[2U] << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 721 | ((uint32_t)hcan->pTxMsg->Data[1U] << 8U) | |
sahilmgandhi | 18:6a4db94011d3 | 722 | ((uint32_t)hcan->pTxMsg->Data[0U])); |
sahilmgandhi | 18:6a4db94011d3 | 723 | hcan->Instance->sTxMailBox[transmitmailbox].TDHR = (((uint32_t)hcan->pTxMsg->Data[7U] << 24U) | |
sahilmgandhi | 18:6a4db94011d3 | 724 | ((uint32_t)hcan->pTxMsg->Data[6U] << 16U) | |
sahilmgandhi | 18:6a4db94011d3 | 725 | ((uint32_t)hcan->pTxMsg->Data[5U] << 8U) | |
sahilmgandhi | 18:6a4db94011d3 | 726 | ((uint32_t)hcan->pTxMsg->Data[4U])); |
sahilmgandhi | 18:6a4db94011d3 | 727 | |
sahilmgandhi | 18:6a4db94011d3 | 728 | if(hcan->State == HAL_CAN_STATE_BUSY_RX) |
sahilmgandhi | 18:6a4db94011d3 | 729 | { |
sahilmgandhi | 18:6a4db94011d3 | 730 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 731 | hcan->State = HAL_CAN_STATE_BUSY_TX_RX; |
sahilmgandhi | 18:6a4db94011d3 | 732 | } |
sahilmgandhi | 18:6a4db94011d3 | 733 | else |
sahilmgandhi | 18:6a4db94011d3 | 734 | { |
sahilmgandhi | 18:6a4db94011d3 | 735 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 736 | hcan->State = HAL_CAN_STATE_BUSY_TX; |
sahilmgandhi | 18:6a4db94011d3 | 737 | } |
sahilmgandhi | 18:6a4db94011d3 | 738 | |
sahilmgandhi | 18:6a4db94011d3 | 739 | /* Set CAN error code to none */ |
sahilmgandhi | 18:6a4db94011d3 | 740 | hcan->ErrorCode = HAL_CAN_ERROR_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 741 | |
sahilmgandhi | 18:6a4db94011d3 | 742 | /* Process Unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 743 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 744 | |
sahilmgandhi | 18:6a4db94011d3 | 745 | /* Enable Error warning Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 746 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 747 | |
sahilmgandhi | 18:6a4db94011d3 | 748 | /* Enable Error passive Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 749 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 750 | |
sahilmgandhi | 18:6a4db94011d3 | 751 | /* Enable Bus-off Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 752 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 753 | |
sahilmgandhi | 18:6a4db94011d3 | 754 | /* Enable Last error code Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 755 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 756 | |
sahilmgandhi | 18:6a4db94011d3 | 757 | /* Enable Error Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 758 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 759 | |
sahilmgandhi | 18:6a4db94011d3 | 760 | /* Enable Transmit mailbox empty Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 761 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_TME); |
sahilmgandhi | 18:6a4db94011d3 | 762 | |
sahilmgandhi | 18:6a4db94011d3 | 763 | /* Request transmission */ |
sahilmgandhi | 18:6a4db94011d3 | 764 | hcan->Instance->sTxMailBox[transmitmailbox].TIR |= CAN_TI0R_TXRQ; |
sahilmgandhi | 18:6a4db94011d3 | 765 | } |
sahilmgandhi | 18:6a4db94011d3 | 766 | else |
sahilmgandhi | 18:6a4db94011d3 | 767 | { |
sahilmgandhi | 18:6a4db94011d3 | 768 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 769 | hcan->State = HAL_CAN_STATE_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 770 | |
sahilmgandhi | 18:6a4db94011d3 | 771 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 772 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 773 | } |
sahilmgandhi | 18:6a4db94011d3 | 774 | |
sahilmgandhi | 18:6a4db94011d3 | 775 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 776 | } |
sahilmgandhi | 18:6a4db94011d3 | 777 | |
sahilmgandhi | 18:6a4db94011d3 | 778 | /** |
sahilmgandhi | 18:6a4db94011d3 | 779 | * @brief Receives a correct CAN frame. |
sahilmgandhi | 18:6a4db94011d3 | 780 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 781 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 782 | * @param FIFONumber: FIFO Number value |
sahilmgandhi | 18:6a4db94011d3 | 783 | * @param Timeout: Specify Timeout value |
sahilmgandhi | 18:6a4db94011d3 | 784 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 785 | */ |
sahilmgandhi | 18:6a4db94011d3 | 786 | HAL_StatusTypeDef HAL_CAN_Receive(CAN_HandleTypeDef* hcan, uint8_t FIFONumber, uint32_t Timeout) |
sahilmgandhi | 18:6a4db94011d3 | 787 | { |
sahilmgandhi | 18:6a4db94011d3 | 788 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 789 | |
sahilmgandhi | 18:6a4db94011d3 | 790 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 791 | assert_param(IS_CAN_FIFO(FIFONumber)); |
sahilmgandhi | 18:6a4db94011d3 | 792 | |
sahilmgandhi | 18:6a4db94011d3 | 793 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 794 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 795 | |
sahilmgandhi | 18:6a4db94011d3 | 796 | if(hcan->State == HAL_CAN_STATE_BUSY_TX) |
sahilmgandhi | 18:6a4db94011d3 | 797 | { |
sahilmgandhi | 18:6a4db94011d3 | 798 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 799 | hcan->State = HAL_CAN_STATE_BUSY_TX_RX; |
sahilmgandhi | 18:6a4db94011d3 | 800 | } |
sahilmgandhi | 18:6a4db94011d3 | 801 | else |
sahilmgandhi | 18:6a4db94011d3 | 802 | { |
sahilmgandhi | 18:6a4db94011d3 | 803 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 804 | hcan->State = HAL_CAN_STATE_BUSY_RX; |
sahilmgandhi | 18:6a4db94011d3 | 805 | } |
sahilmgandhi | 18:6a4db94011d3 | 806 | |
sahilmgandhi | 18:6a4db94011d3 | 807 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 808 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 809 | |
sahilmgandhi | 18:6a4db94011d3 | 810 | /* Check pending message */ |
sahilmgandhi | 18:6a4db94011d3 | 811 | while(__HAL_CAN_MSG_PENDING(hcan, FIFONumber) == 0U) |
sahilmgandhi | 18:6a4db94011d3 | 812 | { |
sahilmgandhi | 18:6a4db94011d3 | 813 | /* Check for the Timeout */ |
sahilmgandhi | 18:6a4db94011d3 | 814 | if(Timeout != HAL_MAX_DELAY) |
sahilmgandhi | 18:6a4db94011d3 | 815 | { |
sahilmgandhi | 18:6a4db94011d3 | 816 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
sahilmgandhi | 18:6a4db94011d3 | 817 | { |
sahilmgandhi | 18:6a4db94011d3 | 818 | hcan->State = HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 819 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 820 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 821 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 822 | } |
sahilmgandhi | 18:6a4db94011d3 | 823 | } |
sahilmgandhi | 18:6a4db94011d3 | 824 | } |
sahilmgandhi | 18:6a4db94011d3 | 825 | |
sahilmgandhi | 18:6a4db94011d3 | 826 | /* Get the Id */ |
sahilmgandhi | 18:6a4db94011d3 | 827 | hcan->pRxMsg->IDE = (uint8_t)0x04 & hcan->Instance->sFIFOMailBox[FIFONumber].RIR; |
sahilmgandhi | 18:6a4db94011d3 | 828 | if (hcan->pRxMsg->IDE == CAN_ID_STD) |
sahilmgandhi | 18:6a4db94011d3 | 829 | { |
sahilmgandhi | 18:6a4db94011d3 | 830 | hcan->pRxMsg->StdId = (uint32_t)0x000007FFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 21U); |
sahilmgandhi | 18:6a4db94011d3 | 831 | } |
sahilmgandhi | 18:6a4db94011d3 | 832 | else |
sahilmgandhi | 18:6a4db94011d3 | 833 | { |
sahilmgandhi | 18:6a4db94011d3 | 834 | hcan->pRxMsg->ExtId = (uint32_t)0x1FFFFFFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 3U); |
sahilmgandhi | 18:6a4db94011d3 | 835 | } |
sahilmgandhi | 18:6a4db94011d3 | 836 | |
sahilmgandhi | 18:6a4db94011d3 | 837 | hcan->pRxMsg->RTR = (uint8_t)0x02U & hcan->Instance->sFIFOMailBox[FIFONumber].RIR; |
sahilmgandhi | 18:6a4db94011d3 | 838 | /* Get the DLC */ |
sahilmgandhi | 18:6a4db94011d3 | 839 | hcan->pRxMsg->DLC = (uint8_t)0x0FU & hcan->Instance->sFIFOMailBox[FIFONumber].RDTR; |
sahilmgandhi | 18:6a4db94011d3 | 840 | /* Get the FMI */ |
sahilmgandhi | 18:6a4db94011d3 | 841 | hcan->pRxMsg->FMI = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 842 | /* Get the data field */ |
sahilmgandhi | 18:6a4db94011d3 | 843 | hcan->pRxMsg->Data[0U] = (uint8_t)0xFFU & hcan->Instance->sFIFOMailBox[FIFONumber].RDLR; |
sahilmgandhi | 18:6a4db94011d3 | 844 | hcan->pRxMsg->Data[1U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 845 | hcan->pRxMsg->Data[2U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 16U); |
sahilmgandhi | 18:6a4db94011d3 | 846 | hcan->pRxMsg->Data[3U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 24U); |
sahilmgandhi | 18:6a4db94011d3 | 847 | hcan->pRxMsg->Data[4U] = (uint8_t)0xFFU & hcan->Instance->sFIFOMailBox[FIFONumber].RDHR; |
sahilmgandhi | 18:6a4db94011d3 | 848 | hcan->pRxMsg->Data[5U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 849 | hcan->pRxMsg->Data[6U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 16U); |
sahilmgandhi | 18:6a4db94011d3 | 850 | hcan->pRxMsg->Data[7U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 24U); |
sahilmgandhi | 18:6a4db94011d3 | 851 | |
sahilmgandhi | 18:6a4db94011d3 | 852 | /* Release the FIFO */ |
sahilmgandhi | 18:6a4db94011d3 | 853 | if(FIFONumber == CAN_FIFO0) |
sahilmgandhi | 18:6a4db94011d3 | 854 | { |
sahilmgandhi | 18:6a4db94011d3 | 855 | /* Release FIFO0 */ |
sahilmgandhi | 18:6a4db94011d3 | 856 | __HAL_CAN_FIFO_RELEASE(hcan, CAN_FIFO0); |
sahilmgandhi | 18:6a4db94011d3 | 857 | } |
sahilmgandhi | 18:6a4db94011d3 | 858 | else /* FIFONumber == CAN_FIFO1 */ |
sahilmgandhi | 18:6a4db94011d3 | 859 | { |
sahilmgandhi | 18:6a4db94011d3 | 860 | /* Release FIFO1 */ |
sahilmgandhi | 18:6a4db94011d3 | 861 | __HAL_CAN_FIFO_RELEASE(hcan, CAN_FIFO1); |
sahilmgandhi | 18:6a4db94011d3 | 862 | } |
sahilmgandhi | 18:6a4db94011d3 | 863 | |
sahilmgandhi | 18:6a4db94011d3 | 864 | if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX) |
sahilmgandhi | 18:6a4db94011d3 | 865 | { |
sahilmgandhi | 18:6a4db94011d3 | 866 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 867 | hcan->State = HAL_CAN_STATE_BUSY_TX; |
sahilmgandhi | 18:6a4db94011d3 | 868 | |
sahilmgandhi | 18:6a4db94011d3 | 869 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 870 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 871 | } |
sahilmgandhi | 18:6a4db94011d3 | 872 | else |
sahilmgandhi | 18:6a4db94011d3 | 873 | { |
sahilmgandhi | 18:6a4db94011d3 | 874 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 875 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 876 | |
sahilmgandhi | 18:6a4db94011d3 | 877 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 878 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 879 | } |
sahilmgandhi | 18:6a4db94011d3 | 880 | |
sahilmgandhi | 18:6a4db94011d3 | 881 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 882 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 883 | } |
sahilmgandhi | 18:6a4db94011d3 | 884 | |
sahilmgandhi | 18:6a4db94011d3 | 885 | /** |
sahilmgandhi | 18:6a4db94011d3 | 886 | * @brief Receives a correct CAN frame. |
sahilmgandhi | 18:6a4db94011d3 | 887 | * @param hcan: Pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 888 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 889 | * @param FIFONumber: Specify the FIFO number |
sahilmgandhi | 18:6a4db94011d3 | 890 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 891 | */ |
sahilmgandhi | 18:6a4db94011d3 | 892 | HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber) |
sahilmgandhi | 18:6a4db94011d3 | 893 | { |
sahilmgandhi | 18:6a4db94011d3 | 894 | uint32_t tmp = 0; |
sahilmgandhi | 18:6a4db94011d3 | 895 | |
sahilmgandhi | 18:6a4db94011d3 | 896 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 897 | assert_param(IS_CAN_FIFO(FIFONumber)); |
sahilmgandhi | 18:6a4db94011d3 | 898 | |
sahilmgandhi | 18:6a4db94011d3 | 899 | tmp = hcan->State; |
sahilmgandhi | 18:6a4db94011d3 | 900 | if((tmp == HAL_CAN_STATE_READY) || (tmp == HAL_CAN_STATE_BUSY_TX)) |
sahilmgandhi | 18:6a4db94011d3 | 901 | { |
sahilmgandhi | 18:6a4db94011d3 | 902 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 903 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 904 | |
sahilmgandhi | 18:6a4db94011d3 | 905 | if(hcan->State == HAL_CAN_STATE_BUSY_TX) |
sahilmgandhi | 18:6a4db94011d3 | 906 | { |
sahilmgandhi | 18:6a4db94011d3 | 907 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 908 | hcan->State = HAL_CAN_STATE_BUSY_TX_RX; |
sahilmgandhi | 18:6a4db94011d3 | 909 | } |
sahilmgandhi | 18:6a4db94011d3 | 910 | else |
sahilmgandhi | 18:6a4db94011d3 | 911 | { |
sahilmgandhi | 18:6a4db94011d3 | 912 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 913 | hcan->State = HAL_CAN_STATE_BUSY_RX; |
sahilmgandhi | 18:6a4db94011d3 | 914 | } |
sahilmgandhi | 18:6a4db94011d3 | 915 | |
sahilmgandhi | 18:6a4db94011d3 | 916 | /* Set CAN error code to none */ |
sahilmgandhi | 18:6a4db94011d3 | 917 | hcan->ErrorCode = HAL_CAN_ERROR_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 918 | |
sahilmgandhi | 18:6a4db94011d3 | 919 | /* Enable Error warning Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 920 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 921 | |
sahilmgandhi | 18:6a4db94011d3 | 922 | /* Enable Error passive Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 923 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 924 | |
sahilmgandhi | 18:6a4db94011d3 | 925 | /* Enable Bus-off Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 926 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 927 | |
sahilmgandhi | 18:6a4db94011d3 | 928 | /* Enable Last error code Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 929 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 930 | |
sahilmgandhi | 18:6a4db94011d3 | 931 | /* Enable Error Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 932 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 933 | |
sahilmgandhi | 18:6a4db94011d3 | 934 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 935 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 936 | |
sahilmgandhi | 18:6a4db94011d3 | 937 | if(FIFONumber == CAN_FIFO0) |
sahilmgandhi | 18:6a4db94011d3 | 938 | { |
sahilmgandhi | 18:6a4db94011d3 | 939 | /* Enable FIFO 0 message pending Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 940 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FMP0); |
sahilmgandhi | 18:6a4db94011d3 | 941 | } |
sahilmgandhi | 18:6a4db94011d3 | 942 | else |
sahilmgandhi | 18:6a4db94011d3 | 943 | { |
sahilmgandhi | 18:6a4db94011d3 | 944 | /* Enable FIFO 1 message pending Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 945 | __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FMP1); |
sahilmgandhi | 18:6a4db94011d3 | 946 | } |
sahilmgandhi | 18:6a4db94011d3 | 947 | |
sahilmgandhi | 18:6a4db94011d3 | 948 | } |
sahilmgandhi | 18:6a4db94011d3 | 949 | else |
sahilmgandhi | 18:6a4db94011d3 | 950 | { |
sahilmgandhi | 18:6a4db94011d3 | 951 | return HAL_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 952 | } |
sahilmgandhi | 18:6a4db94011d3 | 953 | |
sahilmgandhi | 18:6a4db94011d3 | 954 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 955 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 956 | } |
sahilmgandhi | 18:6a4db94011d3 | 957 | |
sahilmgandhi | 18:6a4db94011d3 | 958 | /** |
sahilmgandhi | 18:6a4db94011d3 | 959 | * @brief Enters the Sleep (low power) mode. |
sahilmgandhi | 18:6a4db94011d3 | 960 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 961 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 962 | * @retval HAL status. |
sahilmgandhi | 18:6a4db94011d3 | 963 | */ |
sahilmgandhi | 18:6a4db94011d3 | 964 | HAL_StatusTypeDef HAL_CAN_Sleep(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 965 | { |
sahilmgandhi | 18:6a4db94011d3 | 966 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 967 | |
sahilmgandhi | 18:6a4db94011d3 | 968 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 969 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 970 | |
sahilmgandhi | 18:6a4db94011d3 | 971 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 972 | hcan->State = HAL_CAN_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 973 | |
sahilmgandhi | 18:6a4db94011d3 | 974 | /* Request Sleep mode */ |
sahilmgandhi | 18:6a4db94011d3 | 975 | hcan->Instance->MCR = (((hcan->Instance->MCR) & (uint32_t)(~(uint32_t)CAN_MCR_INRQ)) | CAN_MCR_SLEEP); |
sahilmgandhi | 18:6a4db94011d3 | 976 | |
sahilmgandhi | 18:6a4db94011d3 | 977 | /* Sleep mode status */ |
sahilmgandhi | 18:6a4db94011d3 | 978 | if ((hcan->Instance->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) != CAN_MSR_SLAK) |
sahilmgandhi | 18:6a4db94011d3 | 979 | { |
sahilmgandhi | 18:6a4db94011d3 | 980 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 981 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 982 | |
sahilmgandhi | 18:6a4db94011d3 | 983 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 984 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 985 | } |
sahilmgandhi | 18:6a4db94011d3 | 986 | |
sahilmgandhi | 18:6a4db94011d3 | 987 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 988 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 989 | |
sahilmgandhi | 18:6a4db94011d3 | 990 | /* Wait the acknowledge */ |
sahilmgandhi | 18:6a4db94011d3 | 991 | while((hcan->Instance->MSR & (CAN_MSR_SLAK|CAN_MSR_INAK)) != CAN_MSR_SLAK) |
sahilmgandhi | 18:6a4db94011d3 | 992 | { |
sahilmgandhi | 18:6a4db94011d3 | 993 | if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE) |
sahilmgandhi | 18:6a4db94011d3 | 994 | { |
sahilmgandhi | 18:6a4db94011d3 | 995 | hcan->State = HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 996 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 997 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 998 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 999 | } |
sahilmgandhi | 18:6a4db94011d3 | 1000 | } |
sahilmgandhi | 18:6a4db94011d3 | 1001 | |
sahilmgandhi | 18:6a4db94011d3 | 1002 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1003 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 1004 | |
sahilmgandhi | 18:6a4db94011d3 | 1005 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 1006 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1007 | |
sahilmgandhi | 18:6a4db94011d3 | 1008 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 1009 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 1010 | } |
sahilmgandhi | 18:6a4db94011d3 | 1011 | |
sahilmgandhi | 18:6a4db94011d3 | 1012 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1013 | * @brief Wakes up the CAN peripheral from sleep mode, after that the CAN peripheral |
sahilmgandhi | 18:6a4db94011d3 | 1014 | * is in the normal mode. |
sahilmgandhi | 18:6a4db94011d3 | 1015 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1016 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1017 | * @retval HAL status. |
sahilmgandhi | 18:6a4db94011d3 | 1018 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1019 | HAL_StatusTypeDef HAL_CAN_WakeUp(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1020 | { |
sahilmgandhi | 18:6a4db94011d3 | 1021 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 1022 | |
sahilmgandhi | 18:6a4db94011d3 | 1023 | /* Process locked */ |
sahilmgandhi | 18:6a4db94011d3 | 1024 | __HAL_LOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1025 | |
sahilmgandhi | 18:6a4db94011d3 | 1026 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1027 | hcan->State = HAL_CAN_STATE_BUSY; |
sahilmgandhi | 18:6a4db94011d3 | 1028 | |
sahilmgandhi | 18:6a4db94011d3 | 1029 | /* Wake up request */ |
sahilmgandhi | 18:6a4db94011d3 | 1030 | hcan->Instance->MCR &= ~(uint32_t)CAN_MCR_SLEEP; |
sahilmgandhi | 18:6a4db94011d3 | 1031 | |
sahilmgandhi | 18:6a4db94011d3 | 1032 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 1033 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 1034 | |
sahilmgandhi | 18:6a4db94011d3 | 1035 | /* Sleep mode status */ |
sahilmgandhi | 18:6a4db94011d3 | 1036 | while((hcan->Instance->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK) |
sahilmgandhi | 18:6a4db94011d3 | 1037 | { |
sahilmgandhi | 18:6a4db94011d3 | 1038 | if((HAL_GetTick() - tickstart) > CAN_TIMEOUT_VALUE) |
sahilmgandhi | 18:6a4db94011d3 | 1039 | { |
sahilmgandhi | 18:6a4db94011d3 | 1040 | hcan->State= HAL_CAN_STATE_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 1041 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 1042 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1043 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 1044 | } |
sahilmgandhi | 18:6a4db94011d3 | 1045 | } |
sahilmgandhi | 18:6a4db94011d3 | 1046 | if((hcan->Instance->MSR & CAN_MSR_SLAK) == CAN_MSR_SLAK) |
sahilmgandhi | 18:6a4db94011d3 | 1047 | { |
sahilmgandhi | 18:6a4db94011d3 | 1048 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 1049 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1050 | |
sahilmgandhi | 18:6a4db94011d3 | 1051 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 1052 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 1053 | } |
sahilmgandhi | 18:6a4db94011d3 | 1054 | |
sahilmgandhi | 18:6a4db94011d3 | 1055 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1056 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 1057 | |
sahilmgandhi | 18:6a4db94011d3 | 1058 | /* Process unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 1059 | __HAL_UNLOCK(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1060 | |
sahilmgandhi | 18:6a4db94011d3 | 1061 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 1062 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 1063 | } |
sahilmgandhi | 18:6a4db94011d3 | 1064 | |
sahilmgandhi | 18:6a4db94011d3 | 1065 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1066 | * @brief Handles CAN interrupt request |
sahilmgandhi | 18:6a4db94011d3 | 1067 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1068 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1069 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 1070 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1071 | void HAL_CAN_IRQHandler(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1072 | { |
sahilmgandhi | 18:6a4db94011d3 | 1073 | uint32_t tmp1 = 0U, tmp2 = 0U, tmp3 = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 1074 | |
sahilmgandhi | 18:6a4db94011d3 | 1075 | /* Check End of transmission flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1076 | if(__HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_TME)) |
sahilmgandhi | 18:6a4db94011d3 | 1077 | { |
sahilmgandhi | 18:6a4db94011d3 | 1078 | tmp1 = __HAL_CAN_TRANSMIT_STATUS(hcan, CAN_TXMAILBOX_0); |
sahilmgandhi | 18:6a4db94011d3 | 1079 | tmp2 = __HAL_CAN_TRANSMIT_STATUS(hcan, CAN_TXMAILBOX_1); |
sahilmgandhi | 18:6a4db94011d3 | 1080 | tmp3 = __HAL_CAN_TRANSMIT_STATUS(hcan, CAN_TXMAILBOX_2); |
sahilmgandhi | 18:6a4db94011d3 | 1081 | if(tmp1 || tmp2 || tmp3) |
sahilmgandhi | 18:6a4db94011d3 | 1082 | { |
sahilmgandhi | 18:6a4db94011d3 | 1083 | /* Call transmit function */ |
sahilmgandhi | 18:6a4db94011d3 | 1084 | CAN_Transmit_IT(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1085 | } |
sahilmgandhi | 18:6a4db94011d3 | 1086 | } |
sahilmgandhi | 18:6a4db94011d3 | 1087 | |
sahilmgandhi | 18:6a4db94011d3 | 1088 | tmp1 = __HAL_CAN_MSG_PENDING(hcan, CAN_FIFO0); |
sahilmgandhi | 18:6a4db94011d3 | 1089 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_FMP0); |
sahilmgandhi | 18:6a4db94011d3 | 1090 | /* Check End of reception flag for FIFO0 */ |
sahilmgandhi | 18:6a4db94011d3 | 1091 | if((tmp1 != 0U) && tmp2) |
sahilmgandhi | 18:6a4db94011d3 | 1092 | { |
sahilmgandhi | 18:6a4db94011d3 | 1093 | /* Call receive function */ |
sahilmgandhi | 18:6a4db94011d3 | 1094 | CAN_Receive_IT(hcan, CAN_FIFO0); |
sahilmgandhi | 18:6a4db94011d3 | 1095 | } |
sahilmgandhi | 18:6a4db94011d3 | 1096 | |
sahilmgandhi | 18:6a4db94011d3 | 1097 | tmp1 = __HAL_CAN_MSG_PENDING(hcan, CAN_FIFO1); |
sahilmgandhi | 18:6a4db94011d3 | 1098 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_FMP1); |
sahilmgandhi | 18:6a4db94011d3 | 1099 | /* Check End of reception flag for FIFO1 */ |
sahilmgandhi | 18:6a4db94011d3 | 1100 | if((tmp1 != 0U) && tmp2) |
sahilmgandhi | 18:6a4db94011d3 | 1101 | { |
sahilmgandhi | 18:6a4db94011d3 | 1102 | /* Call receive function */ |
sahilmgandhi | 18:6a4db94011d3 | 1103 | CAN_Receive_IT(hcan, CAN_FIFO1); |
sahilmgandhi | 18:6a4db94011d3 | 1104 | } |
sahilmgandhi | 18:6a4db94011d3 | 1105 | |
sahilmgandhi | 18:6a4db94011d3 | 1106 | tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 1107 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 1108 | tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1109 | /* Check Error Warning Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1110 | if(tmp1 && tmp2 && tmp3) |
sahilmgandhi | 18:6a4db94011d3 | 1111 | { |
sahilmgandhi | 18:6a4db94011d3 | 1112 | /* Set CAN error code to EWG error */ |
sahilmgandhi | 18:6a4db94011d3 | 1113 | hcan->ErrorCode |= HAL_CAN_ERROR_EWG; |
sahilmgandhi | 18:6a4db94011d3 | 1114 | } |
sahilmgandhi | 18:6a4db94011d3 | 1115 | |
sahilmgandhi | 18:6a4db94011d3 | 1116 | tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 1117 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 1118 | tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1119 | /* Check Error Passive Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1120 | if(tmp1 && tmp2 && tmp3) |
sahilmgandhi | 18:6a4db94011d3 | 1121 | { |
sahilmgandhi | 18:6a4db94011d3 | 1122 | /* Set CAN error code to EPV error */ |
sahilmgandhi | 18:6a4db94011d3 | 1123 | hcan->ErrorCode |= HAL_CAN_ERROR_EPV; |
sahilmgandhi | 18:6a4db94011d3 | 1124 | } |
sahilmgandhi | 18:6a4db94011d3 | 1125 | |
sahilmgandhi | 18:6a4db94011d3 | 1126 | tmp1 = __HAL_CAN_GET_FLAG(hcan, CAN_FLAG_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 1127 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 1128 | tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1129 | /* Check Bus-Off Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1130 | if(tmp1 && tmp2 && tmp3) |
sahilmgandhi | 18:6a4db94011d3 | 1131 | { |
sahilmgandhi | 18:6a4db94011d3 | 1132 | /* Set CAN error code to BOF error */ |
sahilmgandhi | 18:6a4db94011d3 | 1133 | hcan->ErrorCode |= HAL_CAN_ERROR_BOF; |
sahilmgandhi | 18:6a4db94011d3 | 1134 | } |
sahilmgandhi | 18:6a4db94011d3 | 1135 | |
sahilmgandhi | 18:6a4db94011d3 | 1136 | tmp1 = HAL_IS_BIT_CLR(hcan->Instance->ESR, CAN_ESR_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 1137 | tmp2 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 1138 | tmp3 = __HAL_CAN_GET_IT_SOURCE(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1139 | /* Check Last error code Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1140 | if((!tmp1) && tmp2 && tmp3) |
sahilmgandhi | 18:6a4db94011d3 | 1141 | { |
sahilmgandhi | 18:6a4db94011d3 | 1142 | tmp1 = (hcan->Instance->ESR) & CAN_ESR_LEC; |
sahilmgandhi | 18:6a4db94011d3 | 1143 | switch(tmp1) |
sahilmgandhi | 18:6a4db94011d3 | 1144 | { |
sahilmgandhi | 18:6a4db94011d3 | 1145 | case(CAN_ESR_LEC_0): |
sahilmgandhi | 18:6a4db94011d3 | 1146 | /* Set CAN error code to STF error */ |
sahilmgandhi | 18:6a4db94011d3 | 1147 | hcan->ErrorCode |= HAL_CAN_ERROR_STF; |
sahilmgandhi | 18:6a4db94011d3 | 1148 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1149 | case(CAN_ESR_LEC_1): |
sahilmgandhi | 18:6a4db94011d3 | 1150 | /* Set CAN error code to FOR error */ |
sahilmgandhi | 18:6a4db94011d3 | 1151 | hcan->ErrorCode |= HAL_CAN_ERROR_FOR; |
sahilmgandhi | 18:6a4db94011d3 | 1152 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1153 | case(CAN_ESR_LEC_1 | CAN_ESR_LEC_0): |
sahilmgandhi | 18:6a4db94011d3 | 1154 | /* Set CAN error code to ACK error */ |
sahilmgandhi | 18:6a4db94011d3 | 1155 | hcan->ErrorCode |= HAL_CAN_ERROR_ACK; |
sahilmgandhi | 18:6a4db94011d3 | 1156 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1157 | case(CAN_ESR_LEC_2): |
sahilmgandhi | 18:6a4db94011d3 | 1158 | /* Set CAN error code to BR error */ |
sahilmgandhi | 18:6a4db94011d3 | 1159 | hcan->ErrorCode |= HAL_CAN_ERROR_BR; |
sahilmgandhi | 18:6a4db94011d3 | 1160 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1161 | case(CAN_ESR_LEC_2 | CAN_ESR_LEC_0): |
sahilmgandhi | 18:6a4db94011d3 | 1162 | /* Set CAN error code to BD error */ |
sahilmgandhi | 18:6a4db94011d3 | 1163 | hcan->ErrorCode |= HAL_CAN_ERROR_BD; |
sahilmgandhi | 18:6a4db94011d3 | 1164 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1165 | case(CAN_ESR_LEC_2 | CAN_ESR_LEC_1): |
sahilmgandhi | 18:6a4db94011d3 | 1166 | /* Set CAN error code to CRC error */ |
sahilmgandhi | 18:6a4db94011d3 | 1167 | hcan->ErrorCode |= HAL_CAN_ERROR_CRC; |
sahilmgandhi | 18:6a4db94011d3 | 1168 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1169 | default: |
sahilmgandhi | 18:6a4db94011d3 | 1170 | break; |
sahilmgandhi | 18:6a4db94011d3 | 1171 | } |
sahilmgandhi | 18:6a4db94011d3 | 1172 | |
sahilmgandhi | 18:6a4db94011d3 | 1173 | /* Clear Last error code Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1174 | hcan->Instance->ESR &= ~(CAN_ESR_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 1175 | } |
sahilmgandhi | 18:6a4db94011d3 | 1176 | |
sahilmgandhi | 18:6a4db94011d3 | 1177 | /* Call the Error call Back in case of Errors */ |
sahilmgandhi | 18:6a4db94011d3 | 1178 | if(hcan->ErrorCode != HAL_CAN_ERROR_NONE) |
sahilmgandhi | 18:6a4db94011d3 | 1179 | { |
sahilmgandhi | 18:6a4db94011d3 | 1180 | /* Clear ERRI Flag */ |
sahilmgandhi | 18:6a4db94011d3 | 1181 | hcan->Instance->MSR = CAN_MSR_ERRI; |
sahilmgandhi | 18:6a4db94011d3 | 1182 | /* Set the CAN state ready to be able to start again the process */ |
sahilmgandhi | 18:6a4db94011d3 | 1183 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 1184 | /* Call Error callback function */ |
sahilmgandhi | 18:6a4db94011d3 | 1185 | HAL_CAN_ErrorCallback(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1186 | } |
sahilmgandhi | 18:6a4db94011d3 | 1187 | } |
sahilmgandhi | 18:6a4db94011d3 | 1188 | |
sahilmgandhi | 18:6a4db94011d3 | 1189 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1190 | * @brief Transmission complete callback in non blocking mode |
sahilmgandhi | 18:6a4db94011d3 | 1191 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1192 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1193 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 1194 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1195 | __weak void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1196 | { |
sahilmgandhi | 18:6a4db94011d3 | 1197 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 1198 | UNUSED(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1199 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 1200 | the HAL_CAN_TxCpltCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 1201 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1202 | } |
sahilmgandhi | 18:6a4db94011d3 | 1203 | |
sahilmgandhi | 18:6a4db94011d3 | 1204 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1205 | * @brief Transmission complete callback in non blocking mode |
sahilmgandhi | 18:6a4db94011d3 | 1206 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1207 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1208 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 1209 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1210 | __weak void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1211 | { |
sahilmgandhi | 18:6a4db94011d3 | 1212 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 1213 | UNUSED(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1214 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 1215 | the HAL_CAN_RxCpltCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 1216 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1217 | } |
sahilmgandhi | 18:6a4db94011d3 | 1218 | |
sahilmgandhi | 18:6a4db94011d3 | 1219 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1220 | * @brief Error CAN callback. |
sahilmgandhi | 18:6a4db94011d3 | 1221 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1222 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1223 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 1224 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1225 | __weak void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1226 | { |
sahilmgandhi | 18:6a4db94011d3 | 1227 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 1228 | UNUSED(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1229 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 1230 | the HAL_CAN_ErrorCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 1231 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1232 | } |
sahilmgandhi | 18:6a4db94011d3 | 1233 | |
sahilmgandhi | 18:6a4db94011d3 | 1234 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1235 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 1236 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1237 | |
sahilmgandhi | 18:6a4db94011d3 | 1238 | /** @defgroup CAN_Exported_Functions_Group3 Peripheral State and Error functions |
sahilmgandhi | 18:6a4db94011d3 | 1239 | * @brief CAN Peripheral State functions |
sahilmgandhi | 18:6a4db94011d3 | 1240 | * |
sahilmgandhi | 18:6a4db94011d3 | 1241 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 1242 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 1243 | ##### Peripheral State and Error functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 1244 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 1245 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 1246 | This subsection provides functions allowing to : |
sahilmgandhi | 18:6a4db94011d3 | 1247 | (+) Check the CAN state. |
sahilmgandhi | 18:6a4db94011d3 | 1248 | (+) Check CAN Errors detected during interrupt process |
sahilmgandhi | 18:6a4db94011d3 | 1249 | |
sahilmgandhi | 18:6a4db94011d3 | 1250 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 1251 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 1252 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1253 | |
sahilmgandhi | 18:6a4db94011d3 | 1254 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1255 | * @brief return the CAN state |
sahilmgandhi | 18:6a4db94011d3 | 1256 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1257 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1258 | * @retval HAL state |
sahilmgandhi | 18:6a4db94011d3 | 1259 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1260 | HAL_CAN_StateTypeDef HAL_CAN_GetState(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1261 | { |
sahilmgandhi | 18:6a4db94011d3 | 1262 | /* Return CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1263 | return hcan->State; |
sahilmgandhi | 18:6a4db94011d3 | 1264 | } |
sahilmgandhi | 18:6a4db94011d3 | 1265 | |
sahilmgandhi | 18:6a4db94011d3 | 1266 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1267 | * @brief Return the CAN error code |
sahilmgandhi | 18:6a4db94011d3 | 1268 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1269 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1270 | * @retval CAN Error Code |
sahilmgandhi | 18:6a4db94011d3 | 1271 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1272 | uint32_t HAL_CAN_GetError(CAN_HandleTypeDef *hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1273 | { |
sahilmgandhi | 18:6a4db94011d3 | 1274 | return hcan->ErrorCode; |
sahilmgandhi | 18:6a4db94011d3 | 1275 | } |
sahilmgandhi | 18:6a4db94011d3 | 1276 | |
sahilmgandhi | 18:6a4db94011d3 | 1277 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1278 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 1279 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1280 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1281 | * @brief Initiates and transmits a CAN frame message. |
sahilmgandhi | 18:6a4db94011d3 | 1282 | * @param hcan: pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1283 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1284 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 1285 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1286 | static HAL_StatusTypeDef CAN_Transmit_IT(CAN_HandleTypeDef* hcan) |
sahilmgandhi | 18:6a4db94011d3 | 1287 | { |
sahilmgandhi | 18:6a4db94011d3 | 1288 | /* Disable Transmit mailbox empty Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1289 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_TME); |
sahilmgandhi | 18:6a4db94011d3 | 1290 | |
sahilmgandhi | 18:6a4db94011d3 | 1291 | if(hcan->State == HAL_CAN_STATE_BUSY_TX) |
sahilmgandhi | 18:6a4db94011d3 | 1292 | { |
sahilmgandhi | 18:6a4db94011d3 | 1293 | /* Disable Error warning Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1294 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 1295 | |
sahilmgandhi | 18:6a4db94011d3 | 1296 | /* Disable Error passive Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1297 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 1298 | |
sahilmgandhi | 18:6a4db94011d3 | 1299 | /* Disable Bus-off Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1300 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 1301 | |
sahilmgandhi | 18:6a4db94011d3 | 1302 | /* Disable Last error code Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1303 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 1304 | |
sahilmgandhi | 18:6a4db94011d3 | 1305 | /* Disable Error Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1306 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1307 | } |
sahilmgandhi | 18:6a4db94011d3 | 1308 | |
sahilmgandhi | 18:6a4db94011d3 | 1309 | if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX) |
sahilmgandhi | 18:6a4db94011d3 | 1310 | { |
sahilmgandhi | 18:6a4db94011d3 | 1311 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1312 | hcan->State = HAL_CAN_STATE_BUSY_RX; |
sahilmgandhi | 18:6a4db94011d3 | 1313 | } |
sahilmgandhi | 18:6a4db94011d3 | 1314 | else |
sahilmgandhi | 18:6a4db94011d3 | 1315 | { |
sahilmgandhi | 18:6a4db94011d3 | 1316 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1317 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 1318 | } |
sahilmgandhi | 18:6a4db94011d3 | 1319 | |
sahilmgandhi | 18:6a4db94011d3 | 1320 | /* Transmission complete callback */ |
sahilmgandhi | 18:6a4db94011d3 | 1321 | HAL_CAN_TxCpltCallback(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1322 | |
sahilmgandhi | 18:6a4db94011d3 | 1323 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 1324 | } |
sahilmgandhi | 18:6a4db94011d3 | 1325 | |
sahilmgandhi | 18:6a4db94011d3 | 1326 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1327 | * @brief Receives a correct CAN frame. |
sahilmgandhi | 18:6a4db94011d3 | 1328 | * @param hcan: Pointer to a CAN_HandleTypeDef structure that contains |
sahilmgandhi | 18:6a4db94011d3 | 1329 | * the configuration information for the specified CAN. |
sahilmgandhi | 18:6a4db94011d3 | 1330 | * @param FIFONumber: Specify the FIFO number |
sahilmgandhi | 18:6a4db94011d3 | 1331 | * @retval HAL status |
sahilmgandhi | 18:6a4db94011d3 | 1332 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 1333 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1334 | static HAL_StatusTypeDef CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber) |
sahilmgandhi | 18:6a4db94011d3 | 1335 | { |
sahilmgandhi | 18:6a4db94011d3 | 1336 | /* Get the Id */ |
sahilmgandhi | 18:6a4db94011d3 | 1337 | hcan->pRxMsg->IDE = (uint8_t)0x04U & hcan->Instance->sFIFOMailBox[FIFONumber].RIR; |
sahilmgandhi | 18:6a4db94011d3 | 1338 | if (hcan->pRxMsg->IDE == CAN_ID_STD) |
sahilmgandhi | 18:6a4db94011d3 | 1339 | { |
sahilmgandhi | 18:6a4db94011d3 | 1340 | hcan->pRxMsg->StdId = (uint32_t)0x000007FFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 21U); |
sahilmgandhi | 18:6a4db94011d3 | 1341 | } |
sahilmgandhi | 18:6a4db94011d3 | 1342 | else |
sahilmgandhi | 18:6a4db94011d3 | 1343 | { |
sahilmgandhi | 18:6a4db94011d3 | 1344 | hcan->pRxMsg->ExtId = (uint32_t)0x1FFFFFFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RIR >> 3U); |
sahilmgandhi | 18:6a4db94011d3 | 1345 | } |
sahilmgandhi | 18:6a4db94011d3 | 1346 | |
sahilmgandhi | 18:6a4db94011d3 | 1347 | hcan->pRxMsg->RTR = (uint8_t)0x02U & hcan->Instance->sFIFOMailBox[FIFONumber].RIR; |
sahilmgandhi | 18:6a4db94011d3 | 1348 | /* Get the DLC */ |
sahilmgandhi | 18:6a4db94011d3 | 1349 | hcan->pRxMsg->DLC = (uint8_t)0x0FU & hcan->Instance->sFIFOMailBox[FIFONumber].RDTR; |
sahilmgandhi | 18:6a4db94011d3 | 1350 | /* Get the FMI */ |
sahilmgandhi | 18:6a4db94011d3 | 1351 | hcan->pRxMsg->FMI = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 1352 | /* Get the data field */ |
sahilmgandhi | 18:6a4db94011d3 | 1353 | hcan->pRxMsg->Data[0U] = (uint8_t)0xFFU & hcan->Instance->sFIFOMailBox[FIFONumber].RDLR; |
sahilmgandhi | 18:6a4db94011d3 | 1354 | hcan->pRxMsg->Data[1U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 1355 | hcan->pRxMsg->Data[2U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 16U); |
sahilmgandhi | 18:6a4db94011d3 | 1356 | hcan->pRxMsg->Data[3U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDLR >> 24U); |
sahilmgandhi | 18:6a4db94011d3 | 1357 | hcan->pRxMsg->Data[4U] = (uint8_t)0xFFU & hcan->Instance->sFIFOMailBox[FIFONumber].RDHR; |
sahilmgandhi | 18:6a4db94011d3 | 1358 | hcan->pRxMsg->Data[5U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 8U); |
sahilmgandhi | 18:6a4db94011d3 | 1359 | hcan->pRxMsg->Data[6U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 16U); |
sahilmgandhi | 18:6a4db94011d3 | 1360 | hcan->pRxMsg->Data[7U] = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDHR >> 24U); |
sahilmgandhi | 18:6a4db94011d3 | 1361 | /* Release the FIFO */ |
sahilmgandhi | 18:6a4db94011d3 | 1362 | /* Release FIFO0 */ |
sahilmgandhi | 18:6a4db94011d3 | 1363 | if (FIFONumber == CAN_FIFO0) |
sahilmgandhi | 18:6a4db94011d3 | 1364 | { |
sahilmgandhi | 18:6a4db94011d3 | 1365 | __HAL_CAN_FIFO_RELEASE(hcan, CAN_FIFO0); |
sahilmgandhi | 18:6a4db94011d3 | 1366 | |
sahilmgandhi | 18:6a4db94011d3 | 1367 | /* Disable FIFO 0 message pending Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1368 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_FMP0); |
sahilmgandhi | 18:6a4db94011d3 | 1369 | } |
sahilmgandhi | 18:6a4db94011d3 | 1370 | /* Release FIFO1 */ |
sahilmgandhi | 18:6a4db94011d3 | 1371 | else /* FIFONumber == CAN_FIFO1 */ |
sahilmgandhi | 18:6a4db94011d3 | 1372 | { |
sahilmgandhi | 18:6a4db94011d3 | 1373 | __HAL_CAN_FIFO_RELEASE(hcan, CAN_FIFO1); |
sahilmgandhi | 18:6a4db94011d3 | 1374 | |
sahilmgandhi | 18:6a4db94011d3 | 1375 | /* Disable FIFO 1 message pending Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1376 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_FMP1); |
sahilmgandhi | 18:6a4db94011d3 | 1377 | } |
sahilmgandhi | 18:6a4db94011d3 | 1378 | |
sahilmgandhi | 18:6a4db94011d3 | 1379 | if(hcan->State == HAL_CAN_STATE_BUSY_RX) |
sahilmgandhi | 18:6a4db94011d3 | 1380 | { |
sahilmgandhi | 18:6a4db94011d3 | 1381 | /* Disable Error warning Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1382 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_EWG); |
sahilmgandhi | 18:6a4db94011d3 | 1383 | |
sahilmgandhi | 18:6a4db94011d3 | 1384 | /* Disable Error passive Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1385 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_EPV); |
sahilmgandhi | 18:6a4db94011d3 | 1386 | |
sahilmgandhi | 18:6a4db94011d3 | 1387 | /* Disable Bus-off Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1388 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_BOF); |
sahilmgandhi | 18:6a4db94011d3 | 1389 | |
sahilmgandhi | 18:6a4db94011d3 | 1390 | /* Disable Last error code Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1391 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_LEC); |
sahilmgandhi | 18:6a4db94011d3 | 1392 | |
sahilmgandhi | 18:6a4db94011d3 | 1393 | /* Disable Error Interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 1394 | __HAL_CAN_DISABLE_IT(hcan, CAN_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 1395 | } |
sahilmgandhi | 18:6a4db94011d3 | 1396 | |
sahilmgandhi | 18:6a4db94011d3 | 1397 | if(hcan->State == HAL_CAN_STATE_BUSY_TX_RX) |
sahilmgandhi | 18:6a4db94011d3 | 1398 | { |
sahilmgandhi | 18:6a4db94011d3 | 1399 | /* Disable CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1400 | hcan->State = HAL_CAN_STATE_BUSY_TX; |
sahilmgandhi | 18:6a4db94011d3 | 1401 | } |
sahilmgandhi | 18:6a4db94011d3 | 1402 | else |
sahilmgandhi | 18:6a4db94011d3 | 1403 | { |
sahilmgandhi | 18:6a4db94011d3 | 1404 | /* Change CAN state */ |
sahilmgandhi | 18:6a4db94011d3 | 1405 | hcan->State = HAL_CAN_STATE_READY; |
sahilmgandhi | 18:6a4db94011d3 | 1406 | } |
sahilmgandhi | 18:6a4db94011d3 | 1407 | |
sahilmgandhi | 18:6a4db94011d3 | 1408 | /* Receive complete callback */ |
sahilmgandhi | 18:6a4db94011d3 | 1409 | HAL_CAN_RxCpltCallback(hcan); |
sahilmgandhi | 18:6a4db94011d3 | 1410 | |
sahilmgandhi | 18:6a4db94011d3 | 1411 | /* Return function status */ |
sahilmgandhi | 18:6a4db94011d3 | 1412 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 1413 | } |
sahilmgandhi | 18:6a4db94011d3 | 1414 | |
sahilmgandhi | 18:6a4db94011d3 | 1415 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1416 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 1417 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1418 | |
sahilmgandhi | 18:6a4db94011d3 | 1419 | #endif /* HAL_CAN_MODULE_ENABLED */ |
sahilmgandhi | 18:6a4db94011d3 | 1420 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1421 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 1422 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1423 | |
sahilmgandhi | 18:6a4db94011d3 | 1424 | /** |
sahilmgandhi | 18:6a4db94011d3 | 1425 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 1426 | */ |
sahilmgandhi | 18:6a4db94011d3 | 1427 | |
sahilmgandhi | 18:6a4db94011d3 | 1428 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |