/*******************************************************************************
|
* File Name : Uart.c
|
* Description :
|
* Created on : 2018Äê4ÔÂ24ÈÕ
|
* Author : www.hido-studio.com
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Include Files *
|
*******************************************************************************/
|
#include "stm32f4xx_hal.h"
|
#include "SPI_hal.h"
|
|
/*******************************************************************************
|
* Macro *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Type Definition *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Variable *
|
*******************************************************************************/
|
static SPI_HandleTypeDef *l_apstSPIHandle[SPI_ID_LAST];
|
|
/*******************************************************************************
|
* Local Function Declaration *
|
*******************************************************************************/
|
|
/*******************************************************************************
|
* Local Function *
|
*******************************************************************************/
|
/*******************************************************************************
|
* Function Name :
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2018Äê4ÔÂ24ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 SPI_Write(E_SPI_ID _eID, HIDO_UINT8 *_pu8WriteBuf, HIDO_UINT32 _u32Len)
|
{
|
HAL_SPI_Transmit(l_apstSPIHandle[_eID], _pu8WriteBuf, _u32Len, 100 * _u32Len);
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name :
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2018Äê4ÔÂ24ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 SPI_ReadWrite(E_SPI_ID _eID, HIDO_UINT8 *_pu8ReadBuf, HIDO_UINT8 *_pu8WriteBuf, HIDO_UINT32 _u32Len)
|
{
|
if(HIDO_NULL == _pu8ReadBuf)
|
{
|
return SPI_Write(_eID, _pu8WriteBuf, _u32Len);
|
}
|
else
|
{
|
HAL_SPI_TransmitReceive(l_apstSPIHandle[_eID], _pu8WriteBuf, _pu8ReadBuf, _u32Len, 100 * _u32Len);
|
}
|
|
return HIDO_OK;
|
}
|
|
/*******************************************************************************
|
* Function Name :
|
* Description :
|
* Input :
|
* Output :
|
* Return :
|
* Author : www.hido-studio.com
|
* Modified Date: : 2018Äê4ÔÂ24ÈÕ
|
*******************************************************************************/
|
HIDO_INT32 SPI_Register(E_SPI_ID _eID, HIDO_VOID *_pSPIHandle)
|
{
|
l_apstSPIHandle[_eID] = (SPI_HandleTypeDef *)_pSPIHandle;
|
|
return HIDO_OK;
|
}
|