void USB_UartCreateHandle(USB_UartType *base,
                          usb_uart_handle_t *handle,
                          usb_uart_rx_callback_t callback,
                          void *userData)
{
    UART_TransferCreateHandle(base, (uart_handle_t *)handle, callback, userData);
}
示例#2
0
void gps_task(void *pArg)
{

	char rx_sentence[200];
	char *data_ptr;
	uint32_t len;
	uint32_t notificationValue;

	PRINTF("from gps task...\r\n");

	/* Use Task Notification to sychronize between UART Rx handler and GPS task */
	xGpsTaskHandle = xTaskGetCurrentTaskHandle();

	/* Initialize UART driver with given parameters */
	UART_Init(GPS_UART_BASE, &gps_uart_config, GPS_UART_SRCCLK);

	/* Initialize UART driver and install our own handler for UART Rx data, which is called by the ISR */
	UART_TransferCreateHandle(GPS_UART_BASE, &gps_uart_handle, gps_uart_rx_handler, NULL);

	/* Set receive buffer pointer explicitly for custom handling */
	gps_uart_handle.rxData = gps_rx_buf;
	gps_uart_handle.rxDataSize = 1;

	/* Enable RX interrupt (start reception of bytes from GPS module) */
	UART_EnableInterrupts(GPS_UART_BASE, kUART_RxDataRegFullInterruptEnable | kUART_RxOverrunInterruptEnable);

	/* Turn on RED LED */


	while (1) {

		/* Wait for notification from UART Rx handler */
		if((notificationValue = ulTaskNotifyTake(pdTRUE, portMAX_DELAY)) == 1) {
			/* Copy the received sentence */
			len = gps_rx_len;
			memcpy((void *) rx_sentence, (void *) gps_rx_sentence, len);

			/* Parse the received sentence to update gps_info structure */
			if (NULL != strstr(rx_sentence, "GPGGA")) {
				data_ptr = &rx_sentence[6];
				gps_parse_gga(data_ptr, &gps_info);
			}

			if ((NULL != strstr(rx_sentence, "GPRMC")) || (NULL != strstr(rx_sentence, "GNRMC"))) {
				data_ptr = &rx_sentence[6];
				gps_parse_rmc(data_ptr, &gps_info);
			}
		}

		/* Check for GPS Fix */
		if (NO_FIX != gps_info.fix) {
			/* Turn on GREEN LED */
			LED_GREEN_ON();
		}
		else {
			/* Turn off GREEN LED */
			LED_GREEN_OFF();
		}

	}

}