void UartRxChedHandler(void * p_event_data, uint16_t event_size) { uint8_t buff[128]; int l = g_Uart.Rx(buff, 128); if (l > 0) { BleSrvcCharNotify(&g_UartBleSrvc, 0, buff, l); } }
int main() { bool res; #ifdef DEMO_C res = UARTInit(&g_UartDev, &g_UartCfg); #else res = g_Uart.Init(g_UartCfg); #endif uint8_t d = 0xff; uint8_t val = 0; uint32_t errcnt = 0; uint32_t cnt = 0; auto t_start = std::chrono::high_resolution_clock::now(); auto t_end = std::chrono::high_resolution_clock::now(); std::chrono::duration<float> elapse = std::chrono::duration<float>(0); t_start = std::chrono::high_resolution_clock::now(); time_t t; double e = 0.0; bool isOK = false; // do { #ifdef DEMO_C while (UARTRx(&g_UartDev, &d, 1) <= 0); #else while (g_Uart.Rx(&d, 1) <= 0); #endif if (val == d) isOK = true; val = Prbs8(d); // } while (!isOK); while(1) { // t_start = std::chrono::high_resolution_clock::now(); t = time(NULL); #ifdef DEMO_C while (UARTRx(&g_UartDev, &d, 1) <= 0); #else while (g_Uart.Rx(&d, 1) <= 0); #endif { e += difftime(time(NULL), t); // t_end = std::chrono::high_resolution_clock::now(); //elapse += std::chrono::duration<float>(t_end-t_start); cnt++; // If success send next code // printf("%x ", d); if (val != d) { errcnt++; // printf("PRBS %u errors %x %x\n", errcnt, val, d); } else if ((cnt & 0x7fff) == 0) { printf("PRBS rate %.3f B/s, err : %u\n", cnt / e, errcnt); // printf("PRBS rate %.3f B/s, err : %u\n", cnt / elapse.count(), errcnt); } val = Prbs8(d); } } return 0; }