This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

串口数据接收问题



做了个串口传输数据的程序,从机向主机发送数据的时候,20字节自动分包,现在是在串口回调函数中加了延时实现的

static void NpiSerialCallback( uint8 port, uint8 events )
{
  (void)port;
  uint8 numBytes = 0;
  uint8 buf[128];
  uint8 send_byte_cnt=0;
  attHandleValueNoti_t pNoti;
  int i=0;
  for(i=20000;i>0;i--)
  {
    asm("nop");
  }
  if (events & (HAL_UART_RX_TIMEOUT))   
  {
    numBytes = NPI_RxBufLen();
    if(numBytes)

现在的问题是修改了波特率,延时时间也要做修改,怎样做可以不用延时。
回调函数能不能做成串口接收数据20个字节以上才能进入。