?? coms_sencor.c
字號:
#include "I2C.h"
EX_INTERRUPT_HANDLER(DMA0_PPI_ISR);
void Init_EBIU(void);
void Init_CPLD(void);
void Init_PLL(void);
void Init_SDRAM(void);
void Init_PPI(void);
void Init_DMA(void);
unsigned short PPI_DMA_DONE;
unsigned char dataIn[40];
main()
{
int o = 0;
bool ret = true;
Set_PLL( (short)(CORECLK/CLKIN), (short)(CORECLK/SYSCLK));
Init_EBIU();
//Initial Interrupt
register_handler(ik_ivg8,DMA0_PPI_ISR);
*pSICB_IMASK0 = 0x00000800;
Init_CPLD();
/*
I2C_Init(MT9V11X_IDENT_W);
I2C_Read(&dataIn[0],&dataIn[1],0x00);
I2C_Read(&dataIn[2],&dataIn[3],0xc8);
I2C_Write(0x00,0x01,0xf0);
I2C_Read(&dataIn[4],&dataIn[5],0xf0);
I2C_Write(0x0a,0x00,0x3a);
I2C_Write(0x0a,0x00,0x9b);
//I2C_Write(0x02,0x80,0xa7);
I2C_Write(0x01,0x40,0xa7);
//I2C_Write(0x01,0xe0,0xaa);
I2C_Write(0x00,0xf0,0xaa);
//I2C_Write(0x04,0x80,0x08);
I2C_Read(&dataIn[6],&dataIn[7],0x3a);
I2C_Read(&dataIn[8],&dataIn[9],0x08);
I2C_Write(0x00,0x02,0xf0);
I2C_Write(0x80,0x00,0xc8);
I2C_Write(0x00,0x00,0xf0);
I2C_Read(&dataIn[10],&dataIn[11],0x05);
if((dataIn[0] != 0x12) || (dataIn[1] != 0x29))
{
while(1);
}
*/
I2C_Init(MT9V111_IDENT_W);
I2C_Write(0x00,0x04,0x01);//CORE
//I2C_Write(0x01,0x28,0x03);
//I2C_Write(0x01,0x6c,0x04);
//I2C_Write(0x30,0x02,0x07);
I2C_Read(&dataIn[0],&dataIn[1],0x36);
I2C_Read(&dataIn[2],&dataIn[3],0x03);
I2C_Read(&dataIn[4],&dataIn[5],0x04);
I2C_Read(&dataIn[6],&dataIn[7],0x07);
I2C_Write(0x00,0x01,0x01);//ifp
I2C_Write(0x01,0x60,0xa7);
I2C_Write(0x01,0x20,0xaa);
I2C_Read(&dataIn[8],&dataIn[9],0x08);
if((dataIn[0] != 0x82) || (dataIn[1] != 0x3a))
{
while(1);
}
Init_DMA();
Init_PPI();
*pDMA1_0_CONFIG = *pDMA1_0_CONFIG | 0x0001;
ssync();
*pPPI0_CONTROL = *pPPI0_CONTROL | 0x0001;
ssync();
*pTIMER8_CONFIG = 0x0003;
asm("ssync;");
*pTIMER9_CONFIG = 0x0003;
asm("ssync;");
*pTMRS4_ENABLE = 0x0003;
asm("ssync;");
while(1);
}
void Init_CPLD(void)
{
int i;
*pCtrlReg1_S= 0x18;
for(i = 0;i < 10000;i++);
*pLED = 0x0;
for(i = 0;i < 10000;i++);
}
void Init_EBIU(void)
{
*pEBIU_AMBCTL0 = 0x7bb07bb0; // <--|Write access time = 7 cycles, read access time = 11 cycles, no ARDY
*pEBIU_AMBCTL1 = 0x7bb07bb0; // |Hold time = 2 cycles, setup time = 3 cycles, transition time = 4 cycles
*pEBIU_AMGCTL = 0x00fF; // |Enable all memory banks
}//end Init_EBIU
void Init_PPI(void)
{
*pPPI0_FRAME = 500 ;
// *pPPI0_COUNT = 1279;
*pPPI0_COUNT = 703;
*pPPI0_DELAY = 0;
*pPPI0_CONTROL = 0x001c;
}
void Init_DMA(void)
{
//Target address of the DMA
*pDMA1_0_START_ADDR = 0x0;
//RAM_Length 32bit transfers will be executed
//*pDMA1_0_X_COUNT = 1280;
*pDMA1_0_X_COUNT = 352;
//The modifier is set to 4 because of the 32bit transfers
*pDMA1_0_X_MODIFY = 0x1;
*pDMA1_0_Y_COUNT = 1000;
*pDMA1_0_Y_MODIFY = 0x1;
//PPI Peripheral is used
*pDMA1_0_PERIPHERAL_MAP = 0x0;
//DMA Config: Enable DMA | Memory write DMA | Discard DMA FIFO before start | enable assertation of interrupt | NDSIZE for stop mode | Enable STOP DMA
//Enable 2D-DMA
*pDMA1_0_CONFIG = 0x00b2;//0x00ba;
//*pDMA0_CONFIG = DMAEN | DI_EN | WNR | WDSIZE_32 | RESTART | DMA2D ;//| DI_SEL;
}//end Init_DMA
EX_INTERRUPT_HANDLER(DMA0_PPI_ISR) // <--|declaration in exception.h -->
{
//disable the interrupt request
*pDMA1_0_IRQ_STATUS = 0x1; // to clear interrupt bit
//temp2 = *pPPI_CONTROL;
*pPPI0_CONTROL &= 0xfffe;
printf( "\nThe DMA0 PPI Interrupt has been entered!\n" );
// PPI_DMA_DONE = 1;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -