STM32L4xx_HAL_Driver  1.14.0
Initialization/de-initialization functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_OSPI_Init (OSPI_HandleTypeDef *hospi)
 Initialize the OSPI mode according to the specified parameters in the OSPI_InitTypeDef and initialize the associated handle. More...
 
void HAL_OSPI_MspInit (OSPI_HandleTypeDef *hospi)
 Initialize the OSPI MSP. More...
 
HAL_StatusTypeDef HAL_OSPI_DeInit (OSPI_HandleTypeDef *hospi)
 De-Initialize the OSPI peripheral. More...
 
void HAL_OSPI_MspDeInit (OSPI_HandleTypeDef *hospi)
 DeInitialize the OSPI MSP. More...
 

Detailed Description

Initialization and Configuration functions.

===============================================================================
            ##### Initialization and Configuration functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to :
      (+) Initialize the OctoSPI.
      (+) De-initialize the OctoSPI.

Function Documentation

◆ HAL_OSPI_DeInit()

HAL_StatusTypeDef HAL_OSPI_DeInit ( OSPI_HandleTypeDef hospi)

De-Initialize the OSPI peripheral.

Parameters
hospi: OSPI handle
Return values
HALstatus

Definition at line 436 of file stm32l4xx_hal_ospi.c.

437 {
438  HAL_StatusTypeDef status = HAL_OK;
439 
440  /* Check the OSPI handle allocation */
441  if (hospi == NULL)
442  {
443  status = HAL_ERROR;
444  /* No error code can be set set as the handler is null */
445  }
446  else
447  {
448  /* Disable OctoSPI */
449  __HAL_OSPI_DISABLE(hospi);
450 
451  /* Disable free running clock if needed : must be done after OSPI disable */
452  CLEAR_BIT(hospi->Instance->DCR1, OCTOSPI_DCR1_FRCK);
453 
454 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
455  if(hospi->MspDeInitCallback == NULL)
456  {
458  }
459 
460  /* DeInit the low level hardware */
461  hospi->MspDeInitCallback(hospi);
462 #else
463  /* De-initialize the low-level hardware */
464  HAL_OSPI_MspDeInit(hospi);
465 #endif
466 
467  /* Reset the driver state */
468  hospi->State = HAL_OSPI_STATE_RESET;
469  }
470 
471  return status;
472 }
void(* MspDeInitCallback)(struct __OSPI_HandleTypeDef *hospi)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
void HAL_OSPI_MspDeInit(OSPI_HandleTypeDef *hospi)
DeInitialize the OSPI MSP.
OCTOSPI_TypeDef * Instance

◆ HAL_OSPI_Init()

HAL_StatusTypeDef HAL_OSPI_Init ( OSPI_HandleTypeDef hospi)

Initialize the OSPI mode according to the specified parameters in the OSPI_InitTypeDef and initialize the associated handle.

Parameters
hospi: OSPI handle
Return values
HALstatus

Definition at line 297 of file stm32l4xx_hal_ospi.c.

298 {
299  HAL_StatusTypeDef status = HAL_OK;
300  uint32_t tickstart = HAL_GetTick();
301 
302  /* Check the OSPI handle allocation */
303  if (hospi == NULL)
304  {
305  status = HAL_ERROR;
306  /* No error code can be set set as the handler is null */
307  }
308  else
309  {
310  /* Check the parameters of the initialization structure */
311  assert_param(IS_OSPI_FIFO_THRESHOLD (hospi->Init.FifoThreshold));
312  assert_param(IS_OSPI_DUALQUAD_MODE (hospi->Init.DualQuad));
313  assert_param(IS_OSPI_MEMORY_TYPE (hospi->Init.MemoryType));
314  assert_param(IS_OSPI_DEVICE_SIZE (hospi->Init.DeviceSize));
315  assert_param(IS_OSPI_CS_HIGH_TIME (hospi->Init.ChipSelectHighTime));
316  assert_param(IS_OSPI_FREE_RUN_CLK (hospi->Init.FreeRunningClock));
317  assert_param(IS_OSPI_CLOCK_MODE (hospi->Init.ClockMode));
318  assert_param(IS_OSPI_WRAP_SIZE (hospi->Init.WrapSize));
319  assert_param(IS_OSPI_CLK_PRESCALER (hospi->Init.ClockPrescaler));
320  assert_param(IS_OSPI_SAMPLE_SHIFTING(hospi->Init.SampleShifting));
321  assert_param(IS_OSPI_DHQC (hospi->Init.DelayHoldQuarterCycle));
322  assert_param(IS_OSPI_CS_BOUNDARY (hospi->Init.ChipSelectBoundary));
323 
324  /* Initialize error code */
325  hospi->ErrorCode = HAL_OSPI_ERROR_NONE;
326 
327  /* Check if the state is the reset state */
328  if (hospi->State == HAL_OSPI_STATE_RESET)
329  {
330 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
331  /* Reset Callback pointers in HAL_OSPI_STATE_RESET only */
342 
343  if(hospi->MspInitCallback == NULL)
344  {
346  }
347 
348  /* Init the low level hardware */
349  hospi->MspInitCallback(hospi);
350 #else
351  /* Initialization of the low level hardware */
352  HAL_OSPI_MspInit(hospi);
353 #endif
354 
355  /* Configure the default timeout for the OSPI memory access */
356  status = HAL_OSPI_SetTimeout(hospi, HAL_OSPI_TIMEOUT_DEFAULT_VALUE);
357  }
358 
359  if (status == HAL_OK)
360  {
361  /* Configure memory type, device size, chip select high time, free running clock, clock mode */
362  MODIFY_REG(hospi->Instance->DCR1, (OCTOSPI_DCR1_MTYP | OCTOSPI_DCR1_DEVSIZE | OCTOSPI_DCR1_CSHT | OCTOSPI_DCR1_FRCK | OCTOSPI_DCR1_CKMODE),
363  (hospi->Init.MemoryType | ((hospi->Init.DeviceSize - 1U) << OCTOSPI_DCR1_DEVSIZE_Pos) |
364  ((hospi->Init.ChipSelectHighTime - 1U) << OCTOSPI_DCR1_CSHT_Pos) | hospi->Init.ClockMode));
365 
366  /* Configure wrap size */
367  MODIFY_REG(hospi->Instance->DCR2, OCTOSPI_DCR2_WRAPSIZE, hospi->Init.WrapSize);
368 
369  /* Configure chip select boundary */
370  hospi->Instance->DCR3 = (hospi->Init.ChipSelectBoundary << OCTOSPI_DCR3_CSBOUND_Pos);
371 
372 
373  /* Configure FIFO threshold */
374  MODIFY_REG(hospi->Instance->CR, OCTOSPI_CR_FTHRES, ((hospi->Init.FifoThreshold - 1U) << OCTOSPI_CR_FTHRES_Pos));
375 
376  /* Wait till busy flag is reset */
377  status = OSPI_WaitFlagStateUntilTimeout(hospi, HAL_OSPI_FLAG_BUSY, RESET, tickstart, hospi->Timeout);
378 
379  if (status == HAL_OK)
380  {
381  /* Configure clock prescaler */
382  MODIFY_REG(hospi->Instance->DCR2, OCTOSPI_DCR2_PRESCALER, ((hospi->Init.ClockPrescaler - 1U) << OCTOSPI_DCR2_PRESCALER_Pos));
383 
384  /* Configure Dual Quad mode */
385  MODIFY_REG(hospi->Instance->CR, OCTOSPI_CR_DQM, hospi->Init.DualQuad);
386 
387  /* Configure sample shifting and delay hold quarter cycle */
388  MODIFY_REG(hospi->Instance->TCR, (OCTOSPI_TCR_SSHIFT | OCTOSPI_TCR_DHQC), (hospi->Init.SampleShifting | hospi->Init.DelayHoldQuarterCycle));
389 
390  /* Enable OctoSPI */
391  __HAL_OSPI_ENABLE(hospi);
392 
393  /* Enable free running clock if needed : must be done after OSPI enable */
394  if (hospi->Init.FreeRunningClock == HAL_OSPI_FREERUNCLK_ENABLE)
395  {
396  SET_BIT(hospi->Instance->DCR1, OCTOSPI_DCR1_FRCK);
397  }
398 
399  /* Initialize the OSPI state */
400  if (hospi->Init.MemoryType == HAL_OSPI_MEMTYPE_HYPERBUS)
401  {
402  hospi->State = HAL_OSPI_STATE_HYPERBUS_INIT;
403  }
404  else
405  {
406  hospi->State = HAL_OSPI_STATE_READY;
407  }
408  }
409  }
410  }
411 
412  /* Return function status */
413  return status;
414 }
void(* TimeOutCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_StatusMatchCallback(OSPI_HandleTypeDef *hospi)
Status Match callback.
void(* RxHalfCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
void(* FifoThresholdCallback)(struct __OSPI_HandleTypeDef *hospi)
void(* CmdCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_CmdCpltCallback(OSPI_HandleTypeDef *hospi)
Command completed callback.
void HAL_OSPI_TxCpltCallback(OSPI_HandleTypeDef *hospi)
Tx Transfer completed callback.
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
void(* RxCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
OSPI_InitTypeDef Init
void(* TxHalfCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
HAL_StatusTypeDef HAL_OSPI_SetTimeout(OSPI_HandleTypeDef *hospi, uint32_t Timeout)
Set OSPI timeout.
void HAL_OSPI_FifoThresholdCallback(OSPI_HandleTypeDef *hospi)
FIFO Threshold callback.
return HAL_OK
void HAL_OSPI_TimeOutCallback(OSPI_HandleTypeDef *hospi)
Timeout callback.
void HAL_OSPI_MspInit(OSPI_HandleTypeDef *hospi)
Initialize the OSPI MSP.
void(* StatusMatchCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_TxHalfCpltCallback(OSPI_HandleTypeDef *hospi)
Tx Half Transfer completed callback.
void(* AbortCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
void(* TxCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_RxCpltCallback(OSPI_HandleTypeDef *hospi)
Rx Transfer completed callback.
void(* ErrorCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_RxHalfCpltCallback(OSPI_HandleTypeDef *hospi)
Rx Half Transfer completed callback.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
OCTOSPI_TypeDef * Instance
void(* MspInitCallback)(struct __OSPI_HandleTypeDef *hospi)
void HAL_OSPI_AbortCpltCallback(OSPI_HandleTypeDef *hospi)
Abort completed callback.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
void HAL_OSPI_ErrorCallback(OSPI_HandleTypeDef *hospi)
Transfer Error callback.

◆ HAL_OSPI_MspDeInit()

__weak void HAL_OSPI_MspDeInit ( OSPI_HandleTypeDef hospi)

DeInitialize the OSPI MSP.

Parameters
hospi: OSPI handle
Return values
None

Definition at line 479 of file stm32l4xx_hal_ospi.c.

480 {
481  /* Prevent unused argument(s) compilation warning */
482  UNUSED(hospi);
483 
484  /* NOTE : This function should not be modified, when the callback is needed,
485  the HAL_OSPI_MspDeInit can be implemented in the user file
486  */
487 }

◆ HAL_OSPI_MspInit()

__weak void HAL_OSPI_MspInit ( OSPI_HandleTypeDef hospi)

Initialize the OSPI MSP.

Parameters
hospi: OSPI handle
Return values
None

Definition at line 421 of file stm32l4xx_hal_ospi.c.

422 {
423  /* Prevent unused argument(s) compilation warning */
424  UNUSED(hospi);
425 
426  /* NOTE : This function should not be modified, when the callback is needed,
427  the HAL_OSPI_MspInit can be implemented in the user file
428  */
429 }