예제 #1
0
uint32_t UARTD_DisableTxChannels( UartDma *pUartd, UartChannel *pTxCh)
{
	assert(pTxCh);
	
	/* Enables the USART to transfer data. */
	UART_SetTransmitterEnabled ( pUartd->pUartHw , DISABLE);
	
	XDMAD_StopTransfer(pUartd->pXdmad, pTxCh->ChNum);
	
	XDMAD_SetCallback(pUartd->pXdmad, pTxCh->ChNum, NULL, NULL);
	
	 /* Free allocated DMA channel for USART TX. */
	if(XDMAD_FreeChannel( pUartd->pXdmad, pTxCh->ChNum) != XDMAD_OK) {
	  return USARTD_ERROR;
	}
		
	if (pTxCh->dmaProgrammingMode == XDMAD_LLI) {
		free(pTxCh->pLLIview);
		pTxCh->pLLIview = NULL;
	}
	
	pTxCh->sempaphore = 1;
	memory_barrier();
	return 0;
}
예제 #2
0
파일: main.c 프로젝트: gstroe/Arm
/**
 * USART interrupt handler
 */
void USART2_Handler(void)
{
	Usart *pUs = BASE_USART;
	uint32_t status;
	uint16_t serialState;
	uint32_t count;

	status  = USART_GetStatus(pUs);
	status &= USART_GetItMask(pUs);

	/* If USB device is not configured, do nothing */
	if (!isCdcSerialON) {
		USART_DisableIt(pUs, 0xFFFFFFFF);
		return;
	}

	if (status & US_CSR_TIMEOUT) {
		/*Clear TIMEOUT Flag and Start Time-out After Next Character Received*/
		USART_AcknowledgeRxTimeOut(BASE_USART, 0);
		/* Flush the DMA FIFO */
		XDMAC_SoftwareFlushReq(dmad.pXdmacs, usartDmaRxChannel);
		/* Transfer the last pack through USB */
		count = dmad.pXdmacs->XDMAC_CHID[usartDmaRxChannel].XDMAC_CUBC;
		SCB_InvalidateDCache_by_Addr((uint32_t *)usartBuffers, DATAPACKETSIZE - count);

		while (CDCDSerialDriver_Write(usartBuffers, DATAPACKETSIZE - count, 0, 0)
			   != USBD_STATUS_SUCCESS);

		/*Reset DMA transfer*/
		XDMAD_StopTransfer(&dmad, usartDmaRxChannel);
		_UsartDmaRx();
	} else {
		/* Errors */
		serialState = CDCDSerialDriver_GetSerialState();

		/* Overrun */
		if ((status & US_CSR_OVRE) != 0) {
			TRACE_WARNING("USART_IrqHandler: Overrun\n\r");
			serialState |= CDCSerialState_OVERRUN;
		}

		/* Framing error */
		if ((status & US_CSR_FRAME) != 0) {
			TRACE_WARNING("USART_IrqHandler: Framing error\n\r");
			serialState |= CDCSerialState_FRAMING;
		}

		CDCDSerialDriver_SetSerialState(serialState);
	}
}
예제 #3
0
파일: usart_dma.c 프로젝트: RTEMS/rtems
/**
 * \brief This function disables the appropriate DMA channel for Rx channel of
 * USART
 * \param pUsartd       Pointer to a UsartDma instance.
 * \param pRxCh         Pointer to TxChannel configuration
 * \returns             0 if the transfer has been started successfully;
 * otherwise returns USARTD_ERROR_LOCK is the driver is in use, or
 * USARTD_ERROR if the command is not valid.
 */
uint32_t USARTD_DisableRxChannels(UsartDma *pUsartd, UsartChannel *pRxCh)
{
	assert(pRxCh);

	/* Enables the USART to transfer data. */
	USART_SetReceiverEnabled (pUsartd->pUsartHw , DISABLE);

	XDMAD_StopTransfer(pUsartd->pXdmad, pRxCh->ChNum);

	XDMAD_SetCallback(pUsartd->pXdmad, pRxCh->ChNum, NULL, NULL);

	/* Free allocated DMA channel for USART TX. */
	if (XDMAD_FreeChannel(pUsartd->pXdmad, pRxCh->ChNum) != XDMAD_OK)
		return USARTD_ERROR;

	if (pRxCh->dmaProgrammingMode == XDMAD_LLI) {
		free(pRxCh->pLLIview);
		pRxCh->pLLIview = NULL;
	}

	pRxCh->dmaProgress = 1;
	return 0;
}