STM32L443xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal_pssi.c 00004 * @author MCD Application Team 00005 * @brief PSSI HAL module driver. 00006 * This file provides firmware functions to manage the following 00007 * functionalities of the Parallel Synchronous Slave Interface (PSSI) peripheral: 00008 * + Initialization and de-initialization functions 00009 * + IO operation functions 00010 * + Peripheral State and Errors functions 00011 * 00012 ****************************************************************************** 00013 * @attention 00014 * 00015 * Copyright (c) 2019 STMicroelectronics. 00016 * All rights reserved. 00017 * 00018 * This software is licensed under terms that can be found in the LICENSE file 00019 * in the root directory of this software component. 00020 * If no LICENSE file comes with this software, it is provided AS-IS. 00021 * 00022 ****************************************************************************** 00023 @verbatim 00024 ============================================================================== 00025 ##### How to use this driver ##### 00026 ============================================================================== 00027 [..] 00028 The PSSI HAL driver can be used as follows: 00029 00030 (#) Declare a PSSI_HandleTypeDef handle structure, for example: 00031 PSSI_HandleTypeDef hpssi; 00032 00033 (#) Initialize the PSSI low level resources by implementing the @ref HAL_PSSI_MspInit() API: 00034 (##) Enable the PSSIx interface clock 00035 (##) PSSI pins configuration 00036 (+++) Enable the clock for the PSSI GPIOs 00037 (+++) Configure PSSI pins as alternate function open-drain 00038 (##) NVIC configuration if you need to use interrupt process 00039 (+++) Configure the PSSIx interrupt priority 00040 (+++) Enable the NVIC PSSI IRQ Channel 00041 (##) DMA Configuration if you need to use DMA process 00042 (+++) Declare DMA_HandleTypeDef handles structure for the transmit and receive 00043 (+++) Enable the DMAx interface clock 00044 (+++) Configure the DMA handle parameters 00045 (+++) Configure the DMA Tx and Rx 00046 (+++) Associate the initialized DMA handle to the hpssi DMA Tx and Rx handle 00047 (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on 00048 the DMA Tx and Rx 00049 00050 (#) Configure the Communication Bus Width, Control Signals, Input Polarity and Output Polarity 00051 in the hpssi Init structure. 00052 00053 (#) Initialize the PSSI registers by calling the @ref HAL_PSSI_Init(), configure also the low level Hardware 00054 (GPIO, CLOCK, NVIC...etc) by calling the customized @ref HAL_PSSI_MspInit(&hpssi) API. 00055 00056 00057 (#) For PSSI IO operations, two operation modes are available within this driver : 00058 00059 *** Polling mode IO operation *** 00060 ================================= 00061 [..] 00062 (+) Transmit an amount of data by byte in blocking mode using @ref HAL_PSSI_Transmit() 00063 (+) Receive an amount of data by byte in blocking mode using @ref HAL_PSSI_Receive() 00064 00065 *** DMA mode IO operation *** 00066 ============================== 00067 [..] 00068 (+) Transmit an amount of data in non-blocking mode (DMA) using 00069 @ref HAL_PSSI_Transmit_DMA() 00070 (+) At transmission end of transfer, @ref HAL_PSSI_TxCpltCallback() is executed and user can 00071 add his own code by customization of function pointer @ref HAL_PSSI_TxCpltCallback() 00072 (+) Receive an amount of data in non-blocking mode (DMA) using 00073 @ref HAL_PSSI_Receive_DMA() 00074 (+) At reception end of transfer, @ref HAL_PSSI_RxCpltCallback() is executed and user can 00075 add his own code by customization of function pointer @ref HAL_PSSI_RxCpltCallback() 00076 (+) In case of transfer Error, @ref HAL_PSSI_ErrorCallback() function is executed and user can 00077 add his own code by customization of function pointer @ref HAL_PSSI_ErrorCallback() 00078 (+) Abort a PSSI process communication with Interrupt using @ref HAL_PSSI_Abort_IT() 00079 (+) End of abort process, @ref HAL_PSSI_AbortCpltCallback() is executed and user can 00080 add his own code by customization of function pointer @ref HAL_PSSI_AbortCpltCallback() 00081 00082 *** PSSI HAL driver macros list *** 00083 ================================== 00084 [..] 00085 Below the list of most used macros in PSSI HAL driver. 00086 00087 (+) @ref HAL_PSSI_ENABLE : Enable the PSSI peripheral 00088 (+) @ref HAL_PSSI_DISABLE : Disable the PSSI peripheral 00089 (+) @ref HAL_PSSI_GET_FLAG : Check whether the specified PSSI flag is set or not 00090 (+) @ref HAL_PSSI_CLEAR_FLAG : Clear the specified PSSI pending flag 00091 (+) @ref HAL_PSSI_ENABLE_IT : Enable the specified PSSI interrupt 00092 (+) @ref HAL_PSSI_DISABLE_IT : Disable the specified PSSI interrupt 00093 00094 *** Callback registration *** 00095 ============================================= 00096 Use Functions @ref HAL_PSSI_RegisterCallback() or @ref HAL_PSSI_RegisterAddrCallback() 00097 to register an interrupt callback. 00098 00099 Function @ref HAL_PSSI_RegisterCallback() allows to register following callbacks: 00100 (+) TxCpltCallback : callback for transmission end of transfer. 00101 (+) RxCpltCallback : callback for reception end of transfer. 00102 (+) ErrorCallback : callback for error detection. 00103 (+) AbortCpltCallback : callback for abort completion process. 00104 (+) MspInitCallback : callback for Msp Init. 00105 (+) MspDeInitCallback : callback for Msp DeInit. 00106 This function takes as parameters the HAL peripheral handle, the Callback ID 00107 and a pointer to the user callback function. 00108 00109 00110 Use function @ref HAL_PSSI_UnRegisterCallback to reset a callback to the default 00111 weak function. 00112 @ref HAL_PSSI_UnRegisterCallback takes as parameters the HAL peripheral handle, 00113 and the Callback ID. 00114 This function allows to reset following callbacks: 00115 (+) TxCpltCallback : callback for transmission end of transfer. 00116 (+) RxCpltCallback : callback for reception end of transfer. 00117 (+) ErrorCallback : callback for error detection. 00118 (+) AbortCpltCallback : callback for abort completion process. 00119 (+) MspInitCallback : callback for Msp Init. 00120 (+) MspDeInitCallback : callback for Msp DeInit. 00121 00122 00123 By default, after the @ref HAL_PSSI_Init() and when the state is @ref HAL_PSSI_STATE_RESET 00124 all callbacks are set to the corresponding weak functions: 00125 examples @ref HAL_PSSI_TxCpltCallback(), @ref HAL_PSSI_RxCpltCallback(). 00126 Exception done for MspInit and MspDeInit functions that are 00127 reset to the legacy weak functions in the @ref HAL_PSSI_Init()/ @ref HAL_PSSI_DeInit() only when 00128 these callbacks are null (not registered beforehand). 00129 If MspInit or MspDeInit are not null, the @ref HAL_PSSI_Init()/ @ref HAL_PSSI_DeInit() 00130 keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state. 00131 00132 Callbacks can be registered/unregistered in @ref HAL_PSSI_STATE_READY state only. 00133 Exception for MspInit/MspDeInit functions that can be registered/unregistered 00134 in @ref HAL_PSSI_STATE_READY or @ref HAL_PSSI_STATE_RESET state, 00135 thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit. 00136 Then, the user first registers the MspInit/MspDeInit user callbacks 00137 using @ref HAL_PSSI_RegisterCallback() before calling @ref HAL_PSSI_DeInit() 00138 or @ref HAL_PSSI_Init() function. 00139 00140 00141 [..] 00142 (@) You can refer to the PSSI HAL driver header file for more useful macros 00143 00144 @endverbatim 00145 ****************************************************************************** 00146 */ 00147 00148 /* Includes ------------------------------------------------------------------*/ 00149 #include "stm32l4xx_hal.h" 00150 00151 /** @addtogroup STM32L4xx_HAL_Driver 00152 * @{ 00153 */ 00154 00155 #if defined(PSSI) 00156 00157 /** @addtogroup PSSI PSSI 00158 * @brief PSSI HAL module driver 00159 * @{ 00160 */ 00161 00162 #ifdef HAL_PSSI_MODULE_ENABLED 00163 00164 /* Private typedef -----------------------------------------------------------*/ 00165 /* Private define ------------------------------------------------------------*/ 00166 /* Private macro -------------------------------------------------------------*/ 00167 /* Private variables ---------------------------------------------------------*/ 00168 /* Private function prototypes -----------------------------------------------*/ 00169 00170 /** @defgroup PSSI_Private_Functions PSSI Private Functions 00171 * @{ 00172 */ 00173 /* Private functions to handle DMA transfer */ 00174 void PSSI_DMATransmitCplt(DMA_HandleTypeDef *hdma); 00175 void PSSI_DMAReceiveCplt(DMA_HandleTypeDef *hdma); 00176 void PSSI_DMAError(DMA_HandleTypeDef *hdma); 00177 void PSSI_DMAAbort(DMA_HandleTypeDef *hdma); 00178 00179 00180 /* Private functions to handle IT transfer */ 00181 static void PSSI_Error(PSSI_HandleTypeDef *hpssi, uint32_t ErrorCode); 00182 00183 00184 /* Private functions for PSSI transfer IRQ handler */ 00185 00186 00187 /* Private functions to handle flags during polling transfer */ 00188 static HAL_StatusTypeDef PSSI_WaitOnStatusUntilTimeout(PSSI_HandleTypeDef *hpssi, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart); 00189 00190 00191 /** 00192 * @} 00193 */ 00194 00195 /* Exported functions --------------------------------------------------------*/ 00196 00197 /** @addtogroup PSSI_Exported_Functions PSSI Exported Functions 00198 * @{ 00199 */ 00200 00201 /** @addtogroup PSSI_Exported_Functions_Group1 Initialization and de-initialization functions 00202 * @brief Initialization and Configuration functions 00203 * 00204 @verbatim 00205 =============================================================================== 00206 ##### Initialization and de-initialization functions ##### 00207 =============================================================================== 00208 [..] This subsection provides a set of functions allowing to initialize and 00209 de-initialize the PSSIx peripheral: 00210 00211 (+) User must implement HAL_PSSI_MspInit() function in which he configures 00212 all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). 00213 00214 (+) Call the function HAL_PSSI_Init() to configure the selected device with 00215 the selected configuration: 00216 (++) Data Width 00217 (++) Control Signals 00218 (++) Input Clock polarity 00219 (++) Output Clock polarity 00220 00221 (+) Call the function HAL_PSSI_DeInit() to restore the default configuration 00222 of the selected PSSIx peripheral. 00223 00224 @endverbatim 00225 * @{ 00226 */ 00227 00228 /** 00229 * @brief Initializes the PSSI according to the specified parameters 00230 * in the PSSI_InitTypeDef and initializes the associated handle. 00231 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00232 * the configuration information for the specified PSSI. 00233 * @retval HAL status 00234 */ 00235 HAL_StatusTypeDef HAL_PSSI_Init(PSSI_HandleTypeDef *hpssi) 00236 { 00237 /* Check the PSSI handle allocation */ 00238 if (hpssi == NULL) 00239 { 00240 return HAL_ERROR; 00241 } 00242 00243 /* Check the parameters */ 00244 assert_param(IS_PSSI_ALL_INSTANCE(hpssi->Instance)); 00245 assert_param(IS_PSSI_CONTROL_SIGNAL(hpssi->Init.ControlSignal)); 00246 assert_param(IS_PSSI_BUSWIDTH(hpssi->Init.BusWidth)); 00247 assert_param(IS_PSSI_CLOCK_POLARITY(hpssi->Init.ClockPolarity)); 00248 assert_param(IS_PSSI_DE_POLARITY(hpssi->Init.DataEnablePolarity)); 00249 assert_param(IS_PSSI_RDY_POLARITY(hpssi->Init.ReadyPolarity)); 00250 00251 if (hpssi->State == HAL_PSSI_STATE_RESET) 00252 { 00253 /* Allocate lock resource and initialize it */ 00254 hpssi->Lock = HAL_UNLOCKED; 00255 00256 /* Init the PSSI Callback settings */ 00257 hpssi->TxCpltCallback = HAL_PSSI_TxCpltCallback; /* Legacy weak TxCpltCallback */ 00258 hpssi->RxCpltCallback = HAL_PSSI_RxCpltCallback; /* Legacy weak RxCpltCallback */ 00259 hpssi->ErrorCallback = HAL_PSSI_ErrorCallback; /* Legacy weak ErrorCallback */ 00260 hpssi->AbortCpltCallback = HAL_PSSI_AbortCpltCallback; /* Legacy weak AbortCpltCallback */ 00261 00262 if (hpssi->MspInitCallback == NULL) 00263 { 00264 hpssi->MspInitCallback = HAL_PSSI_MspInit; /* Legacy weak MspInit */ 00265 } 00266 00267 /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */ 00268 hpssi->MspInitCallback(hpssi); 00269 00270 } 00271 00272 hpssi->State = HAL_PSSI_STATE_BUSY; 00273 00274 /* Disable the selected PSSI peripheral */ 00275 HAL_PSSI_DISABLE(hpssi); 00276 00277 /*---------------------------- PSSIx CR Configuration ----------------------*/ 00278 /* Configure PSSIx: Control Signal and Bus Width*/ 00279 00280 MODIFY_REG(hpssi->Instance->CR,PSSI_CR_DERDYCFG|PSSI_CR_EDM|PSSI_CR_DEPOL|PSSI_CR_RDYPOL, 00281 hpssi->Init.ControlSignal|hpssi->Init.DataEnablePolarity|hpssi->Init.ReadyPolarity|hpssi->Init.BusWidth); 00282 00283 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 00284 hpssi->State = HAL_PSSI_STATE_READY; 00285 00286 return HAL_OK; 00287 } 00288 00289 /** 00290 * @brief De-Initialize the PSSI peripheral. 00291 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00292 * the configuration information for the specified PSSI. 00293 * @retval HAL status 00294 */ 00295 HAL_StatusTypeDef HAL_PSSI_DeInit(PSSI_HandleTypeDef *hpssi) 00296 { 00297 /* Check the PSSI handle allocation */ 00298 if (hpssi == NULL) 00299 { 00300 return HAL_ERROR; 00301 } 00302 00303 /* Check the parameters */ 00304 assert_param(IS_PSSI_ALL_INSTANCE(hpssi->Instance)); 00305 00306 hpssi->State = HAL_PSSI_STATE_BUSY; 00307 00308 /* Disable the PSSI Peripheral Clock */ 00309 HAL_PSSI_DISABLE(hpssi); 00310 00311 if (hpssi->MspDeInitCallback == NULL) 00312 { 00313 hpssi->MspDeInitCallback = HAL_PSSI_MspDeInit; /* Legacy weak MspDeInit */ 00314 } 00315 00316 /* De-Init the low level hardware: GPIO, CLOCK, NVIC */ 00317 hpssi->MspDeInitCallback(hpssi); 00318 00319 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 00320 hpssi->State = HAL_PSSI_STATE_RESET; 00321 00322 /* Release Lock */ 00323 __HAL_UNLOCK(hpssi); 00324 00325 return HAL_OK; 00326 } 00327 00328 /** 00329 * @brief Initialize the PSSI MSP. 00330 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00331 * the configuration information for the specified PSSI. 00332 * @retval None 00333 */ 00334 __weak void HAL_PSSI_MspInit(PSSI_HandleTypeDef *hpssi) 00335 { 00336 /* Prevent unused argument(s) compilation warning */ 00337 UNUSED(hpssi); 00338 00339 /* NOTE : This function should not be modified; when the callback is needed, 00340 the HAL_PSSI_MspInit can be implemented in the user file 00341 */ 00342 } 00343 00344 /** 00345 * @brief De-Initialize the PSSI MSP. 00346 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00347 * the configuration information for the specified PSSI. 00348 * @retval None 00349 */ 00350 __weak void HAL_PSSI_MspDeInit(PSSI_HandleTypeDef *hpssi) 00351 { 00352 /* Prevent unused argument(s) compilation warning */ 00353 UNUSED(hpssi); 00354 00355 /* NOTE : This function should not be modified; when the callback is needed, 00356 the HAL_PSSI_MspDeInit can be implemented in the user file 00357 */ 00358 } 00359 00360 /** 00361 * @brief Register a User PSSI Callback 00362 * To be used instead of the weak predefined callback 00363 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00364 * the configuration information for the specified PSSI. 00365 * @param CallbackID ID of the callback to be registered 00366 * This parameter can be one of the following values: 00367 * @arg @ref HAL_PSSI_TX_COMPLETE_CB_ID Tx Transfer completed callback ID 00368 * @arg @ref HAL_PSSI_RX_COMPLETE_CB_ID Rx Transfer completed callback ID 00369 * @arg @ref HAL_PSSI_ERROR_CB_ID Error callback ID 00370 * @arg @ref HAL_PSSI_ABORT_CB_ID Abort callback ID 00371 * @arg @ref HAL_PSSI_MSPINIT_CB_ID MspInit callback ID 00372 * @arg @ref HAL_PSSI_MSPDEINIT_CB_ID MspDeInit callback ID 00373 * @param pCallback pointer to the Callback function 00374 * @retval HAL status 00375 */ 00376 HAL_StatusTypeDef HAL_PSSI_RegisterCallback(PSSI_HandleTypeDef *hpssi, HAL_PSSI_CallbackIDTypeDef CallbackID, pPSSI_CallbackTypeDef pCallback) 00377 { 00378 HAL_StatusTypeDef status = HAL_OK; 00379 00380 if (pCallback == NULL) 00381 { 00382 /* Update the error code */ 00383 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00384 00385 return HAL_ERROR; 00386 } 00387 /* Process locked */ 00388 __HAL_LOCK(hpssi); 00389 00390 if (HAL_PSSI_STATE_READY == hpssi->State) 00391 { 00392 switch (CallbackID) 00393 { 00394 case HAL_PSSI_TX_COMPLETE_CB_ID : 00395 hpssi->TxCpltCallback = pCallback; 00396 break; 00397 00398 case HAL_PSSI_RX_COMPLETE_CB_ID : 00399 hpssi->RxCpltCallback = pCallback; 00400 break; 00401 00402 case HAL_PSSI_ERROR_CB_ID : 00403 hpssi->ErrorCallback = pCallback; 00404 break; 00405 00406 case HAL_PSSI_ABORT_CB_ID : 00407 hpssi->AbortCpltCallback = pCallback; 00408 break; 00409 00410 case HAL_PSSI_MSPINIT_CB_ID : 00411 hpssi->MspInitCallback = pCallback; 00412 break; 00413 00414 case HAL_PSSI_MSPDEINIT_CB_ID : 00415 hpssi->MspDeInitCallback = pCallback; 00416 break; 00417 00418 default : 00419 /* Update the error code */ 00420 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00421 00422 /* Return error status */ 00423 status = HAL_ERROR; 00424 break; 00425 } 00426 } 00427 else if (HAL_PSSI_STATE_RESET == hpssi->State) 00428 { 00429 switch (CallbackID) 00430 { 00431 case HAL_PSSI_MSPINIT_CB_ID : 00432 hpssi->MspInitCallback = pCallback; 00433 break; 00434 00435 case HAL_PSSI_MSPDEINIT_CB_ID : 00436 hpssi->MspDeInitCallback = pCallback; 00437 break; 00438 00439 default : 00440 /* Update the error code */ 00441 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00442 00443 /* Return error status */ 00444 status = HAL_ERROR; 00445 break; 00446 } 00447 } 00448 else 00449 { 00450 /* Update the error code */ 00451 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00452 00453 /* Return error status */ 00454 status = HAL_ERROR; 00455 } 00456 00457 /* Release Lock */ 00458 __HAL_UNLOCK(hpssi); 00459 return status; 00460 } 00461 00462 /** 00463 * @brief Unregister a PSSI Callback 00464 * PSSI callback is redirected to the weak predefined callback 00465 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00466 * the configuration information for the specified PSSI. 00467 * @param CallbackID ID of the callback to be unregistered 00468 * This parameter can be one of the following values: 00469 * @arg @ref HAL_PSSI_TX_COMPLETE_CB_ID Tx Transfer completed callback ID 00470 * @arg @ref HAL_PSSI_RX_COMPLETE_CB_ID Rx Transfer completed callback ID 00471 * @arg @ref HAL_PSSI_ERROR_CB_ID Error callback ID 00472 * @arg @ref HAL_PSSI_ABORT_CB_ID Abort callback ID 00473 * @arg @ref HAL_PSSI_MSPINIT_CB_ID MspInit callback ID 00474 * @arg @ref HAL_PSSI_MSPDEINIT_CB_ID MspDeInit callback ID 00475 * @retval HAL status 00476 */ 00477 HAL_StatusTypeDef HAL_PSSI_UnRegisterCallback(PSSI_HandleTypeDef *hpssi, HAL_PSSI_CallbackIDTypeDef CallbackID) 00478 { 00479 HAL_StatusTypeDef status = HAL_OK; 00480 00481 /* Process locked */ 00482 __HAL_LOCK(hpssi); 00483 00484 if (HAL_PSSI_STATE_READY == hpssi->State) 00485 { 00486 switch (CallbackID) 00487 { 00488 case HAL_PSSI_TX_COMPLETE_CB_ID : 00489 hpssi->TxCpltCallback = HAL_PSSI_TxCpltCallback; /* Legacy weak TxCpltCallback */ 00490 break; 00491 00492 case HAL_PSSI_RX_COMPLETE_CB_ID : 00493 hpssi->RxCpltCallback = HAL_PSSI_RxCpltCallback; /* Legacy weak RxCpltCallback */ 00494 break; 00495 00496 case HAL_PSSI_ERROR_CB_ID : 00497 hpssi->ErrorCallback = HAL_PSSI_ErrorCallback; /* Legacy weak ErrorCallback */ 00498 break; 00499 00500 case HAL_PSSI_ABORT_CB_ID : 00501 hpssi->AbortCpltCallback = HAL_PSSI_AbortCpltCallback; /* Legacy weak AbortCpltCallback */ 00502 break; 00503 00504 case HAL_PSSI_MSPINIT_CB_ID : 00505 hpssi->MspInitCallback = HAL_PSSI_MspInit; /* Legacy weak MspInit */ 00506 break; 00507 00508 case HAL_PSSI_MSPDEINIT_CB_ID : 00509 hpssi->MspDeInitCallback = HAL_PSSI_MspDeInit; /* Legacy weak MspDeInit */ 00510 break; 00511 00512 default : 00513 /* Update the error code */ 00514 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00515 00516 /* Return error status */ 00517 status = HAL_ERROR; 00518 break; 00519 } 00520 } 00521 else if (HAL_PSSI_STATE_RESET == hpssi->State) 00522 { 00523 switch (CallbackID) 00524 { 00525 case HAL_PSSI_MSPINIT_CB_ID : 00526 hpssi->MspInitCallback = HAL_PSSI_MspInit; /* Legacy weak MspInit */ 00527 break; 00528 00529 case HAL_PSSI_MSPDEINIT_CB_ID : 00530 hpssi->MspDeInitCallback = HAL_PSSI_MspDeInit; /* Legacy weak MspDeInit */ 00531 break; 00532 00533 default : 00534 /* Update the error code */ 00535 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00536 00537 /* Return error status */ 00538 status = HAL_ERROR; 00539 break; 00540 } 00541 } 00542 else 00543 { 00544 /* Update the error code */ 00545 hpssi->ErrorCode |= HAL_PSSI_ERROR_INVALID_CALLBACK; 00546 00547 /* Return error status */ 00548 status = HAL_ERROR; 00549 } 00550 00551 /* Release Lock */ 00552 __HAL_UNLOCK(hpssi); 00553 return status; 00554 } 00555 00556 00557 /** 00558 * @} 00559 */ 00560 00561 /** @addtogroup PSSI_Exported_Functions_Group2 Input and Output operation functions 00562 * @brief Data transfers functions 00563 * 00564 @verbatim 00565 =============================================================================== 00566 ##### IO operation functions ##### 00567 =============================================================================== 00568 [..] 00569 This subsection provides a set of functions allowing to manage the PSSI data 00570 transfers. 00571 00572 (#) There are two modes of transfer: 00573 (++) Blocking mode : The communication is performed in the polling mode. 00574 The status of all data processing is returned by the same function 00575 after finishing transfer. 00576 (++) No-Blocking mode : The communication is performed using DMA. 00577 These functions return the status of the transfer startup. 00578 The end of the data processing will be indicated through the 00579 dedicated DMA IRQ . 00580 00581 (#) Blocking mode functions are : 00582 (++) HAL_PSSI_Transmit() 00583 (++) HAL_PSSI_Receive() 00584 00585 (#) No-Blocking mode functions with DMA are : 00586 (++) HAL_PSSI_Transmit_DMA() 00587 (++) HAL_PSSI_Receive_DMA() 00588 00589 (#) A set of callbacks are provided in non Blocking mode: 00590 (++) HAL_PSSI_TxCpltCallback() 00591 (++) HAL_PSSI_RxCpltCallback() 00592 (++) HAL_PSSI_ErrorCallback() 00593 (++) HAL_PSSI_AbortCpltCallback() 00594 00595 @endverbatim 00596 * @{ 00597 */ 00598 00599 /** 00600 * @brief Transmits in master mode an amount of data in blocking mode. 00601 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00602 * the configuration information for the specified PSSI. 00603 * @param pData Pointer to data buffer 00604 * @param Size Amount of data to be sent (in bytes) 00605 * @param Timeout Timeout duration 00606 * @retval HAL status 00607 */ 00608 HAL_StatusTypeDef HAL_PSSI_Transmit(PSSI_HandleTypeDef *hpssi, uint8_t *pData, uint32_t Size, uint32_t Timeout) 00609 { 00610 uint32_t tickstart; 00611 uint32_t transfer_size = Size; 00612 00613 if (((hpssi->Init.DataWidth == HAL_PSSI_8BITS) && (hpssi->Init.BusWidth != HAL_PSSI_8LINES)) || 00614 ((hpssi->Init.DataWidth == HAL_PSSI_16BITS) && ((Size%2U) != 0U)) || 00615 ((hpssi->Init.DataWidth == HAL_PSSI_32BITS) && ((Size%4U) != 0U))) 00616 { 00617 hpssi->ErrorCode = HAL_PSSI_ERROR_NOT_SUPPORTED; 00618 return HAL_ERROR; 00619 } 00620 if (hpssi->State == HAL_PSSI_STATE_READY) 00621 { 00622 /* Process Locked */ 00623 __HAL_LOCK(hpssi); 00624 00625 hpssi->State = HAL_PSSI_STATE_BUSY; 00626 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 00627 00628 /* Disable the selected PSSI peripheral */ 00629 HAL_PSSI_DISABLE(hpssi); 00630 00631 /* Configure transfer parameters */ 00632 hpssi->Instance->CR |= PSSI_CR_OUTEN_OUTPUT | 00633 ((hpssi->Init.ClockPolarity == HAL_PSSI_RISING_EDGE)?0U:PSSI_CR_CKPOL); 00634 /* DMA Disable */ 00635 hpssi->Instance->CR &= PSSI_CR_DMA_DISABLE; 00636 00637 /* Enable the selected PSSI peripheral */ 00638 HAL_PSSI_ENABLE(hpssi); 00639 00640 if (hpssi->Init.DataWidth == HAL_PSSI_8BITS) 00641 { 00642 uint8_t *pbuffer = pData; 00643 while (transfer_size > 0U) 00644 { 00645 /* Init tickstart for timeout management*/ 00646 tickstart = HAL_GetTick(); 00647 /* Wait until Fifo is ready (until one byte flag is set) to transfer */ 00648 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT1B, RESET, Timeout, tickstart) != HAL_OK) 00649 { 00650 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00651 hpssi->State = HAL_PSSI_STATE_READY; 00652 /* Process Unlocked */ 00653 __HAL_UNLOCK(hpssi); 00654 return HAL_ERROR; 00655 } 00656 /* Write data to DR */ 00657 *(__IO uint8_t *)(&hpssi->Instance->DR) = *(uint8_t *)pbuffer; 00658 00659 /* Increment Buffer pointer */ 00660 pbuffer++; 00661 00662 transfer_size--; 00663 } 00664 } 00665 else if (hpssi->Init.DataWidth == HAL_PSSI_16BITS) 00666 { 00667 uint8_t *pbuffer = pData; 00668 uint16_t data; 00669 while (transfer_size > 0U) 00670 { 00671 /* Init tickstart for timeout management*/ 00672 tickstart = HAL_GetTick(); 00673 /* Wait until Fifo is ready (until four bytes flag is set) to transfer */ 00674 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT4B, RESET, Timeout, tickstart) != HAL_OK) 00675 { 00676 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00677 hpssi->State = HAL_PSSI_STATE_READY; 00678 /* Process Unlocked */ 00679 __HAL_UNLOCK(hpssi); 00680 return HAL_ERROR; 00681 } 00682 /* Write data to DR */ 00683 data = (uint16_t)*pbuffer ; 00684 pbuffer++; 00685 data = (((uint16_t)*pbuffer) << 8U) | data; 00686 pbuffer++; 00687 *(__IO uint32_t *)((uint32_t)(&hpssi->Instance->DR)) = data; 00688 00689 /* Decrement Transfer Size */ 00690 transfer_size -= 2U; 00691 00692 } 00693 } 00694 else if (hpssi->Init.DataWidth == HAL_PSSI_32BITS) 00695 { 00696 uint8_t *pbuffer = pData; 00697 uint32_t data; 00698 while (transfer_size > 0U) 00699 { 00700 /* Init tickstart for timeout management*/ 00701 tickstart = HAL_GetTick(); 00702 /* Wait until Fifo is ready (until four bytes flag is set) to transfer */ 00703 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT4B, RESET, Timeout, tickstart) != HAL_OK) 00704 { 00705 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00706 hpssi->State = HAL_PSSI_STATE_READY; 00707 /* Process Unlocked */ 00708 __HAL_UNLOCK(hpssi); 00709 return HAL_ERROR; 00710 } 00711 /* Write data to DR */ 00712 data = (uint32_t)*pbuffer ; 00713 pbuffer++; 00714 data = (((uint32_t)*pbuffer) << 8U) | data; 00715 pbuffer++; 00716 data = (((uint32_t)*pbuffer) << 16U) | data; 00717 pbuffer++; 00718 data = (((uint32_t)*pbuffer) << 24U) | data; 00719 pbuffer++; 00720 *(__IO uint32_t *)(&hpssi->Instance->DR) = data; 00721 00722 /* Decrement Transfer Size */ 00723 transfer_size -= 4U; 00724 } 00725 00726 } 00727 else 00728 { 00729 hpssi->ErrorCode = HAL_PSSI_ERROR_NOT_SUPPORTED; 00730 hpssi->State = HAL_PSSI_STATE_READY; 00731 /* Process Unlocked */ 00732 __HAL_UNLOCK(hpssi); 00733 return HAL_ERROR; 00734 } 00735 00736 /* Check Errors Flags */ 00737 if (HAL_PSSI_GET_FLAG(hpssi, PSSI_FLAG_OVR_RIS) != 0U) 00738 { 00739 HAL_PSSI_CLEAR_FLAG(hpssi, PSSI_FLAG_OVR_RIS); 00740 HAL_PSSI_DISABLE(hpssi); 00741 hpssi->ErrorCode = HAL_PSSI_ERROR_UNDER_RUN; 00742 hpssi->State = HAL_PSSI_STATE_READY; 00743 /* Process Unlocked */ 00744 __HAL_UNLOCK(hpssi); 00745 return HAL_ERROR; 00746 } 00747 00748 hpssi->State = HAL_PSSI_STATE_READY; 00749 00750 /* Process Unlocked */ 00751 __HAL_UNLOCK(hpssi); 00752 00753 return HAL_OK; 00754 } 00755 else 00756 { 00757 return HAL_BUSY; 00758 } 00759 } 00760 00761 00762 /** 00763 * @brief Receives an amount of data in blocking mode. 00764 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00765 * the configuration information for the specified PSSI. 00766 * @param pData Pointer to data buffer 00767 * @param Size Amount of data to be received (in bytes) 00768 * @param Timeout Timeout duration 00769 * @retval HAL status 00770 */ 00771 HAL_StatusTypeDef HAL_PSSI_Receive(PSSI_HandleTypeDef *hpssi, uint8_t *pData, uint32_t Size, uint32_t Timeout) 00772 { 00773 uint32_t tickstart; 00774 uint32_t transfer_size = Size; 00775 00776 if (((hpssi->Init.DataWidth == HAL_PSSI_8BITS) && (hpssi->Init.BusWidth != HAL_PSSI_8LINES)) || 00777 ((hpssi->Init.DataWidth == HAL_PSSI_16BITS) && ((Size%2U) != 0U)) || 00778 ((hpssi->Init.DataWidth == HAL_PSSI_32BITS) && ((Size%4U) != 0U))) 00779 { 00780 hpssi->ErrorCode = HAL_PSSI_ERROR_NOT_SUPPORTED; 00781 return HAL_ERROR; 00782 } 00783 00784 if (hpssi->State == HAL_PSSI_STATE_READY) 00785 { 00786 /* Process Locked */ 00787 __HAL_LOCK(hpssi); 00788 00789 hpssi->State = HAL_PSSI_STATE_BUSY; 00790 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 00791 00792 /* Disable the selected PSSI peripheral */ 00793 HAL_PSSI_DISABLE(hpssi); 00794 /* Configure transfer parameters */ 00795 hpssi->Instance->CR |= PSSI_CR_OUTEN_INPUT |((hpssi->Init.ClockPolarity == HAL_PSSI_FALLING_EDGE)?0U:PSSI_CR_CKPOL); 00796 00797 00798 /* DMA Disable */ 00799 hpssi->Instance->CR &= PSSI_CR_DMA_DISABLE; 00800 00801 /* Enable the selected PSSI peripheral */ 00802 HAL_PSSI_ENABLE(hpssi); 00803 if (hpssi->Init.DataWidth == HAL_PSSI_8BITS) 00804 { 00805 uint8_t *pbuffer = pData; 00806 00807 while (transfer_size > 0U) 00808 { 00809 /* Init tickstart for timeout management*/ 00810 tickstart = HAL_GetTick(); 00811 /* Wait until Fifo is ready (until one byte flag is set) to receive */ 00812 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT1B, RESET, Timeout, tickstart) != HAL_OK) 00813 { 00814 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00815 hpssi->State = HAL_PSSI_STATE_READY; 00816 /* Process Unlocked */ 00817 __HAL_UNLOCK(hpssi); 00818 return HAL_ERROR; 00819 } 00820 /* Read data from DR */ 00821 *pbuffer = *(__IO uint8_t *)(&hpssi->Instance->DR); 00822 pbuffer++; 00823 transfer_size--; 00824 } 00825 } 00826 else if (hpssi->Init.DataWidth == HAL_PSSI_16BITS) 00827 { 00828 uint8_t *pbuffer = pData; 00829 uint16_t data; 00830 while (transfer_size > 0U) 00831 { 00832 /* Init tickstart for timeout management*/ 00833 tickstart = HAL_GetTick(); 00834 /* Wait until Fifo is ready (until four bytes flag is set) to receive */ 00835 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT4B, RESET, Timeout, tickstart) != HAL_OK) 00836 { 00837 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00838 hpssi->State = HAL_PSSI_STATE_READY; 00839 /* Process Unlocked */ 00840 __HAL_UNLOCK(hpssi); 00841 return HAL_ERROR; 00842 } 00843 00844 /* Read data from DR */ 00845 data = *(__IO uint32_t *)((uint32_t)&hpssi->Instance->DR); 00846 *pbuffer = (uint8_t)(data & 0x0FFU); 00847 pbuffer++; 00848 *pbuffer = (uint8_t)(data >> 8U); 00849 pbuffer++; 00850 transfer_size -= 2U; 00851 } 00852 } 00853 else if (hpssi->Init.DataWidth == HAL_PSSI_32BITS) 00854 { 00855 uint8_t *pbuffer = pData; 00856 uint32_t data; 00857 while (transfer_size > 0U) 00858 { 00859 /* Init tickstart for timeout management*/ 00860 tickstart = HAL_GetTick(); 00861 /* Wait until Fifo is ready (until four bytes flag is set) to receive */ 00862 if (PSSI_WaitOnStatusUntilTimeout(hpssi, PSSI_FLAG_RTT4B, RESET, Timeout, tickstart) != HAL_OK) 00863 { 00864 hpssi->ErrorCode = HAL_PSSI_ERROR_TIMEOUT; 00865 hpssi->State = HAL_PSSI_STATE_READY; 00866 /* Process Unlocked */ 00867 __HAL_UNLOCK(hpssi); 00868 return HAL_ERROR; 00869 } 00870 00871 /* Read data from DR */ 00872 data = *(__IO uint32_t *)(&hpssi->Instance->DR); 00873 *pbuffer = (uint8_t)(data & 0x0FFU); 00874 pbuffer++; 00875 *pbuffer = (uint8_t)((data & 0x0FF00U) >> 8U); 00876 pbuffer++; 00877 *pbuffer = (uint8_t)((data & 0x0FF0000U) >> 16U); 00878 pbuffer++; 00879 *pbuffer = (uint8_t)((data & 0xFF000000U) >> 24U); 00880 pbuffer++; 00881 transfer_size -= 4U; 00882 00883 } 00884 } 00885 else 00886 { 00887 hpssi->ErrorCode = HAL_PSSI_ERROR_NOT_SUPPORTED; 00888 hpssi->State = HAL_PSSI_STATE_READY; 00889 /* Process Unlocked */ 00890 __HAL_UNLOCK(hpssi); 00891 return HAL_ERROR; 00892 } 00893 /* Check Errors Flags */ 00894 00895 if (HAL_PSSI_GET_FLAG(hpssi, PSSI_FLAG_OVR_RIS) != 0U) 00896 { 00897 HAL_PSSI_CLEAR_FLAG(hpssi, PSSI_FLAG_OVR_RIS); 00898 hpssi->ErrorCode = HAL_PSSI_ERROR_OVER_RUN; 00899 __HAL_UNLOCK(hpssi); 00900 return HAL_ERROR; 00901 } 00902 00903 hpssi->State = HAL_PSSI_STATE_READY; 00904 00905 /* Process Unlocked */ 00906 __HAL_UNLOCK(hpssi); 00907 00908 return HAL_OK; 00909 } 00910 else 00911 { 00912 return HAL_BUSY; 00913 } 00914 } 00915 00916 /** 00917 * @brief Transmit an amount of data in non-blocking mode with DMA 00918 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 00919 * the configuration information for the specified PSSI. 00920 * @param pData Pointer to data buffer 00921 * @param Size Amount of data to be sent (in bytes) 00922 * @retval HAL status 00923 */ 00924 HAL_StatusTypeDef HAL_PSSI_Transmit_DMA(PSSI_HandleTypeDef *hpssi, uint32_t *pData, uint32_t Size) 00925 { 00926 HAL_StatusTypeDef dmaxferstatus; 00927 00928 if (hpssi->State == HAL_PSSI_STATE_READY) 00929 { 00930 00931 /* Process Locked */ 00932 __HAL_LOCK(hpssi); 00933 00934 hpssi->State = HAL_PSSI_STATE_BUSY_TX; 00935 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 00936 00937 /* Disable the selected PSSI peripheral */ 00938 HAL_PSSI_DISABLE(hpssi); 00939 00940 /* Prepare transfer parameters */ 00941 hpssi->pBuffPtr = pData; 00942 hpssi->XferCount = Size; 00943 00944 if (hpssi->XferCount > PSSI_MAX_NBYTE_SIZE) 00945 { 00946 hpssi->XferSize = PSSI_MAX_NBYTE_SIZE; 00947 } 00948 else 00949 { 00950 hpssi->XferSize = hpssi->XferCount; 00951 } 00952 00953 if (hpssi->XferSize > 0U) 00954 { 00955 if (hpssi->hdmatx != NULL) 00956 { 00957 00958 /* Configure BusWidth */ 00959 if( hpssi->hdmatx->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE) 00960 { 00961 MODIFY_REG(hpssi->Instance->CR,PSSI_CR_DMAEN|PSSI_CR_OUTEN|PSSI_CR_CKPOL,PSSI_CR_DMA_ENABLE | PSSI_CR_OUTEN_OUTPUT | 00962 ((hpssi->Init.ClockPolarity == HAL_PSSI_RISING_EDGE)?0U:PSSI_CR_CKPOL)); 00963 } 00964 else 00965 { 00966 MODIFY_REG(hpssi->Instance->CR,PSSI_CR_DMAEN|PSSI_CR_OUTEN|PSSI_CR_CKPOL,PSSI_CR_DMA_ENABLE | hpssi->Init.BusWidth | PSSI_CR_OUTEN_OUTPUT | 00967 ((hpssi->Init.ClockPolarity == HAL_PSSI_RISING_EDGE)?0U:PSSI_CR_CKPOL)); 00968 } 00969 00970 /* Set the PSSI DMA transfer complete callback */ 00971 hpssi->hdmatx->XferCpltCallback = PSSI_DMATransmitCplt; 00972 00973 /* Set the DMA error callback */ 00974 hpssi->hdmatx->XferErrorCallback = PSSI_DMAError; 00975 00976 /* Set the unused DMA callbacks to NULL */ 00977 hpssi->hdmatx->XferHalfCpltCallback = NULL; 00978 hpssi->hdmatx->XferAbortCallback = NULL; 00979 00980 /* Enable the DMA */ 00981 dmaxferstatus = HAL_DMA_Start_IT(hpssi->hdmatx, (uint32_t)pData, (uint32_t)&hpssi->Instance->DR, hpssi->XferSize); 00982 } 00983 else 00984 { 00985 /* Update PSSI state */ 00986 hpssi->State = HAL_PSSI_STATE_READY; 00987 00988 /* Update PSSI error code */ 00989 hpssi->ErrorCode |= HAL_PSSI_ERROR_DMA; 00990 00991 /* Process Unlocked */ 00992 __HAL_UNLOCK(hpssi); 00993 00994 return HAL_ERROR; 00995 } 00996 00997 if (dmaxferstatus == HAL_OK) 00998 { 00999 01000 01001 /* Update XferCount value */ 01002 hpssi->XferCount -= hpssi->XferSize; 01003 01004 /* Process Unlocked */ 01005 __HAL_UNLOCK(hpssi); 01006 01007 /* Note : The PSSI interrupts must be enabled after unlocking current process 01008 to avoid the risk of PSSI interrupt handle execution before current 01009 process unlock */ 01010 /* Enable ERR interrupt */ 01011 HAL_PSSI_ENABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01012 01013 /* Enable DMA Request */ 01014 hpssi->Instance->CR |= PSSI_CR_DMA_ENABLE; 01015 /* Enable the selected PSSI peripheral */ 01016 HAL_PSSI_ENABLE(hpssi); 01017 } 01018 else 01019 { 01020 /* Update PSSI state */ 01021 hpssi->State = HAL_PSSI_STATE_READY; 01022 01023 /* Update PSSI error code */ 01024 hpssi->ErrorCode |= HAL_PSSI_ERROR_DMA; 01025 01026 /* Process Unlocked */ 01027 __HAL_UNLOCK(hpssi); 01028 01029 return HAL_ERROR; 01030 } 01031 } 01032 else 01033 { 01034 /* Process Unlocked */ 01035 __HAL_UNLOCK(hpssi); 01036 01037 /* Note : The PSSI interrupts must be enabled after unlocking current process 01038 to avoid the risk of PSSI interrupt handle execution before current 01039 process unlock */ 01040 /* Enable ERRinterrupt */ 01041 /* possible to enable all of these */ 01042 01043 HAL_PSSI_ENABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01044 } 01045 01046 return HAL_OK; 01047 } 01048 else 01049 { 01050 return HAL_BUSY; 01051 } 01052 } 01053 01054 /** 01055 * @brief Receive an amount of data in non-blocking mode with DMA 01056 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01057 * the configuration information for the specified PSSI. 01058 * @param pData Pointer to data buffer 01059 * @param Size Amount of data to be received (in bytes) 01060 * @retval HAL status 01061 */ 01062 HAL_StatusTypeDef HAL_PSSI_Receive_DMA(PSSI_HandleTypeDef *hpssi, uint32_t *pData, uint32_t Size) 01063 { 01064 01065 HAL_StatusTypeDef dmaxferstatus; 01066 01067 if (hpssi->State == HAL_PSSI_STATE_READY) 01068 { 01069 01070 /* Disable the selected PSSI peripheral */ 01071 HAL_PSSI_DISABLE(hpssi); 01072 /* Process Locked */ 01073 __HAL_LOCK(hpssi); 01074 01075 hpssi->State = HAL_PSSI_STATE_BUSY_RX; 01076 hpssi->ErrorCode = HAL_PSSI_ERROR_NONE; 01077 01078 /* Prepare transfer parameters */ 01079 hpssi->pBuffPtr = pData; 01080 hpssi->XferCount = Size; 01081 01082 if (hpssi->XferCount > PSSI_MAX_NBYTE_SIZE) 01083 { 01084 hpssi->XferSize = PSSI_MAX_NBYTE_SIZE; 01085 } 01086 else 01087 { 01088 hpssi->XferSize = hpssi->XferCount; 01089 } 01090 01091 if (hpssi->XferSize > 0U) 01092 { 01093 if (hpssi->hdmarx != NULL) 01094 { 01095 01096 /* Configure BusWidth */ 01097 if( hpssi->hdmatx->Init.PeriphDataAlignment == DMA_PDATAALIGN_BYTE) 01098 { 01099 MODIFY_REG(hpssi->Instance->CR,PSSI_CR_DMAEN|PSSI_CR_OUTEN|PSSI_CR_CKPOL,PSSI_CR_DMA_ENABLE | 01100 ((hpssi->Init.ClockPolarity == HAL_PSSI_RISING_EDGE)?PSSI_CR_CKPOL:0U)); 01101 } 01102 else 01103 { 01104 MODIFY_REG(hpssi->Instance->CR,PSSI_CR_DMAEN|PSSI_CR_OUTEN|PSSI_CR_CKPOL,PSSI_CR_DMA_ENABLE | hpssi->Init.BusWidth | 01105 ((hpssi->Init.ClockPolarity == HAL_PSSI_RISING_EDGE)?PSSI_CR_CKPOL:0U)); 01106 } 01107 01108 /* Set the PSSI DMA transfer complete callback */ 01109 hpssi->hdmarx->XferCpltCallback = PSSI_DMAReceiveCplt; 01110 01111 /* Set the DMA error callback */ 01112 hpssi->hdmarx->XferErrorCallback = PSSI_DMAError; 01113 01114 /* Set the unused DMA callbacks to NULL */ 01115 hpssi->hdmarx->XferHalfCpltCallback = NULL; 01116 hpssi->hdmarx->XferAbortCallback = NULL; 01117 01118 /* Enable the DMA */ 01119 dmaxferstatus = HAL_DMA_Start_IT(hpssi->hdmarx, (uint32_t)&hpssi->Instance->DR, (uint32_t)pData, hpssi->XferSize); 01120 } 01121 else 01122 { 01123 /* Update PSSI state */ 01124 hpssi->State = HAL_PSSI_STATE_READY; 01125 01126 /* Update PSSI error code */ 01127 hpssi->ErrorCode |= HAL_PSSI_ERROR_DMA; 01128 01129 /* Process Unlocked */ 01130 __HAL_UNLOCK(hpssi); 01131 01132 return HAL_ERROR; 01133 } 01134 01135 if (dmaxferstatus == HAL_OK) 01136 { 01137 /* Update XferCount value */ 01138 hpssi->XferCount -= hpssi->XferSize; 01139 01140 /* Process Unlocked */ 01141 __HAL_UNLOCK(hpssi); 01142 01143 /* Note : The PSSI interrupts must be enabled after unlocking current process 01144 to avoid the risk of PSSI interrupt handle execution before current 01145 process unlock */ 01146 /* Enable ERR interrupt */ 01147 HAL_PSSI_ENABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01148 01149 /* Enable DMA Request */ 01150 hpssi->Instance->CR |= PSSI_CR_DMA_ENABLE; 01151 /* Enable the selected PSSI peripheral */ 01152 HAL_PSSI_ENABLE(hpssi); 01153 } 01154 else 01155 { 01156 /* Update PSSI state */ 01157 hpssi->State = HAL_PSSI_STATE_READY; 01158 01159 /* Update PSSI error code */ 01160 hpssi->ErrorCode |= HAL_PSSI_ERROR_DMA; 01161 01162 /* Process Unlocked */ 01163 __HAL_UNLOCK(hpssi); 01164 01165 return HAL_ERROR; 01166 } 01167 } 01168 else 01169 { 01170 01171 /* Process Unlocked */ 01172 __HAL_UNLOCK(hpssi); 01173 01174 /* Enable ERR,interrupt */ 01175 HAL_PSSI_ENABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01176 } 01177 01178 return HAL_OK; 01179 } 01180 else 01181 { 01182 return HAL_BUSY; 01183 } 01184 } 01185 01186 01187 01188 /** 01189 * @brief Abort a DMA process communication with Interrupt. 01190 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01191 * the configuration information for the specified PSSI. 01192 * @retval HAL status 01193 */ 01194 HAL_StatusTypeDef HAL_PSSI_Abort_DMA(PSSI_HandleTypeDef *hpssi) 01195 { 01196 01197 /* Process Locked */ 01198 __HAL_LOCK(hpssi); 01199 01200 /* Disable Interrupts */ 01201 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01202 01203 /* Set State at HAL_PSSI_STATE_ABORT */ 01204 hpssi->State = HAL_PSSI_STATE_ABORT; 01205 01206 /* Abort DMA TX transfer if any */ 01207 if ((hpssi->Instance->CR & PSSI_CR_DMAEN) == PSSI_CR_DMAEN) 01208 { 01209 if (hpssi->State == HAL_PSSI_STATE_BUSY_TX) 01210 { 01211 01212 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01213 01214 if (hpssi->hdmatx != NULL) 01215 { 01216 /* Set the PSSI DMA Abort callback : 01217 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01218 hpssi->hdmatx->XferAbortCallback = PSSI_DMAAbort; 01219 01220 /* Abort DMA TX */ 01221 if (HAL_DMA_Abort_IT(hpssi->hdmatx) != HAL_OK) 01222 { 01223 /* Call Directly XferAbortCallback function in case of error */ 01224 hpssi->hdmatx->XferAbortCallback(hpssi->hdmatx); 01225 } 01226 } 01227 01228 } 01229 /* Abort DMA RX transfer if any */ 01230 else if (hpssi->State == HAL_PSSI_STATE_BUSY_RX) 01231 { 01232 01233 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01234 01235 if (hpssi->hdmarx != NULL) 01236 { 01237 /* Set the PSSI DMA Abort callback : 01238 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01239 hpssi->hdmarx->XferAbortCallback = PSSI_DMAAbort; 01240 01241 /* Abort DMA RX */ 01242 if (HAL_DMA_Abort_IT(hpssi->hdmarx) != HAL_OK) 01243 { 01244 /* Call Directly hpssi->hdma->XferAbortCallback function in case of error */ 01245 hpssi->hdmarx->XferAbortCallback(hpssi->hdmarx); 01246 } 01247 } 01248 } 01249 else 01250 { 01251 /* Call the error callback */ 01252 hpssi->ErrorCallback(hpssi); 01253 } 01254 } 01255 01256 01257 /* Process Unlocked */ 01258 __HAL_UNLOCK(hpssi); 01259 01260 /* Note : The PSSI interrupts must be enabled after unlocking current process 01261 to avoid the risk of PSSI interrupt handle execution before current 01262 process unlock */ 01263 HAL_PSSI_ENABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01264 01265 return HAL_OK; 01266 01267 } 01268 01269 /** 01270 * @} 01271 */ 01272 01273 /** @addtogroup PSSI_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks 01274 * @{ 01275 */ 01276 01277 /** 01278 * @brief This function handles PSSI event interrupt request. 01279 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01280 * the configuration information for the specified PSSI. 01281 * @retval None 01282 */ 01283 void HAL_PSSI_IRQHandler(PSSI_HandleTypeDef *hpssi) 01284 { 01285 /* Overrun/ Underrun Errors */ 01286 if (HAL_PSSI_GET_FLAG(hpssi, PSSI_FLAG_OVR_MIS) != 0U) 01287 { 01288 /* Reset handle parameters */ 01289 01290 hpssi->XferCount = 0U; 01291 01292 /* Disable all interrupts */ 01293 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01294 01295 01296 /* Abort DMA TX transfer if any */ 01297 if ((hpssi->Instance->CR & PSSI_CR_DMAEN) == PSSI_CR_DMAEN) 01298 { 01299 if (hpssi->State == HAL_PSSI_STATE_BUSY_TX) 01300 { 01301 /* Set new error code */ 01302 hpssi->ErrorCode |= HAL_PSSI_ERROR_UNDER_RUN; 01303 01304 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01305 01306 if (hpssi->hdmatx != NULL) 01307 { 01308 /* Set the PSSI DMA Abort callback : 01309 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01310 hpssi->hdmatx->XferAbortCallback = PSSI_DMAAbort; 01311 01312 /* Process Unlocked */ 01313 __HAL_UNLOCK(hpssi); 01314 01315 /* Abort DMA TX */ 01316 if (HAL_DMA_Abort_IT(hpssi->hdmatx) != HAL_OK) 01317 { 01318 /* Call Directly XferAbortCallback function in case of error */ 01319 hpssi->hdmatx->XferAbortCallback(hpssi->hdmatx); 01320 } 01321 } 01322 01323 } 01324 /* Abort DMA RX transfer if any */ 01325 else if (hpssi->State == HAL_PSSI_STATE_BUSY_RX) 01326 { 01327 /* Set new error code */ 01328 hpssi->ErrorCode |= HAL_PSSI_ERROR_OVER_RUN; 01329 01330 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01331 01332 if (hpssi->hdmarx != NULL) 01333 { 01334 /* Set the PSSI DMA Abort callback : 01335 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01336 hpssi->hdmarx->XferAbortCallback = PSSI_DMAAbort; 01337 01338 /* Process Unlocked */ 01339 __HAL_UNLOCK(hpssi); 01340 01341 /* Abort DMA RX */ 01342 if (HAL_DMA_Abort_IT(hpssi->hdmarx) != HAL_OK) 01343 { 01344 /* Call Directly hpssi->hdma->XferAbortCallback function in case of error */ 01345 hpssi->hdmarx->XferAbortCallback(hpssi->hdmarx); 01346 } 01347 } 01348 } 01349 else 01350 { 01351 /* Call the corresponding callback to inform upper layer of the error */ 01352 hpssi->ErrorCallback(hpssi); 01353 } 01354 } 01355 01356 /* If state is an abort treatment on going, don't change state */ 01357 if (hpssi->State == HAL_PSSI_STATE_ABORT) 01358 { 01359 /* Process Unlocked */ 01360 __HAL_UNLOCK(hpssi); 01361 } 01362 else 01363 { 01364 /* Set HAL_PSSI_STATE_READY */ 01365 hpssi->State = HAL_PSSI_STATE_READY; 01366 /* Process Unlocked */ 01367 __HAL_UNLOCK(hpssi); 01368 01369 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01370 hpssi->ErrorCallback(hpssi); 01371 01372 } 01373 01374 } 01375 } 01376 01377 01378 /** 01379 * @brief Tx Transfer complete callback. 01380 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01381 * the configuration information for the specified PSSI. 01382 * @retval None 01383 */ 01384 __weak void HAL_PSSI_TxCpltCallback(PSSI_HandleTypeDef *hpssi) 01385 { 01386 /* Prevent unused argument(s) compilation warning */ 01387 UNUSED(hpssi); 01388 01389 /* NOTE : This function should not be modified; when the callback is needed, 01390 the HAL_PSSI_TxCpltCallback can be implemented in the user file 01391 */ 01392 } 01393 01394 /** 01395 * @brief Rx Transfer complete callback. 01396 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01397 * the configuration information for the specified PSSI. 01398 * @retval None 01399 */ 01400 __weak void HAL_PSSI_RxCpltCallback(PSSI_HandleTypeDef *hpssi) 01401 { 01402 /* Prevent unused argument(s) compilation warning */ 01403 UNUSED(hpssi); 01404 01405 /* NOTE : This function should not be modified; when the callback is needed, 01406 the HAL_PSSI_RxCpltCallback can be implemented in the user file 01407 */ 01408 } 01409 01410 01411 /** 01412 * @brief PSSI error callback. 01413 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01414 * the configuration information for the specified PSSI. 01415 * @retval None 01416 */ 01417 __weak void HAL_PSSI_ErrorCallback(PSSI_HandleTypeDef *hpssi) 01418 { 01419 /* Prevent unused argument(s) compilation warning */ 01420 UNUSED(hpssi); 01421 01422 /* NOTE : This function should not be modified; when the callback is needed, 01423 the HAL_PSSI_ErrorCallback can be implemented in the user file 01424 */ 01425 } 01426 01427 /** 01428 * @brief PSSI abort callback. 01429 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01430 * the configuration information for the specified PSSI. 01431 * @retval None 01432 */ 01433 __weak void HAL_PSSI_AbortCpltCallback(PSSI_HandleTypeDef *hpssi) 01434 { 01435 /* Prevent unused argument(s) compilation warning */ 01436 UNUSED(hpssi); 01437 01438 /* NOTE : This function should not be modified; when the callback is needed, 01439 the HAL_PSSI_AbortCpltCallback can be implemented in the user file 01440 */ 01441 } 01442 01443 /** 01444 * @} 01445 */ 01446 01447 /** @addtogroup PSSI_Exported_Functions_Group3 Peripheral State, Mode and Error functions 01448 * @brief Peripheral State, Mode and Error functions 01449 * 01450 @verbatim 01451 =============================================================================== 01452 ##### Peripheral State, Mode and Error functions ##### 01453 =============================================================================== 01454 [..] 01455 This subsection permit to get in run-time the status of the peripheral 01456 and the data flow. 01457 01458 @endverbatim 01459 * @{ 01460 */ 01461 01462 /** 01463 * @brief Return the PSSI handle state. 01464 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01465 * the configuration information for the specified PSSI. 01466 * @retval HAL state 01467 */ 01468 HAL_PSSI_StateTypeDef HAL_PSSI_GetState(PSSI_HandleTypeDef *hpssi) 01469 { 01470 /* Return PSSI handle state */ 01471 return hpssi->State; 01472 } 01473 01474 01475 /** 01476 * @brief Return the PSSI error code. 01477 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01478 * the configuration information for the specified PSSI. 01479 * @retval PSSI Error Code 01480 */ 01481 uint32_t HAL_PSSI_GetError(PSSI_HandleTypeDef *hpssi) 01482 { 01483 return hpssi->ErrorCode; 01484 } 01485 01486 /** 01487 * @} 01488 */ 01489 01490 /** 01491 * @} 01492 */ 01493 01494 /** @addtogroup PSSI_Private_Functions 01495 * @{ 01496 */ 01497 01498 /** 01499 * @brief PSSI Errors process. 01500 * @param hpssi PSSI handle. 01501 * @param ErrorCode Error code to handle. 01502 * @retval None 01503 */ 01504 static void PSSI_Error(PSSI_HandleTypeDef *hpssi, uint32_t ErrorCode) 01505 { 01506 01507 /* Reset handle parameters */ 01508 01509 hpssi->XferCount = 0U; 01510 01511 /* Set new error code */ 01512 hpssi->ErrorCode |= ErrorCode; 01513 01514 /* Disable all interrupts */ 01515 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01516 01517 01518 /* Abort DMA TX transfer if any */ 01519 if ((hpssi->Instance->CR & PSSI_CR_DMAEN) == PSSI_CR_DMAEN) 01520 { 01521 if (hpssi->State == HAL_PSSI_STATE_BUSY_TX) 01522 { 01523 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01524 01525 if (hpssi->hdmatx != NULL) 01526 { 01527 /* Set the PSSI DMA Abort callback : 01528 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01529 hpssi->hdmatx->XferAbortCallback = PSSI_DMAAbort; 01530 01531 /* Process Unlocked */ 01532 __HAL_UNLOCK(hpssi); 01533 01534 /* Abort DMA TX */ 01535 if (HAL_DMA_Abort_IT(hpssi->hdmatx) != HAL_OK) 01536 { 01537 /* Call Directly XferAbortCallback function in case of error */ 01538 hpssi->hdmatx->XferAbortCallback(hpssi->hdmatx); 01539 } 01540 } 01541 01542 } 01543 /* Abort DMA RX transfer if any */ 01544 else if (hpssi->State == HAL_PSSI_STATE_BUSY_RX) 01545 { 01546 hpssi->Instance->CR &= ~PSSI_CR_DMAEN; 01547 01548 if (hpssi->hdmarx != NULL) 01549 { 01550 /* Set the PSSI DMA Abort callback : 01551 will lead to call HAL_PSSI_ErrorCallback() at end of DMA abort procedure */ 01552 hpssi->hdmarx->XferAbortCallback = PSSI_DMAAbort; 01553 01554 /* Process Unlocked */ 01555 __HAL_UNLOCK(hpssi); 01556 01557 /* Abort DMA RX */ 01558 if (HAL_DMA_Abort_IT(hpssi->hdmarx) != HAL_OK) 01559 { 01560 /* Call Directly hpssi->hdma->XferAbortCallback function in case of error */ 01561 hpssi->hdmarx->XferAbortCallback(hpssi->hdmarx); 01562 } 01563 } 01564 } 01565 else 01566 { 01567 /*Nothing to do*/ 01568 } 01569 } 01570 01571 /* If state is an abort treatment on going, don't change state */ 01572 if (hpssi->State == HAL_PSSI_STATE_ABORT) 01573 { 01574 /* Process Unlocked */ 01575 __HAL_UNLOCK(hpssi); 01576 } 01577 else 01578 { 01579 /* Set HAL_PSSI_STATE_READY */ 01580 hpssi->State = HAL_PSSI_STATE_READY; 01581 01582 /* Process Unlocked */ 01583 __HAL_UNLOCK(hpssi); 01584 01585 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01586 hpssi->ErrorCallback(hpssi); 01587 01588 } 01589 } 01590 01591 /** 01592 * @brief DMA PSSI slave transmit process complete callback. 01593 * @param hdma DMA handle 01594 * @retval None 01595 */ 01596 void PSSI_DMATransmitCplt(DMA_HandleTypeDef *hdma) 01597 { 01598 PSSI_HandleTypeDef *hpssi = (PSSI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ 01599 01600 uint32_t tmperror; 01601 01602 01603 /* Disable Interrupts */ 01604 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01605 01606 /* Store current volatile hpssi->ErrorCode, misra rule */ 01607 tmperror = hpssi->ErrorCode; 01608 01609 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01610 if ((hpssi->State == HAL_PSSI_STATE_ABORT) || (tmperror != HAL_PSSI_ERROR_NONE)) 01611 { 01612 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01613 PSSI_Error(hpssi, hpssi->ErrorCode); 01614 } 01615 /* hpssi->State == HAL_PSSI_STATE_BUSY_TX */ 01616 else 01617 { 01618 hpssi->State = HAL_PSSI_STATE_READY; 01619 01620 /* Process Unlocked */ 01621 __HAL_UNLOCK(hpssi); 01622 01623 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01624 01625 hpssi->TxCpltCallback(hpssi); 01626 01627 } 01628 01629 01630 } 01631 01632 /** 01633 * @brief DMA PSSI master receive process complete callback. 01634 * @param hdma DMA handle 01635 * @retval None 01636 */ 01637 void PSSI_DMAReceiveCplt(DMA_HandleTypeDef *hdma) 01638 { 01639 PSSI_HandleTypeDef *hpssi = (PSSI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ 01640 01641 uint32_t tmperror; 01642 01643 01644 /* Disable Interrupts */ 01645 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01646 01647 /* Store current volatile hpssi->ErrorCode, misra rule */ 01648 tmperror = hpssi->ErrorCode; 01649 01650 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01651 if ((hpssi->State == HAL_PSSI_STATE_ABORT) || (tmperror != HAL_PSSI_ERROR_NONE)) 01652 { 01653 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01654 PSSI_Error(hpssi, hpssi->ErrorCode); 01655 } 01656 /* hpssi->State == HAL_PSSI_STATE_BUSY_RX */ 01657 else 01658 { 01659 hpssi->State = HAL_PSSI_STATE_READY; 01660 01661 /* Process Unlocked */ 01662 __HAL_UNLOCK(hpssi); 01663 01664 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01665 hpssi->RxCpltCallback(hpssi); 01666 01667 } 01668 01669 01670 } 01671 01672 /** 01673 * @brief DMA PSSI communication abort callback 01674 * (To be called at end of DMA Abort procedure). 01675 * @param hdma DMA handle. 01676 * @retval None 01677 */ 01678 void PSSI_DMAAbort(DMA_HandleTypeDef *hdma) 01679 { 01680 PSSI_HandleTypeDef *hpssi = (PSSI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ 01681 01682 /* Reset AbortCpltCallback */ 01683 hpssi->hdmatx->XferAbortCallback = NULL; 01684 hpssi->hdmarx->XferAbortCallback = NULL; 01685 01686 /* Check if come from abort from user */ 01687 if (hpssi->State == HAL_PSSI_STATE_ABORT) 01688 { 01689 hpssi->State = HAL_PSSI_STATE_READY; 01690 01691 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01692 01693 hpssi->AbortCpltCallback(hpssi); 01694 01695 } 01696 else 01697 { 01698 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01699 hpssi->ErrorCallback(hpssi); 01700 } 01701 } 01702 01703 /** 01704 * @brief This function handles PSSI Communication Timeout. 01705 * @param hpssi Pointer to a PSSI_HandleTypeDef structure that contains 01706 * the configuration information for the specified PSSI. 01707 * @param Flag Specifies the PSSI flag to check. 01708 * @param Status The new Flag status (SET or RESET). 01709 * @param Timeout Timeout duration 01710 * @param Tickstart Tick start value 01711 * @retval HAL status 01712 */ 01713 static HAL_StatusTypeDef PSSI_WaitOnStatusUntilTimeout(PSSI_HandleTypeDef *hpssi, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart) 01714 { 01715 while ((HAL_PSSI_GET_STATUS(hpssi, Flag) & Flag) == (uint32_t)Status) 01716 { 01717 /* Check for the Timeout */ 01718 if (Timeout != HAL_MAX_DELAY) 01719 { 01720 if (((HAL_GetTick() - Tickstart) > Timeout) || (Timeout == 0U)) 01721 { 01722 hpssi->ErrorCode |= HAL_PSSI_ERROR_TIMEOUT; 01723 hpssi->State = HAL_PSSI_STATE_READY; 01724 01725 /* Process Unlocked */ 01726 __HAL_UNLOCK(hpssi); 01727 01728 return HAL_ERROR; 01729 } 01730 } 01731 } 01732 return HAL_OK; 01733 } 01734 01735 /** 01736 * @brief DMA PSSI communication error callback 01737 * @param hdma DMA handle. 01738 * @retval None 01739 */ 01740 void PSSI_DMAError(DMA_HandleTypeDef *hdma) 01741 { 01742 PSSI_HandleTypeDef *hpssi = (PSSI_HandleTypeDef *)(((DMA_HandleTypeDef *)hdma)->Parent); /* Derogation MISRAC2012-Rule-11.5 */ 01743 01744 uint32_t tmperror; 01745 01746 01747 /* Disable the selected PSSI peripheral */ 01748 HAL_PSSI_DISABLE(hpssi); 01749 01750 /* Disable Interrupts */ 01751 HAL_PSSI_DISABLE_IT(hpssi, PSSI_FLAG_OVR_RIS); 01752 01753 /* Store current volatile hpssi->ErrorCode, misra rule */ 01754 tmperror = hpssi->ErrorCode; 01755 01756 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01757 if ((hpssi->State == HAL_PSSI_STATE_ABORT) || (tmperror != HAL_PSSI_ERROR_NONE)) 01758 { 01759 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01760 PSSI_Error(hpssi, hpssi->ErrorCode); 01761 } 01762 else 01763 { 01764 hpssi->State = HAL_PSSI_STATE_READY; 01765 01766 /* Process Unlocked */ 01767 __HAL_UNLOCK(hpssi); 01768 01769 /* Call the corresponding callback to inform upper layer of End of Transfer */ 01770 hpssi->ErrorCallback(hpssi); 01771 01772 } 01773 01774 } 01775 01776 01777 01778 /** 01779 * @} 01780 */ 01781 01782 #endif /* HAL_PSSI_MODULE_ENABLED */ 01783 /** 01784 * @} 01785 */ 01786 01787 #endif /* PSSI */ 01788 01789 /** 01790 * @} 01791 */