Exemplo n.º 1
0
void uart_event_handler(nrf_drv_uart_event_t * p_event, void* p_context)
{
	switch(p_event->type) {
	case NRF_DRV_UART_EVT_RX_DONE:
		for (uint8_t i=0; i < p_event->data.rxtx.bytes; ++i) {
			//p_event->data.rxtx.p_data[0];
			//(void)nrf_drv_uart_rx(&byte,1);
			QS_RX_PUT(p_event->data.rxtx.p_data[i]);
		}
	    QS_rxParse();  /* parse all the received bytes */
    	break;
	case NRF_DRV_UART_EVT_ERROR:
		//p_event->data.error.error_mask;
	case NRF_DRV_UART_EVT_TX_DONE:
		uart_tx1();
		break;
    }
}
Exemplo n.º 2
0
/*..........................................................................*/
static DWORD WINAPI idleThread(LPVOID par) {/* signature for CreateThread() */
    (void)par;
    while (l_sock != INVALID_SOCKET) {
        uint16_t nBytes;
        uint8_t const *block;

        /* try to receive bytes from the QS socket... */
        nBytes = QS_rxGetNfree();
        if (nBytes > 0U) {
            uint8_t buf[64];
            int status;

            if (nBytes > sizeof(buf)) {
                nBytes = sizeof(buf);
            }
            status = recv(l_sock, (char *)buf, (int)nBytes, 0);
            if (status != SOCKET_ERROR) {
                uint16_t i;
                nBytes = (uint16_t)status;
                for (i = 0U; i < nBytes; ++i) {
                    QS_RX_PUT(buf[i]);
                }
            }
        }
        QS_rxParse();  /* parse all the received bytes */

        nBytes = 1024U;
        QF_CRIT_ENTRY(dummy);
        block = QS_getBlock(&nBytes);
        QF_CRIT_EXIT(dummy);

        if (block != (uint8_t *)0) {
            send(l_sock, (char const *)block, nBytes, 0);
        }
        Sleep(20); /* sleep for xx milliseconds */
    }
    return (DWORD)0; /* return success */
}