Exemplo n.º 1
0
Arquivo: usart.c Projeto: tsugli/stm32
//===============================================================================================
__inline AT91F_US_START_TRANSMITION(AT91PS_USART COM, uint8 *data, int size)
{
    portENTER_CRITICAL();
    {
        AT91F_US_EnableTx(COM);
        AT91F_US_EnableIt(COM,AT91C_US_TXEMPTY | AT91C_US_TXEN );
        COM->US_TCR = 0;
        COM->US_TNCR = 0;
        COM->US_TPR = (unsigned int) data;
        COM->US_TCR = size;
    }
    portEXIT_CRITICAL();
}
Exemplo n.º 2
0
Arquivo: usart.c Projeto: tsugli/stm32
//===============================================================================================
__inline AT91F_US_START_RECEIVE(AT91PS_USART COM, uint8 *data, int size)
{
    portENTER_CRITICAL();
    {
        AT91F_US_TIMEOUT(COM,0x40);
        AT91F_US_EnableIt(COM,AT91C_US_RXBUFF | AT91C_US_TIMEOUT | AT91C_US_RXBUFF | AT91C_US_FRAME | AT91C_US_PARE |AT91C_US_OVRE);
        AT91F_US_EnableRx(COM);
        COM->US_RCR = 0;
        COM->US_RNCR = 0;
        COM->US_RPR = (unsigned int) data;
        COM->US_RCR = size;
    }
    portEXIT_CRITICAL();
}
Exemplo n.º 3
0
//===============================================================================================
inline void AT91F_US_START_RECEIVE(AT91PS_USART COM, uint8 *data, int size)
{
	portENTER_CRITICAL();
	{
		AT91F_US_TIMEOUT_SET(COM,0x20);
		AT91F_US_EnableIt(COM, AT91C_US_TIMEOUT | AT91C_US_RXBUFF);
		COM->US_RNCR = 0;
		COM->US_RNCR = 0;
		COM->US_RPR = (unsigned int) data;
		COM->US_RCR = size;
		AT91F_US_EnableRx(COM);
	}
	portEXIT_CRITICAL();
}
Exemplo n.º 4
0
/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
xComPortHandle xReturn = serHANDLE;
extern void ( vUART_ISR )( void );

	/* Create the queues used to hold Rx and Tx characters. */
	xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
	xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) );

	/* If the queues were created correctly then setup the serial port 
	hardware. */
	if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) )
	{
		portENTER_CRITICAL();
		{
			/* Enable the USART clock. */
   			AT91F_PMC_EnablePeriphClock( AT91C_BASE_PMC, 1 << AT91C_ID_US0 );

			AT91F_PIO_CfgPeriph( AT91C_BASE_PIOA, ( ( unsigned long ) AT91C_PA5_RXD0 ) | ( ( unsigned long ) AT91C_PA6_TXD0 ), serNO_PERIPHERAL_B_SETUP );

			/* Set the required protocol. */
			AT91F_US_Configure( serCOM0, configCPU_CLOCK_HZ, AT91C_US_ASYNC_MODE, ulWantedBaud, serNO_TIMEGUARD );

			/* Enable Rx and Tx. */
			serCOM0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

			/* Enable the Rx interrupts.  The Tx interrupts are not enabled
			until there are characters to be transmitted. */
    		AT91F_US_EnableIt( serCOM0, AT91C_US_RXRDY );

			/* Enable the interrupts in the AIC. */
			AT91F_AIC_ConfigureIt( AT91C_BASE_AIC, AT91C_ID_US0, serINTERRUPT_LEVEL, AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, ( void (*)( void ) ) vSerialISREntry );
			AT91F_AIC_EnableIt( AT91C_BASE_AIC, AT91C_ID_US0 );
		}
		portEXIT_CRITICAL();
	}
	else
	{
		xReturn = ( xComPortHandle ) 0;
	}

	/* This demo file only supports a single port but we have to return 
	something to comply with the standard demo header file. */
	return xReturn;
}
Exemplo n.º 5
0
Arquivo: dbgu.c Projeto: 12019/openpcd
//*----------------------------------------------------------------------------
//* \fn    AT91F_DBGU_Init
//* \brief This function is used to send a string through the DBGU channel (Very low level debugging)
//*----------------------------------------------------------------------------
void AT91F_DBGU_Init(void)
{
	unsigned int rst_status = AT91F_RSTGetStatus(AT91C_BASE_RSTC);

	dbgu_rb_init();

	//* Open PIO for DBGU
	AT91F_DBGU_CfgPIO();
	//* Enable Transmitter & receivier
	((AT91PS_USART) AT91C_BASE_DBGU)->US_CR =
	    AT91C_US_RSTTX | AT91C_US_RSTRX;

	//* Configure DBGU
	AT91F_US_Configure((AT91PS_USART) AT91C_BASE_DBGU,	// DBGU base address
			   MCK, AT91C_US_ASYNC_MODE,	// Mode Register to be programmed
			   AT91C_DBGU_BAUD,	// Baudrate to be programmed
			   0);	// Timeguard to be programmed

	//* Enable Transmitter & receivier
	((AT91PS_USART) AT91C_BASE_DBGU)->US_CR = AT91C_US_RXEN | AT91C_US_TXEN;

	//* Enable USART IT error and AT91C_US_ENDRX
	AT91F_US_EnableIt((AT91PS_USART) AT91C_BASE_DBGU, AT91C_US_RXRDY);

	//* open interrupt
	sysirq_register(AT91SAM7_SYSIRQ_DBGU, &DBGU_irq_handler);

	AT91F_DBGU_Printk("\n\r");
	AT91F_DBGU_Printk("(C) 2006-2011 by Harald Welte <*****@*****.**>\n\r"
			  "This software is FREE SOFTWARE licensed under GNU GPL\n\r");
	AT91F_DBGU_Printk("Version " COMPILE_SVNREV
			  " compiled " COMPILE_DATE
			  " by " COMPILE_BY "\n\r\n\r");
	AT91F_DBGU_Printk("\n\rDEBUG Interface:\n\r"
			  "0) Set Pull-up 1) Clear Pull-up 2) Toggle LED1 3) "
			  "Toggle LED2\r\n9) Reset\n\r");

	debugp("RSTC_SR=0x%08x\n", rst_status);
}
Exemplo n.º 6
0
Arquivo: usart.c Projeto: tsugli/stm32
//===============================================================================================
__inline void AT91F_US_INTERRUPT(AT91PS_USART COM,xQueueHandle *pxQueue,ErrorHandle *pxError)
{
    unsigned int status;
    unsigned int size;
    portBASE_TYPE  xTaskWokenByPost = pdFALSE;
    /* What caused the interrupt? */
    status = COM->US_CSR &= COM->US_IMR;
    if (status & (AT91C_US_RXBUFF | AT91C_US_FRAME | AT91C_US_PARE |AT91C_US_OVRE))
    {
        AT91F_US_DisableIt(COM, (status & (AT91C_US_RXBUFF | AT91C_US_FRAME | AT91C_US_PARE |AT91C_US_OVRE)));
    } else  {
        if ((status & AT91C_US_TIMEOUT ))
        {
            AT91F_US_DisableIt(COM, AT91C_US_TIMEOUT | AT91C_US_RXBUFF );
            AT91F_US_DisableRx(COM);
            size = (unsigned int)COM->US_RCR;
            xQueueSendFromISR( *pxQueue, &size, &xTaskWokenByPost );
        }
    }
    if (status & AT91C_US_ENDTX)
    {   // Data transmitted
        AT91F_US_DisableIt(COM, AT91C_US_ENDTX );
        AT91F_US_DisableTx(COM);
        AT91F_US_EnableIt(COM, AT91C_US_TXEMPTY );
    }
    if (status & AT91C_US_TXEMPTY)
    {
        size = (unsigned int)COM->US_TCR;
        xQueueSendFromISR( *pxQueue, &size, &xTaskWokenByPost );
        AT91F_US_DisableIt(COM, AT91C_US_TXEMPTY );
    }
    if( xTaskWokenByPost)
    {
        portYIELD_FROM_ISR();
    }
    AT91C_BASE_AIC->AIC_EOICR = 0;
}