Src/custom_bus.c
int32_t BSP_SPI2_Init(void) 
{
  int32_t ret = BSP_ERROR_NONE;
  
  hspi2.Instance  = SPI2;
  if (HAL_SPI_GetState(&hspi2) == HAL_SPI_STATE_RESET) 
  { 
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 0)
    /* Init the SPI Msp */
    SPI2_MspInit(&hspi2);
#else
    if(IsSPI2MspCbValid == 0U)
    {
      if(BSP_SPI2_RegisterDefaultMspCallbacks() != BSP_ERROR_NONE)
      {
        return BSP_ERROR_MSP_FAILURE;
      }
    }
#endif   
    
    /* Init the SPI */
    if (MX_SPI2_Init(&hspi2) != HAL_OK)
    {
      ret = BSP_ERROR_BUS_FAILURE;
    }
  } 

  return ret;
}
/**
  * @brief  Initializes SPI HAL. 
  * @retval BSP status
  */
@brief  Initializes SPI HAL.
@retval BSP status
@brief Initializes SPI HAL . @retval BSP status
int32_t BSP_SPI2_Init(void) 
{
  int32_t ret = BSP_ERROR_NONE;
  hspi2.Instance  = SPI2;
  if (HAL_SPI_GetState(&hspi2) == HAL_SPI_STATE_RESET) 
  { 
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 0)
    SPI2_MspInit(&hspi2);
#else
    if(IsSPI2MspCbValid == 0U)
    {
      if(BSP_SPI2_RegisterDefaultMspCallbacks() != BSP_ERROR_NONE)
      {
        return BSP_ERROR_MSP_FAILURE;
      }
    }
#endif   
    if (MX_SPI2_Init(&hspi2) != HAL_OK)
    {
      ret = BSP_ERROR_BUS_FAILURE;
    }
  } 
  return ret;
}
int32_t BSP_SPI2_Init ( void ) { int32_t ret = BSP_ERROR_NONE ; hspi2 . Instance = SPI2 ; if ( HAL_SPI_GetState ( & hspi2 ) == HAL_SPI_STATE_RESET ) { #if ( USE_HAL_SPI_REGISTER_CALLBACKS == 0 ) SPI2_MspInit ( & hspi2 ) ; #else if ( IsSPI2MspCbValid == 0U ) { if ( BSP_SPI2_RegisterDefaultMspCallbacks ( ) != BSP_ERROR_NONE ) { return BSP_ERROR_MSP_FAILURE ; } } #endif if ( MX_SPI2_Init ( & hspi2 ) != HAL_OK ) { ret = BSP_ERROR_BUS_FAILURE ; } } return ret ; }
@brief  Initializes SPI HAL.
@brief Initializes SPI HAL .
/* Init the SPI Msp */ /* Init the SPI */