/****************************************************************************
  MAIN APPLICATION ENTRY POINT
****************************************************************************/
int main(void)
{
	//	Queue creation - will be used for communication between the stack and other tasks
	xQueue = xQueueCreate(3, sizeof (int));

	xSemFrontEnd = xSemaphoreCreateMutex();
	
	// Initialize application specific hardware
	HWInit(HWDEFAULT);
	UARTInit(1,19200);
	UARTOn(1);

	// RTOS starting
	if (xSemFrontEnd != NULL) 
	{
		// Creates the task to handle all HiLo functions
		xTaskCreate(GSMTask, (signed char*) "GSM", STACK_SIZE_GSM,
		NULL, tskIDLE_PRIORITY + 1, &hGSMTask);
	
		// Start of the RTOS scheduler, this function should never return
		vTaskStartScheduler();
	}
	
	#if defined	(STACK_USE_UART)
	UARTWrite(1, "Unexpected end of program...\r\n");
	#endif
	while(1);
	return -1;
}
示例#2
0
/****************************************************************************
  MAIN APPLICATION ENTRY POINT
****************************************************************************/
int main(void)
{
	// Initialize application specific hardware
	HWInit(HWDEFAULT);	

	// Initializing the UART for the debug
	#if defined	(STACK_USE_UART)
	UARTInit(1, UART_DBG_DEF_BAUD);
	UARTOn(1);
	_dbgwrite("Flyport starting...");
	#endif

	//	Queue creation - will be used for communication between the stack and other tasks
	xQueue = xQueueCreate(3, sizeof (int));

	xSemFrontEnd = xSemaphoreCreateMutex();
	
	
	//	RTOS starting
	if (xSemFrontEnd != NULL) 
	{
		// Creates the task to handle all TCPIP functions
		xTaskCreate(TCPIPTask, (signed char*) "TCP", STACK_SIZE_TCPIP,
		NULL, tskIDLE_PRIORITY + 1, &hTCPIPTask);
	
		// Start of the RTOS scheduler, this function should never return
		vTaskStartScheduler();
	}
	
	_dbgwrite("Unexpected end of program...\r\n");

	while(1);
	return -1;
}
示例#3
0
/**
 *  static int Gps_set(void * _self, va_list *app) -  Perform a new gps acquisition.
 * \param *_self - pointer to the device 
 * \param *app - none 
 * \return:
 	<LI><Breturn = 0:</B>when the GPS device is connected on a Grove nest DIG port, with or without a valid connection </LI> 
 	<LI><Breturn = -1:</B>when the GPS device is not connected on a Grove nest DIG port. </LI> 
 </UL>
 */
static int Gps_set(void *_self,va_list *app)
{ 
	struct Gps *self = _self;
	char gps_sentences[70];
	unsigned int timer = 65000;
	flag = 1;
	nmea_zero_INFO(&self->info);
	nmea_parser_init(&self->parser);
	UARTOn(self->uart_module);
	UARTFlush(self->uart_module);
	vTaskDelay(50);
	while((UARTBufferSize(self->uart_module)<3) && timer)
		timer--;
	if(!timer)
		return -1;		
	timer = 500;
	while((gps_sentences[0] != '$') && timer)
	{
		timer--;
		while(UARTBufferSize(self->uart_module)<1);
		UARTRead(self->uart_module,gps_sentences,1);
		if(gps_sentences[0] == '$')
		{
			while(UARTBufferSize(self->uart_module) < 5);
			UARTRead(self->uart_module,(gps_sentences+1),5); //Reads all the chars in the
			if((gps_sentences[4] == 'M'))
			{
				while(UARTBufferSize(self->uart_module) < 65);					
				UARTRead(self->uart_module,(gps_sentences+6),64); //Reads all the chars in the
				gps_sentences[70] = '\0';
				int i = 0;
				i = nmea_parse(&self->parser, gps_sentences, (int)strlen(gps_sentences), &self->info);
				if(i)
				{
					flag = 0;
					self->lat = nmea_ndeg2degree (self->info.lat);
					self->lon = -nmea_ndeg2degree (self->info.lon);
					self->year = self->info.utc.year+1900;
					self->mon = self->info.utc.mon;
					self->day = self->info.utc.day;
					self->hour = self->info.utc.hour;
					self->min = self->info.utc.min;
					self->sec = self->info.utc.sec;
					self->speed = self->info.speed;
				    break;
				}
			}	
		}
		gps_sentences[0]= 0;
	}
	nmea_parser_destroy(&self->parser);
	UARTOff(self->uart_module);
	return 0;
}