SBL_Status sendAutoBaud()
{
char pData[2];
memset(pData, 0x55, 2);
Uart_ReturnType STA;
int retry_count = 0;
bool bBaudSetOk = false;
while(retry_count < 3)
{
// 发送 0X55 ,0X55, 期望 ack,依赖于 Uart_Write 传递
STA = Uart_Write(UART_CHANNEL_ID, pData, 2);
if(STA == UART_NOTOK) //uart串口发送数据没有发送成功,串口错误
{
retry_count++;
continue;
}
// 考虑是否需要加延迟函数,用来接来自BLE的响应。
if(getCmdResponse(&bBaudSetOk) == SBL_SUCCESS && bBaudSetOk == true)
{
return SBL_SUCCESS;
}
else
{
retry_count++;
}
}
// 超过最大重试次数或 getCmdResponse 返回错误
return SBL_ERROR;
}