Again, please see How to insert source code
@anandhram1988 wrote:
test 2: L4 with no slave device connected
Think about it: how would the hardware detect that there is no slave attached?
It can't.
You will have to add that in your application.
@anandhram1988 wrote:
test 3: L4 with slave device connected but trying to simulate introduce error to get error codes
So what, exactly, did you do for this "simulation"?
Again, think about whether it produces anything that the SPI hardware could actually detect.
These are the possible error codes which can be reported by HAL_SPI_GetError:
/** @defgroup SPI_Error_Code SPI Error Code
* @{
*/
#define HAL_SPI_ERROR_NONE (0x00000000U) /*!< No error */
#define HAL_SPI_ERROR_MODF (0x00000001U) /*!< MODF error */
#define HAL_SPI_ERROR_CRC (0x00000002U) /*!< CRC error */
#define HAL_SPI_ERROR_OVR (0x00000004U) /*!< OVR error */
#define HAL_SPI_ERROR_FRE (0x00000008U) /*!< FRE error */
#define HAL_SPI_ERROR_DMA (0x00000010U) /*!< DMA transfer error */
#define HAL_SPI_ERROR_FLAG (0x00000020U) /*!< Error on RXNE/TXE/BSY/FTLVL/FRLVL Flag */
#define HAL_SPI_ERROR_ABORT (0x00000040U) /*!< Error during SPI Abort procedure */
#if (USE_HAL_SPI_REGISTER_CALLBACKS == 1U)
#define HAL_SPI_ERROR_INVALID_CALLBACK (0x00000080U) /*!< Invalid Callback error */
#endif /* USE_HAL_SPI_REGISTER_CALLBACKS */
/**
* @}
*/
See stm32l4xx_hal_spi.h