CART
  • Cart is empty.

    ItemQuantityPrice

    Total: $0

GPS test on Wipom board


Serial API test to check GSP ( SPI2, CS2, CH A).

Toolkit:STM Development System

Location:/bipom/devtools/STM32/examples/Wipom/gps

Code Example


UCB uart3;
UBYTE	uart3_rxBuffer[SC16IS7XX_RX_SOFT_FIFO_LENGTH];
UBYTE	uart3_txBuffer[SC16IS7XX_TX_SOFT_FIFO_LENGTH];

DEVICE_INTERFACE spi2_int_arm;

//********************************************************************************

static void vGPSTEST( void *pvParameters )
{
	int cnt =0;
	int dataInt;
	(void) pvParameters;
	tprintf("\n\rGPS TASK");
	while(1) 
	{
		if (uart3.getRxCounter())
		{
			dataInt = uart3.getData();
			if (dataInt != -1) 
			{
				tprintf("%c",(char)dataInt);
				continue;
			}		
		}
		vTaskDelay(100);
		if( cnt++ == 10)
		{
			tprintf("\n\r\n\rERRORS = %d\n\r",uart3.getErrors());
			cnt =0;
		}
	}
}

//********************************************************************************

int main (void)
{
	ERRCODE ec;
	delayMs(250);
	
	/* Send messages to TERMINAL window */
	tprintf("\n\rMini-Max/STM32F1");
	tprintf("\n\rGPS TEST REV 1.01");
	/* Initialize Device Manager */
	DM_Init();
	/* 	Initialize SPI2 and register to Device Manager	*/
	SPI2_Init(SPI2_INTERFACE_TYPE,DEVICE_INTERFACE_IN_PROGRESS);
	//

	/* Initialize SPI/SC16IS76X/UART interface ( SPI2, CS2, CH A )*/
	uart3.baudRate		= 4800;										// uart baudrate

	uart3.parity		= SERIALAPI_PARITY_NO;						// uart parity

	uart3.stop			= SERIALAPI_STOP_1;							// uart stop bit

	uart3.word_length	= SERIALAPI_WORLD_LENGTH_8;					// uart word length

	uart3.rxFifo		= SERIALAPI_FIFO_8;							// uart RX FIFO trigger level

	uart3.txFifo		= SERIALAPI_FIFO_56;						// uart TX FIFO trigger level

	//SPI1/SC16IS760

	uart3.clock			= SC16IS7XX_SPI_CLOCK;						// SPI clock = 1MHz

	uart3.iface			= SERIALAPI_SPI2_INTERFACE;					// SPI2 interface

	uart3.channel 		= CHANNEL_A;								// Channel A of sc16is76x chip 

	// GPIO

	uart3.gpioDir		= 0xFA;										// All outputs

	uart3.gpioState		= 0x00;
	// RTS

	uart3.rts			= SC16IS7XX_LOW_RTS;
	//

	// Define Rx/Tx buffers

	uart3.rxBuffer		= uart3_rxBuffer;
	uart3.rxLen			= sizeof(uart3_rxBuffer);
	uart3.txBuffer		= uart3_txBuffer;
	uart3.txLen			= sizeof(uart3_txBuffer);
	//

	ec = serialspi2cs2chA_init(&uart3);
	if(ec) goto func_end;
	tprintf("\r\nuart3 init is OK");
	//	

	/* Initialize INT_ARM interrupts */
	INT_ARM_Init();
	/* Register INT ARM interface  to Device Manager as a part of SPI2 interfcace */
	INT_ARM_RegisterInterface(&spi2_int_arm);
	spi2_int_arm.iFaceType 	= SPI2_INTERFACE_TYPE;
	spi2_int_arm.iFaceState	= DEVICE_INTERFACE_PROCESS_REQUEST;
	spi2_int_arm.process	= DM_Process;
	//

	if(pdPASS != 
		xTaskCreate (vGPSTEST, ( const signed portCHAR * const )"GPSTEST", 
			configMINIMAL_STACK_SIZE<<4, NULL, tskIDLE_PRIORITY, NULL ))
	{
		tprintf("\n\rERROR: can't create GPSTEST task");
		ec = 1;
		goto func_end;
	}
	/* Now all the tasks have been started - start the scheduler. */
	vTaskStartScheduler();
func_end:	
	tprintf("\r\nEND, ec =%d",ec);
	for(;;);
	return 0;
}