Esempio n. 1
0
void vNFCTxTask(void* pvParameters ) {
	TQ tq;

	vDebugString("NFC TX task started");
/*
	while(1)
	{	USARTx_Send(DMA1_Stream3,"A",1*sizeof(uint8_t));
	vTaskDelay(10);
	}
*/
	for(;;) {

		if(xQueueReceive( xQueueNFCTx, &tq, (portTickType)portMAX_DELAY) == pdPASS){
			USARTx_Send(DMA1_Stream3,tq.data,tq.length*sizeof(uint8_t));

			if(xSemaphoreTake(xSemaphoreTx,(portTickType)100) != pdTRUE){
				vDebugString("NFC TX task timeout");
			}
		}
		else
		{
			vTaskDelay(50);
		}
	}
}
Esempio n. 2
0
portTASK_FUNCTION( vEOBDTask, pvParameters )
{
	EOBDMSG RxMsg;
	EOBDMSG TxMsg;

	xEOBDQueueHandleToPrim = xQueueCreate(QLENGTH,sizeof(struct EOBSMessage *));
	if(xEOBDQueueHandleToPrim == 0)
	{
		vDebugPrintf( "xEOBDQueueHandle == 0\r\n");
	}

    xTaskCreate( vEOBDPrimitiveTask, (signed char *) "EOBDPrim", configMINIMAL_STACK_SIZE,
            NULL, mainEOBDPRIM_TASK_PRIORITY, &hEOBDPrimitiveTask );

	vDebugString( "EOBD task started.\r\n");

	while(1)
	{
		if(SendRcvd(&TxMsg, &RxMsg, (portTickType)50))
		{

		}
		else {
			vDebugString( "SendRcvd timeout\r\n");
		}
	}

}
// ============================================================================
void vDebugTask(void *pvParameters) {
    char ch;
    portBASE_TYPE xStatus;
    //uint16_t u16StackSize;

    /* The parameters are not used. */
    (void) pvParameters;

    vDebugString("Debug task started.\r\n");

    while(1) {
        // As long as there are characters in the queue fifo this code should
        // pop them out and send them as quick as possible out the UART.
        if(USART_GetFlagStatus(USART2, USART_FLAG_TXE)) {
            // We don't want to block forever - need to check on Rx too.
            xStatus = xQueueReceive(xDebugQueue, &ch, 10 / portTICK_RATE_MS);
            if(xStatus == pdPASS) USART_SendData(USART2, ch);
        }
        if (USART_GetFlagStatus(USART2, USART_FLAG_RXNE)) {
            ch = USART_ReceiveData(USART2);
            // Handle Debug Console Commands Here.
            switch (ch) {

            // Alphabetical list of commands the console debugger responds to.

            case 'm':
                vDebugPrintf("Mems dump Stopped.\r\n");
                //vSetMemsDump(false);
                break;
            case 'M':
                vDebugPrintf("Mems dump Started.\r\n");
                //vSetMemsDump(true);
                break;

            case 'a':
                vDebugPrintf("AtoD dump Stopped.\r\n");
                //vSetAtoDDump(FALSE);
                break;
            case 'A':
                vDebugPrintf("AtoD dump Started.\r\n");
                //vSetAtoDDump(TRUE);
                break;

            // Print out how much stack space remains on each task stack.
            case 's':
                vDebugPrintf("Remaining space on Task Stack:\r\n");
                break;

            // Add general test code here...
            case 't':
                break;

            default:
                break;
            }
        }

        taskYIELD();
    }
}
Esempio n. 4
0
portTASK_FUNCTION( vEOBDPrimitiveTask, pvParameters )
{
	EOBDMSG TxMsg;
	EOBDMSG RxMsg;

	EOBD_Primitive_Configure();

	xEOBDQueueHandle = xQueueCreate(QLENGTH,sizeof(struct EOBSMessage *));
	if(xEOBDQueueHandle == 0)
	{
		vDebugPrintf( "xEOBDQueueHandle == 0\r\n");
	}


	vDebugString( "EOBD primitive task started.\r\n");

	while(1)
	{
		if(xQueueReceive(xEOBDQueueHandleToPrim,&TxMsg , portMAX_DELAY))
		{


			xQueueSend(xEOBDQueueHandle,&RxMsg, (portTickType)0);
		}
	}

}
Esempio n. 5
0
portBASE_TYPE usart3_readSingleByte(uint8_t* ch,portTickType timeout){
	  if(xQueueReceive( xQueueNFCRx, ch , timeout) == pdPASS){
		  return pdPASS;
	  }

	  vDebugString("rx fail");
	  return pdFAIL;
}
Esempio n. 6
0
void vNFCTask(void *vParameter){

	vDebugString("vNFCTask started");

	vTaskDelay(100);

	nfc_init(&context);

	pnd = nfc_open(context);

	nfc_close(pnd);

	nfc_exit(context);

	for(;;){

			vTaskDelay(1000);
	}
}
Esempio n. 7
0
// DebugPrintf - really trivial implementation, however, it's reentrant!
// ToDo - This needs a rewrite! Add code to check we're not overflowing.
// ============================================================================
void vDebugPrintf(const char *fmt, ...) {
	char sTmp[80];	// String build area.  String lives on the stack!
	uint8_t pos=0;
	char *bp = (char *)fmt;
    va_list ap;
    char c;
    char *p;
    int i;

    va_start(ap, fmt);

    while ((c = *bp++)) {
        if (c != '%') {
            sTmp[pos++] = c;
            continue;
        }

        switch ((c = *bp++)) {
			// d - decimal value
			case 'd':
				vNum2String( sTmp, &pos, va_arg(ap, uint32_t), 10);
				break;

			// %x - value in hex
			case 'x':
				sTmp[pos++] = '0';
				sTmp[pos++] = 'x';
				vNum2String( sTmp, &pos, va_arg(ap, uint32_t), 16);
				break;

			// %b - binary
			case 'b':
				sTmp[pos++] = '0';
				sTmp[pos++] = 'b';
				vNum2String( sTmp, &pos, va_arg(ap, uint32_t), 2);
				break;

			// %c - character
			case 'c':
				sTmp[pos++] = va_arg(ap, int);
				break;

			// %i - integer
			case 'i':
				i = va_arg(ap, int32_t);
				if(i < 0){
					sTmp[pos++] = '-';
					vNum2String( sTmp, &pos, (~i)+1, 10);
				} else {
					vNum2String( sTmp, &pos, i, 10);
				}
				break;

			// %s - string
			case 's':
				p = va_arg(ap, char *);
				do {
					sTmp[pos++] = *p++;
				} while (*p);
				break;

			// %% - output % character
			case '%':
				sTmp[pos++] = '%';
				break;

			// Else, must be something else not handled.
			default:
				sTmp[pos++] = '?';
				break;
        }
    }
    sTmp[pos++] = 0;		// Mark the end of the string.
    vDebugString( sTmp );	// Copy the string into the OS queue.
    return;
}
Esempio n. 8
0
portTASK_FUNCTION( vDebugTask, pvParameters )
{
/*----------------------------------------------------------
Local variables
----------------------------------------------------------*/
char          ch;
portBASE_TYPE xStatus;
//uint16_t      u16StackSize;

/*----------------------------------------------------------
What.
----------------------------------------------------------*/
( void ) pvParameters;
    
/*----------------------------------------------------------
Start Debug task loop
----------------------------------------------------------*/
vDebugString( "Debug task started.\r\n");
for(;;)
    {
    /*------------------------------------------------------
    Send characters in the FIFO queue
    ------------------------------------------------------*/
    if( USART_GetFlagStatus( USART2, USART_FLAG_TXE ) )
        {
        /*--------------------------------------------------
        Don't block forever, need to check RX too
        --------------------------------------------------*/
        xStatus = xQueueReceive( xDebugQueue, &ch, 10 / portTICK_RATE_MS );
        if( xStatus == pdPASS )
            {
            USART_SendData( USART2, ch );
            }
        }
        
    /*------------------------------------------------------
    Receive incoming characters
    ------------------------------------------------------*/
    if ( USART_GetFlagStatus( USART2, USART_FLAG_RXNE ) )
        {
        ch = USART_ReceiveData( USART2 );

        /*--------------------------------------------------
        Handle console commands
        --------------------------------------------------*/
        switch ( ch )
            {
            case 'a':
                vDebugPrintf( "AtoD dump Stopped.\r\n");
                //vSetAtoDDump( FALSE );
                break;
            
            case 'A':
                vDebugPrintf( "AtoD dump Started.\r\n");
                //vSetAtoDDump( TRUE );
                break;

            case 'l':
                vDebugPrintf( "Loop Count Stopped.\r\n");
                //vSetCntLoops( FALSE );
                break;
            case 'L':
                vDebugPrintf( "Loop Count Started.\r\n");
                //vSetCntLoops( TRUE );
                break;

            case 's':
                vDebugPrintf( "Remaining space on Task Stack:\r\n" );
                //u16StackSize = uxTaskGetStackHighWaterMark( hDebugTask );
                //vDebugPrintf( "Debug\t%d\r\n", u16StackSize);
                //u16StackSize = uxTaskGetStackHighWaterMark( hTimeTask );
                //vDebugPrintf( "Time\t%d\r\n", u16StackSize);
                break;

            default:
                break;
            }
        }

    taskYIELD();
    }
}
Esempio n. 9
0
// TODO - check for overflows
void vDebugPrintf(const char *fmt, ...) {
    
/*----------------------------------------------------------
Local variables
----------------------------------------------------------*/
char sTmp[ 80 ];
uint8_t pos=0;
char *bp = (char *)fmt;
va_list ap;
char c;
char *p;
int i;

va_start(ap, fmt);
    
/*----------------------------------------------------------
Parse all given parameters
----------------------------------------------------------*/
while ( ( c = *bp++ ) )
    {
    if (c != '%')
        {
        sTmp[pos++] = c;
        continue;
        }

    switch ((c = *bp++))
        {
        /* d - decimal value */
        case 'd':
            vNum2String( sTmp, &pos, va_arg( ap, uint32_t), 10 );
            break;

        /* %x - value in hex */
        case 'x':
            sTmp[pos++] = '0';
            sTmp[pos++] = 'x';
            vNum2String( sTmp, &pos, va_arg( ap, uint32_t), 16 );
            break;

        /* %b - binary */
        case 'b':
            sTmp[pos++] = '0';
            sTmp[pos++] = 'b';
            vNum2String( sTmp, &pos, va_arg( ap, uint32_t), 2 );
            break;

        /* %c - character */
        case 'c':
            sTmp[pos++] = va_arg( ap, int );
            break;

        /* %i - integer */
        case 'i':
            i = va_arg( ap, int32_t );
            if(i < 0){
                sTmp[pos++] = '-';
                vNum2String( sTmp, &pos, (~i)+1, 10);
            } else {
                vNum2String( sTmp, &pos, i, 10);
            }
            break;

        /* %s - string */
        case 's':
            p = va_arg(ap, char *);
            do {
                sTmp[pos++] = *p++;
            } while (*p);
            break;

        /* %% - output % character */
        case '%':
            sTmp[pos++] = '%';
            break;

        /* Else, must be something else not handled. */
        default:
            sTmp[pos++] = '?';
            break;
        }
    }
    
/*----------------------------------------------------------
Mark end of string and copy into OS queue
----------------------------------------------------------*/
sTmp[pos++] = 0;
vDebugString( sTmp );
return;

}