typedef enum S_ERR
{
S_ERR_OK, // no error
S_ERR_BUSY, // Read or Write process is in busy.
S_ERR_NO_BUFFER, // no buffer room for data received
S_ERR_TIMEOUT, // timeout when read
S_ERR_UNKNOWN_CMD, // not in use
S_ERR_INVALID_CMD, // not in use
S_ERR_CANCEL, // not in use
S_ERR_PARA // provide function with invalid argument
}S_ERR;
//*** callback function type definitions ***
typedef void(*CB_ERR)(S_ERR);
typedef void(*CB_DONE_WRITE)(S_ERR);
typedef void(*CB_DONE_READ)(S_ERR, UINT32);
void sci_appl_Init(void)
{
S_ERR err = S_ERR_OK;
err = HAL_Init( (CB_ERR)CBError ); // initiate HAL (must provide valid argument otherwise HAL_Init will return error(S_ERR_PARA).)
if( err == S_ERR_OK )
{
init_appl_data(); // initialize application-layer's data
HAL_Config_Set(&s_HALconfig_LEN); // configure HAL (assign Work-mode)
//HAL_Config_Set(&s_HALconfig_TIME);
//HAL_Config_Set(&s_HALconfig_CHAR);
#if DMA_MODE == DMA_REC_SEND
HAL_Read_DMA(RX_BUFFER_SIZE,s_pReadBuffer,CBDoneRead); // request HAL to read.(for Serial-x)
// HAL_Read_DMA2(RX_BUFFER_SIZE,s_pReadBuffer2,CBDoneRead2); // request HAL to read.(for LittleSwan)
HAL_Read_Poll2(RX_BUFFER_SIZE,s_pReadBuffer2,CBDoneRead2); // use poll method for littleswan receiving.
#else
HAL_Read(RX_BUFFER_SIZE,s_pReadBuffer2,CBDoneRead2); // request HAL to read.
#endif
}
ReadBuffer[0]=0x01; // test
}
S_ERR HAL_Init(CB_ERR _fpError)
{
UINT8 dummy;
S_ERR err = S_ERR_OK;
if( NULL == _fpError )
{
err = S_ERR_PARA;
}
else
{
s_fpError = _fpError; // Store CallBack function pointers
}
if(S_ERR_OK == err) // if no error encountered.
{
hw_voInitUART(); // initiate UART module hardware
}
return err;
}
请问我该如何理解这一句?err = HAL_Init( (CB_ERR)CBError ); |