Exemple #1
0
void Camera_Start()
{
	Camera_SIOD_SetDriveMode(Camera_SIOD_DM_RES_UP); //turn on pull-up resistors on I2C pins
	Camera_SIOC_SetDriveMode(Camera_SIOC_DM_RES_UP);
	Camera_I2C_Start();
	
	Camera_WriteReg(0x12,0x80); //reset
	CyDelay(1);
	uint16 i;
	for(i=0;Camera_settings[i][0]!=0xff;i++) Camera_WriteReg(Camera_settings[i][0],Camera_settings[i][1]); //camera settings
	for(i=0;Camera_format[i]!=0xff;i++) Camera_WriteReg(Camera_format[i],Camera_qcif[i]); //qcif format (176x144)
	
	uint8 (*buffer)[BUFFER_SIZE]=(uint8(*)[BUFFER_SIZE])Camera_framebuffer; //recast buffer for easier arithmetic
	DMA_channel=Camera_DMA_DmaInitialize(1,1,HI16(CYDEV_PERIPH_BASE),HI16(CYDEV_SRAM_BASE)); //peripheral -> SRAM
	for(i=0;i<sizeof DMA_TD;i++) //set up TDs
	{
		DMA_TD[i]=CyDmaTdAllocate();
		CyDmaTdSetAddress(DMA_TD[i],LO16(Camera_FIFO_dp__F0_REG),LO16((uint32)buffer[i]));
		if(i) CyDmaTdSetConfiguration(DMA_TD[i-1],BUFFER_SIZE,DMA_TD[i],TD_INC_DST_ADR);
	}
	CyDmaChPriority(DMA_channel,0); //ensure highest priority for DMA channel
}
Exemple #2
0
/*********************************************************************
* Function Name: uint8 Buf0_DmaInitalize
**********************************************************************
* Summary:
*   Allocates and initialises a channel of the DMAC to be used by the
*   caller.
*
* Parameters:
*   BurstCount.
*       
*       
*   ReqestPerBurst.
*       
*       
*   UpperSrcAddress.
*       
*       
*   UpperDestAddress.
*       
*
* Return:
*   The channel that can be used by the caller for DMA activity.
*   DMA_INVALID_CHANNEL (0xFF) if there are no channels left. 
*
*
*******************************************************************/
uint8 Buf0_DmaInitialize(uint8 BurstCount, uint8 ReqestPerBurst, uint16 UpperSrcAddress, uint16 UpperDestAddress) 
{

    /* Allocate a DMA channel. */
    Buf0_DmaHandle = (uint8)Buf0__DRQ_NUMBER;

    /* Configure the channel. */
    (void)CyDmaChSetConfiguration(Buf0_DmaHandle,
                                  BurstCount,
                                  ReqestPerBurst,
                                  (uint8)Buf0__TERMOUT0_SEL,
                                  (uint8)Buf0__TERMOUT1_SEL,
                                  (uint8)Buf0__TERMIN_SEL);

    /* Set the extended address for the transfers */
    (void)CyDmaChSetExtendedAddress(Buf0_DmaHandle, UpperSrcAddress, UpperDestAddress);

    /* Set the priority for this channel */
    (void)CyDmaChPriority(Buf0_DmaHandle, (uint8)Buf0__PRIORITY);
    
    return Buf0_DmaHandle;
}