Example #1
0
static void scsiPhyInitDMA()
{
	// One-time init only.
	if (scsiDmaTxChan == CY_DMA_INVALID_CHANNEL)
	{
		scsiDmaRxChan =
			SCSI_RX_DMA_DmaInitialize(
				1, // Bytes per burst
				1, // request per burst
				HI16(CYDEV_PERIPH_BASE),
				HI16(CYDEV_SRAM_BASE)
				);

		scsiDmaTxChan =
			SCSI_TX_DMA_DmaInitialize(
				1, // Bytes per burst
				1, // request per burst
				HI16(CYDEV_SRAM_BASE),
				HI16(CYDEV_PERIPH_BASE)
				);

		CyDmaChDisable(scsiDmaRxChan);
		CyDmaChDisable(scsiDmaTxChan);

		scsiDmaRxTd[0] = CyDmaTdAllocate();
		scsiDmaTxTd[0] = CyDmaTdAllocate();

		SCSI_RX_DMA_COMPLETE_StartEx(scsiRxCompleteISR);
		SCSI_TX_DMA_COMPLETE_StartEx(scsiTxCompleteISR);
	}
}
Example #2
0
void scsiPhyReset()
{
	trace(trace_scsiPhyReset);
	if (dmaInProgress)
	{
		dmaInProgress = 0;
		dmaBuffer = NULL;
		dmaSentCount = 0;
		dmaTotalCount = 0;
		CyDmaChSetRequest(scsiDmaTxChan, CY_DMA_CPU_TERM_CHAIN);
		CyDmaChSetRequest(scsiDmaRxChan, CY_DMA_CPU_TERM_CHAIN);

		// CyDmaChGetRequest returns 0 for the relevant bit once the
		// request is completed.
		trace(trace_spinDMAReset);
		while (
			(CyDmaChGetRequest(scsiDmaTxChan) & CY_DMA_CPU_TERM_CHAIN) &&
			!scsiTxDMAComplete
			)
		{}

		while ((
			CyDmaChGetRequest(scsiDmaRxChan) & CY_DMA_CPU_TERM_CHAIN) &&
			!scsiRxDMAComplete
			)
		{}

		CyDelayUs(1);

		CyDmaChDisable(scsiDmaTxChan);
		CyDmaChDisable(scsiDmaRxChan);
	}

	// Set the Clear bits for both SCSI device FIFOs
	scsiTarget_AUX_CTL = scsiTarget_AUX_CTL | 0x03;

	// Trigger RST outselves.  It is connected to the datapath and will
	// ensure it returns to the idle state.  The datapath runs at the BUS clk
	// speed (ie. same as the CPU), so we can be sure it is active for a sufficient
	// duration.
	SCSI_RST_ISR_Disable();
	SCSI_SetPin(SCSI_Out_RST);

	SCSI_CTL_PHASE_Write(0);
	SCSI_ClearPin(SCSI_Out_ATN);
	SCSI_ClearPin(SCSI_Out_BSY);
	SCSI_ClearPin(SCSI_Out_ACK);
	SCSI_ClearPin(SCSI_Out_RST);
	SCSI_ClearPin(SCSI_Out_SEL);
	SCSI_ClearPin(SCSI_Out_REQ);

	// Allow the FIFOs to fill up again.
	SCSI_ClearPin(SCSI_Out_RST);
	SCSI_RST_ISR_Enable();
	scsiTarget_AUX_CTL = scsiTarget_AUX_CTL & ~(0x03);

	SCSI_Parity_Error_Read(); // clear sticky bits
}
Example #3
0
/****************************************************************************
* Function Name: OSC1_ADC_SAR_Disable()
*****************************************************************************
*
* Summary:
*  Disables the component without disabling the ADC SAR.
*
* Parameters:
*  None.
*
* Return:
*  None.
*
* Side Effects:
*  None.
*
* Reentrant:
*  No.
*
****************************************************************************/
void OSC1_ADC_SAR_Disable(void)
{
    OSC1_ADC_SAR_CONTROL_REG &= ((uint8)(~OSC1_ADC_SAR_BASE_COMPONENT_ENABLE));

    (void) CyDmaChDisable(OSC1_ADC_SAR_tempChan);
    CyDmaTdFree(OSC1_ADC_SAR_tempTD);
    OSC1_ADC_SAR_tempTD = CY_DMA_INVALID_TD;

    (void) CyDmaChDisable(OSC1_ADC_SAR_finalChan);
    CyDmaTdFree(OSC1_ADC_SAR_finalTD);
    OSC1_ADC_SAR_finalTD = CY_DMA_INVALID_TD;
}
Example #4
0
/*******************************************************************************
* Function Name: WaveDAC8_1_Stop
********************************************************************************
*
* Summary:
*  Stops the clock (if internal), disables the DMA channels
*  and powers down the DAC.
*
* Parameters:
*  None
*
* Return:
*  None
*
*******************************************************************************/
void WaveDAC8_1_Stop(void)
{
    /* Turn off internal clock, if one present */
#if(WaveDAC8_1_CLOCK_SRC == WaveDAC8_1_CLOCK_INT)
    WaveDAC8_1_DacClk_Stop();
#endif /* WaveDAC8_1_CLOCK_SRC == WaveDAC8_1_CLOCK_INT */

    /* Disble DMA channels */
    (void)CyDmaChDisable(WaveDAC8_1_Wave1Chan);
    (void)CyDmaChDisable(WaveDAC8_1_Wave2Chan);

    /* Disable power to DAC */
    WaveDAC8_1_VDAC8_Stop();
}
Example #5
0
/*******************************************************************************
* Function Name: E_F_Stop
********************************************************************************
*
* Summary:
*  Stops the clock (if internal), disables the DMA channels
*  and powers down the DAC.
*
* Parameters:  
*  None  
*
* Return: 
*  None
*
*******************************************************************************/
void E_F_Stop(void) 
{
	/* Turn off internal clock, if one present */
	#if(E_F_CLOCK_SRC == E_F_CLOCK_INT)  	
	   E_F_DacClk_Stop();
	#endif /* E_F_CLOCK_SRC == E_F_CLOCK_INT */
	
	/* Disble DMA channels */
	(void)CyDmaChDisable(E_F_Wave1Chan);
	(void)CyDmaChDisable(E_F_Wave2Chan);

	/* Disable power to DAC */
	E_F_VDAC8_Stop();
}
Example #6
0
 /*******************************************************************************
 * Function Name: USBFS_1_Stop_DMA
 ********************************************************************************
 *
 * Summary: Stops and free DMA
 *
 * Parameters:
 *  epNumber: Contains the data endpoint number or
 *           USBFS_1_MAX_EP to stop all DMAs
 *
 * Return:
 *  None.
 *
 * Reentrant:
 *  No.
 *
 *******************************************************************************/
 void USBFS_1_Stop_DMA(uint8 epNumber) 
 {
     uint8 i;
     i = (epNumber < USBFS_1_MAX_EP) ? epNumber : USBFS_1_EP1;
     do
     {
         if(USBFS_1_DmaTd[i] != DMA_INVALID_TD)
         {
             (void) CyDmaChDisable(USBFS_1_DmaChan[i]);
             CyDmaTdFree(USBFS_1_DmaTd[i]);
             USBFS_1_DmaTd[i] = DMA_INVALID_TD;
         }
         i++;
     }while((i < USBFS_1_MAX_EP) && (epNumber == USBFS_1_MAX_EP));
 }
/*********************************************************************
* Function Name: void WaveDAC8_4_Wave1_DMA_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with WaveDAC8_4_Wave1_DMA.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void WaveDAC8_4_Wave1_DMA_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(WaveDAC8_4_Wave1_DMA_DmaHandle);
}
/*********************************************************************
* Function Name: void USBFS_ep2_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with USBFS_ep2.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void USBFS_ep2_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(USBFS_ep2_DmaHandle);
}
/*********************************************************************
* Function Name: void PDM_CIC_DMA_IntOut_R_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with PDM_CIC_DMA_IntOut_R.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void PDM_CIC_DMA_IntOut_R_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(PDM_CIC_DMA_IntOut_R_DmaHandle);
}
Example #10
0
/*********************************************************************
* Function Name: void DMA_RX_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with DMA_RX.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void DMA_RX_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(DMA_RX_DmaHandle);
}
/*********************************************************************
* Function Name: void ADC_SAR_Seq_2_TempBuf_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with ADC_SAR_Seq_2_TempBuf.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void ADC_SAR_Seq_2_TempBuf_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(ADC_SAR_Seq_2_TempBuf_DmaHandle);
}
Example #12
0
/*********************************************************************
* Function Name: void CICOut_L_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with CICOut_L.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void CICOut_L_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(CICOut_L_DmaHandle);
}
/*********************************************************************
* Function Name: void ADC_SAR_FinalBuf_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with ADC_SAR_FinalBuf.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void ADC_SAR_FinalBuf_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(ADC_SAR_FinalBuf_DmaHandle);
}
/*********************************************************************
* Function Name: void APPS_ADC_TempBuf_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with APPS_ADC_TempBuf.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void APPS_ADC_TempBuf_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(APPS_ADC_TempBuf_DmaHandle);
}
/*********************************************************************
* Function Name: void PDM_CIC_DMA_CombD0Update_L_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with PDM_CIC_DMA_CombD0Update_L.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void PDM_CIC_DMA_CombD0Update_L_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(PDM_CIC_DMA_CombD0Update_L_DmaHandle);
}
Example #16
0
/*********************************************************************
* Function Name: void USBUART_ep3_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with USBUART_ep3.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void USBUART_ep3_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(USBUART_ep3_DmaHandle);
}
/*********************************************************************
* Function Name: void NSDSPI_RX_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with NSDSPI_RX.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void NSDSPI_RX_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(NSDSPI_RX_DmaHandle);
}
Example #18
0
/*******************************************************************************
* Function Name: USBFS_1_LoadInEP
********************************************************************************
*
* Summary:
*  Loads and enables the specified USB data endpoint for an IN interrupt or bulk
*  transfer.
*
* Parameters:
*  epNumber: Contains the data endpoint number.
*            Valid values are between 1 and 8.
*  *pData: A pointer to a data array from which the data for the endpoint space
*          is loaded.
*  length: The number of bytes to transfer from the array and then send as a
*          result of an IN request. Valid values are between 0 and 512.
*
* Return:
*  None.
*
* Reentrant:
*  No.
*
*******************************************************************************/
void USBFS_1_LoadInEP(uint8 epNumber, const uint8 pData[], uint16 length)
                                                                        
{
    uint8 ri;
    reg8 *p;
    #if(USBFS_1_EP_MM == USBFS_1__EP_MANUAL)
        uint16 i;
    #endif /* End USBFS_1_EP_MM == USBFS_1__EP_MANUAL */

    if((epNumber > USBFS_1_EP0) && (epNumber < USBFS_1_MAX_EP))
    {
        ri = ((epNumber - USBFS_1_EP1) << USBFS_1_EPX_CNTX_ADDR_SHIFT);
        p = (reg8 *)(USBFS_1_ARB_RW1_DR_IND + ri);

        #if(USBFS_1_EP_MM != USBFS_1__EP_DMAAUTO)
            /* Limits length to available buffer space, auto MM could send packets up to 1024 bytes */
            if(length > (USBFS_1_EPX_DATA_BUF_MAX - USBFS_1_EP[epNumber].buffOffset))
            {
                length = USBFS_1_EPX_DATA_BUF_MAX - USBFS_1_EP[epNumber].buffOffset;
            }
        #endif /* End USBFS_1_EP_MM != USBFS_1__EP_DMAAUTO */

        /* Set the count and data toggle */
        CY_SET_REG8((reg8 *)(USBFS_1_SIE_EP1_CNT0_IND + ri),
                            (length >> 8u) | (USBFS_1_EP[epNumber].epToggle));
        CY_SET_REG8((reg8 *)(USBFS_1_SIE_EP1_CNT1_IND + ri),  length & 0xFFu);

        #if(USBFS_1_EP_MM == USBFS_1__EP_MANUAL)
            if(pData != NULL)
            {
                /* Copy the data using the arbiter data register */
                for (i = 0u; i < length; i++)
                {
                    CY_SET_REG8(p, pData[i]);
                }
            }
            USBFS_1_EP[epNumber].apiEpState = USBFS_1_NO_EVENT_PENDING;
            /* Write the Mode register */
            CY_SET_REG8((reg8 *)(USBFS_1_SIE_EP1_CR0_IND + ri), USBFS_1_EP[epNumber].epMode);
        #else
            /* Init DMA if it was not initialized */
            if(USBFS_1_DmaTd[epNumber] == DMA_INVALID_TD)
            {
                USBFS_1_InitEP_DMA(epNumber, pData);
            }
        #endif /* End USBFS_1_EP_MM == USBFS_1__EP_MANUAL */

        #if(USBFS_1_EP_MM == USBFS_1__EP_DMAMANUAL)
            USBFS_1_EP[epNumber].apiEpState = USBFS_1_NO_EVENT_PENDING;
            if((pData != NULL) && (length > 0u))
            {
                /* Enable DMA in mode2 for transferring data */
                (void) CyDmaChDisable(USBFS_1_DmaChan[epNumber]);
                (void) CyDmaTdSetConfiguration(USBFS_1_DmaTd[epNumber], length, CY_DMA_DISABLE_TD,
                                                                                 TD_TERMIN_EN | TD_INC_SRC_ADR);
                (void) CyDmaTdSetAddress(USBFS_1_DmaTd[epNumber],  LO16((uint32)pData), LO16((uint32)p));
                /* Enable the DMA */
                (void) CyDmaChSetInitialTd(USBFS_1_DmaChan[epNumber], USBFS_1_DmaTd[epNumber]);
                (void) CyDmaChEnable(USBFS_1_DmaChan[epNumber], 1u);
                /* Generate DMA request */
                * (reg8 *)(USBFS_1_ARB_EP1_CFG_IND + ri) |= USBFS_1_ARB_EPX_CFG_DMA_REQ;
                * (reg8 *)(USBFS_1_ARB_EP1_CFG_IND + ri) &= ((uint8)(~USBFS_1_ARB_EPX_CFG_DMA_REQ));
                /* Mode register will be written in arb ISR after DMA transfer complete */
            }
            else
            {
                /* When zero-length packet - write the Mode register directly */
                CY_SET_REG8((reg8 *)(USBFS_1_SIE_EP1_CR0_IND + ri), USBFS_1_EP[epNumber].epMode);
            }
        #endif /* End USBFS_1_EP_MM == USBFS_1__EP_DMAMANUAL */

        #if(USBFS_1_EP_MM == USBFS_1__EP_DMAAUTO)
            if(pData != NULL)
            {
                /* Enable DMA in mode3 for transferring data */
                (void) CyDmaChDisable(USBFS_1_DmaChan[epNumber]);
                (void) CyDmaTdSetConfiguration(USBFS_1_DmaTd[epNumber], length,
                                               USBFS_1_DmaTd[epNumber], TD_TERMIN_EN | TD_INC_SRC_ADR);
                (void) CyDmaTdSetAddress(USBFS_1_DmaTd[epNumber],  LO16((uint32)pData), LO16((uint32)p));
                /* Clear Any potential pending DMA requests before starting the DMA channel to transfer data */
                (void) CyDmaClearPendingDrq(USBFS_1_DmaChan[epNumber]);
                /* Enable the DMA */
                (void) CyDmaChSetInitialTd(USBFS_1_DmaChan[epNumber], USBFS_1_DmaTd[epNumber]);
                (void) CyDmaChEnable(USBFS_1_DmaChan[epNumber], 1u);
            }
            else
            {
                USBFS_1_EP[epNumber].apiEpState = USBFS_1_NO_EVENT_PENDING;
                if(length > 0u)
                {
                    /* Set Data ready status, This will generate DMA request */
                    * (reg8 *)(USBFS_1_ARB_EP1_CFG_IND + ri) |= USBFS_1_ARB_EPX_CFG_IN_DATA_RDY;
                    /* Mode register will be written in arb ISR(In Buffer Full) after first DMA transfer complete */
                }
                else
                {
                    /* When zero-length packet - write the Mode register directly */
                    CY_SET_REG8((reg8 *)(USBFS_1_SIE_EP1_CR0_IND + ri), USBFS_1_EP[epNumber].epMode);
                }
            }
        #endif /* End USBFS_1_EP_MM == USBFS_1__EP_DMAAUTO */

    }
Example #19
0
/*********************************************************************
* Function Name: void Buf0_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with Buf0.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void Buf0_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(Buf0_DmaHandle);
}
/*********************************************************************
* Function Name: void MultAcc_1_DMA_IN_B_DmaRelease
**********************************************************************
* Summary:
*   Frees the channel associated with MultAcc_1_DMA_IN_B.
*
*
* Parameters:
*   void.
*
*
*
* Return:
*   void.
*
*******************************************************************/
void MultAcc_1_DMA_IN_B_DmaRelease(void) 
{
    /* Disable the channel */
    (void)CyDmaChDisable(MultAcc_1_DMA_IN_B_DmaHandle);
}