用I2C进行传感器的寄存器配置,这段代码是放在固件框架的periph.c里吗? 具体是void TD_Init(void)、void TD_Poll(void)、BOOL DR_VendorCmnd(void)三个中哪里,还是另外写个C程序再调用什么的?求具体方法或相似的例程也行。比如下面这段 MT9D112传感器的配置代码,它是放在periph.c 的那个函数里
// 复位操作
BYTE xdata rst[4]={0x30,0x1A,0x0A 0xCC};
EZUSB_InitI2C();
EZUSB_WriteI2C(0x3C,0x04,rst );
// 设置为满分辨率
BYTE xdata buffer[4] ;
// 设置输出宽为1600:
buffer[0] = 0x33;
buffer[1] = 0x8C;
buffer[2] = 0xA7;
buffer[3] = 0x07;
EZUSB_WriteI2C( 0x3C, 0x04, buffer );
buffer[0] = 0x33;
buffer[1] = 0x90;
buffer[2] = 0x06;
buffer[3] = 0x40;
EZUSB_WriteI2C( 0x3C, 0x04, buffer );
// 设置输出高为1200:
buffer[0] = 0x33;
buffer[1] = 0x8C;
buffer[2] = 0xA7;
buffer[3] = 0x09;
EZUSB_WriteI2C( 0x3C, 0x04, buffer );
buffer[0] = 0x33;
buffer[1] = 0x90;
buffer[2] = 0x04;
buffer[3] = 0xB0;
EZUSB_WriteI2C( 0x3C, 0x04, buffer );
……
|