STM32L4xx_HAL_Driver  1.14.0
Peripheral Control and State functions

OSPI control and State functions. More...

Functions

HAL_StatusTypeDef HAL_OSPI_Abort (OSPI_HandleTypeDef *hospi)
 Abort the current transmission. More...
 
HAL_StatusTypeDef HAL_OSPI_Abort_IT (OSPI_HandleTypeDef *hospi)
 Abort the current transmission (non-blocking function) More...
 
HAL_StatusTypeDef HAL_OSPI_SetFifoThreshold (OSPI_HandleTypeDef *hospi, uint32_t Threshold)
 Set OSPI Fifo threshold. More...
 
uint32_t HAL_OSPI_GetFifoThreshold (OSPI_HandleTypeDef *hospi)
 Get OSPI Fifo threshold. More...
 
HAL_StatusTypeDef HAL_OSPI_SetTimeout (OSPI_HandleTypeDef *hospi, uint32_t Timeout)
 Set OSPI timeout. More...
 
uint32_t HAL_OSPI_GetError (OSPI_HandleTypeDef *hospi)
 Return the OSPI error code. More...
 
uint32_t HAL_OSPI_GetState (OSPI_HandleTypeDef *hospi)
 Return the OSPI handle state. More...
 

Detailed Description

OSPI control and State functions.

 ===============================================================================
                  ##### Peripheral Control and State functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to :
      (+) Check in run-time the state of the driver.
      (+) Check the error code set during last operation.
      (+) Abort any operation.
      (+) Manage the Fifo threshold.
      (+) Configure the timeout duration used in the driver.

Function Documentation

◆ HAL_OSPI_Abort()

HAL_StatusTypeDef HAL_OSPI_Abort ( OSPI_HandleTypeDef hospi)

Abort the current transmission.

Parameters
hospi: OSPI handle
Return values
HALstatus

Definition at line 2219 of file stm32l4xx_hal_ospi.c.

2220 {
2221  HAL_StatusTypeDef status = HAL_OK;
2222  uint32_t state;
2223  uint32_t tickstart = HAL_GetTick();
2224 
2225  /* Check if the state is in one of the busy or configured states */
2226  state = hospi->State;
2227  if (((state & OSPI_BUSY_STATE_MASK) != 0U) || ((state & OSPI_CFG_STATE_MASK) != 0U))
2228  {
2229  /* Check if the DMA is enabled */
2230  if ((hospi->Instance->CR & OCTOSPI_CR_DMAEN) != 0U)
2231  {
2232  /* Disable the DMA transfer on the OctoSPI side */
2233  CLEAR_BIT(hospi->Instance->CR, OCTOSPI_CR_DMAEN);
2234 
2235  /* Disable the DMA transfer on the DMA side */
2236  status = HAL_DMA_Abort(hospi->hdma);
2237  if (status != HAL_OK)
2238  {
2239  hospi->ErrorCode = HAL_OSPI_ERROR_DMA;
2240  }
2241  }
2242 
2243  if (__HAL_OSPI_GET_FLAG(hospi, HAL_OSPI_FLAG_BUSY) != RESET)
2244  {
2245  /* Perform an abort of the OctoSPI */
2246  SET_BIT(hospi->Instance->CR, OCTOSPI_CR_ABORT);
2247 
2248  /* Wait until the transfer complete flag is set to go back in idle state */
2249  status = OSPI_WaitFlagStateUntilTimeout(hospi, HAL_OSPI_FLAG_TC, SET, tickstart, hospi->Timeout);
2250 
2251  if (status == HAL_OK)
2252  {
2253  /* Clear transfer complete flag */
2254  __HAL_OSPI_CLEAR_FLAG(hospi, HAL_OSPI_FLAG_TC);
2255 
2256  /* Wait until the busy flag is reset to go back in idle state */
2257  status = OSPI_WaitFlagStateUntilTimeout(hospi, HAL_OSPI_FLAG_BUSY, RESET, tickstart, hospi->Timeout);
2258 
2259  if (status == HAL_OK)
2260  {
2261  /* Update state */
2262  hospi->State = HAL_OSPI_STATE_READY;
2263  }
2264  }
2265  }
2266  else
2267  {
2268  /* Update state */
2269  hospi->State = HAL_OSPI_STATE_READY;
2270  }
2271  }
2272  else
2273  {
2274  status = HAL_ERROR;
2275  hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_SEQUENCE;
2276  }
2277 
2278  /* Return function status */
2279  return status;
2280 }
uint32_t HAL_GetTick(void)
Provide a tick value in millisecond.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
HAL_StatusTypeDef HAL_DMA_Abort(DMA_HandleTypeDef *hdma)
Abort the DMA Transfer.
OCTOSPI_TypeDef * Instance
DMA_HandleTypeDef * hdma

◆ HAL_OSPI_Abort_IT()

HAL_StatusTypeDef HAL_OSPI_Abort_IT ( OSPI_HandleTypeDef hospi)

Abort the current transmission (non-blocking function)

Parameters
hospi: OSPI handle
Return values
HALstatus

Definition at line 2287 of file stm32l4xx_hal_ospi.c.

2288 {
2289  HAL_StatusTypeDef status = HAL_OK;
2290  uint32_t state;
2291 
2292  /* Check if the state is in one of the busy or configured states */
2293  state = hospi->State;
2294  if (((state & OSPI_BUSY_STATE_MASK) != 0U) || ((state & OSPI_CFG_STATE_MASK) != 0U))
2295  {
2296  /* Disable all interrupts */
2297  __HAL_OSPI_DISABLE_IT(hospi, (HAL_OSPI_IT_TO | HAL_OSPI_IT_SM | HAL_OSPI_IT_FT | HAL_OSPI_IT_TC | HAL_OSPI_IT_TE));
2298 
2299  /* Update state */
2300  hospi->State = HAL_OSPI_STATE_ABORT;
2301 
2302  /* Check if the DMA is enabled */
2303  if ((hospi->Instance->CR & OCTOSPI_CR_DMAEN) != 0U)
2304  {
2305  /* Disable the DMA transfer on the OctoSPI side */
2306  CLEAR_BIT(hospi->Instance->CR, OCTOSPI_CR_DMAEN);
2307 
2308  /* Disable the DMA transfer on the DMA side */
2309  hospi->hdma->XferAbortCallback = OSPI_DMAAbortCplt;
2310  if (HAL_DMA_Abort_IT(hospi->hdma) != HAL_OK)
2311  {
2312  /* Update state */
2313  hospi->State = HAL_OSPI_STATE_READY;
2314 
2315  /* Abort callback */
2316 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
2317  hospi->AbortCpltCallback(hospi);
2318 #else
2320 #endif
2321  }
2322  }
2323  else
2324  {
2325  if (__HAL_OSPI_GET_FLAG(hospi, HAL_OSPI_FLAG_BUSY) != RESET)
2326  {
2327  /* Clear transfer complete flag */
2328  __HAL_OSPI_CLEAR_FLAG(hospi, HAL_OSPI_FLAG_TC);
2329 
2330  /* Enable the transfer complete interrupts */
2331  __HAL_OSPI_ENABLE_IT(hospi, HAL_OSPI_IT_TC);
2332 
2333  /* Perform an abort of the OctoSPI */
2334  SET_BIT(hospi->Instance->CR, OCTOSPI_CR_ABORT);
2335  }
2336  else
2337  {
2338  /* Update state */
2339  hospi->State = HAL_OSPI_STATE_READY;
2340 
2341  /* Abort callback */
2342 #if defined (USE_HAL_OSPI_REGISTER_CALLBACKS) && (USE_HAL_OSPI_REGISTER_CALLBACKS == 1U)
2343  hospi->AbortCpltCallback(hospi);
2344 #else
2346 #endif
2347  }
2348  }
2349  }
2350  else
2351  {
2352  status = HAL_ERROR;
2353  hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_SEQUENCE;
2354  }
2355 
2356  /* Return function status */
2357  return status;
2358 }
void(* XferAbortCallback)(struct __DMA_HandleTypeDef *hdma)
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
return HAL_OK
void(* AbortCpltCallback)(struct __OSPI_HandleTypeDef *hospi)
OCTOSPI_TypeDef * Instance
void HAL_OSPI_AbortCpltCallback(OSPI_HandleTypeDef *hospi)
Abort completed callback.
DMA_HandleTypeDef * hdma

◆ HAL_OSPI_GetError()

uint32_t HAL_OSPI_GetError ( OSPI_HandleTypeDef hospi)

Return the OSPI error code.

Parameters
hospi: OSPI handle
Return values
OSPIError Code

Definition at line 2414 of file stm32l4xx_hal_ospi.c.

2415 {
2416  return hospi->ErrorCode;
2417 }

◆ HAL_OSPI_GetFifoThreshold()

uint32_t HAL_OSPI_GetFifoThreshold ( OSPI_HandleTypeDef hospi)

Get OSPI Fifo threshold.

Parameters
hospi: OSPI handle.
Return values
Fifothreshold

Definition at line 2393 of file stm32l4xx_hal_ospi.c.

2394 {
2395  return ((READ_BIT(hospi->Instance->CR, OCTOSPI_CR_FTHRES) >> OCTOSPI_CR_FTHRES_Pos) + 1U);
2396 }
OCTOSPI_TypeDef * Instance

◆ HAL_OSPI_GetState()

uint32_t HAL_OSPI_GetState ( OSPI_HandleTypeDef hospi)

Return the OSPI handle state.

Parameters
hospi: OSPI handle
Return values
HALstate

Definition at line 2424 of file stm32l4xx_hal_ospi.c.

2425 {
2426  /* Return OSPI handle state */
2427  return hospi->State;
2428 }

◆ HAL_OSPI_SetFifoThreshold()

HAL_StatusTypeDef HAL_OSPI_SetFifoThreshold ( OSPI_HandleTypeDef hospi,
uint32_t  Threshold 
)

Set OSPI Fifo threshold.

Parameters
hospi: OSPI handle.
Threshold: Threshold of the Fifo.
Return values
HALstatus

Definition at line 2365 of file stm32l4xx_hal_ospi.c.

2366 {
2367  HAL_StatusTypeDef status = HAL_OK;
2368 
2369  /* Check the state */
2370  if ((hospi->State & OSPI_BUSY_STATE_MASK) == 0U)
2371  {
2372  /* Synchronize initialization structure with the new fifo threshold value */
2373  hospi->Init.FifoThreshold = Threshold;
2374 
2375  /* Configure new fifo threshold */
2376  MODIFY_REG(hospi->Instance->CR, OCTOSPI_CR_FTHRES, ((hospi->Init.FifoThreshold-1U) << OCTOSPI_CR_FTHRES_Pos));
2377 
2378  }
2379  else
2380  {
2381  status = HAL_ERROR;
2382  hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_SEQUENCE;
2383  }
2384 
2385  /* Return function status */
2386  return status;
2387 }
OSPI_InitTypeDef Init
return HAL_OK
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
OCTOSPI_TypeDef * Instance

◆ HAL_OSPI_SetTimeout()

HAL_StatusTypeDef HAL_OSPI_SetTimeout ( OSPI_HandleTypeDef hospi,
uint32_t  Timeout 
)

Set OSPI timeout.

Parameters
hospi: OSPI handle.
Timeout: Timeout for the memory access.
Return values
None

Definition at line 2403 of file stm32l4xx_hal_ospi.c.

2404 {
2405  hospi->Timeout = Timeout;
2406  return HAL_OK;
2407 }
return HAL_OK