最大転送スループットは、800MBytes/sec なので、半分近くにまで落ちている。(1回の転送バイト数)8 バイト x 100(MHz) x 64/105 ≒ 488(MBytes/sec)
/* * cam_disp3.c * * Created on: 2013/02/01 * Author: Masaaki */
#include "xparameters.h"
#include "xgpio.h"
void cam_iic_init(void) {
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x100), 0x002); // reset tx fifo
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x100), 0x001); // enable iic
}
void cam_iic_write(u32 device_addr, u32 write_addr, u32 write_data) {
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), (0x100 | (device_addr & 0xfe))); // Slave IIC Write Address
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), write_addr); // address
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), ((write_data >> 8)|0xff)); // first data
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), (0x200 | (write_data & 0xff))); // second data
cam_iic_write_sync();
}
void cam_iic_write_sync(void) {
while ((Xil_In32(XPAR_AXI_IIC_MT9D111_BASEADDR + 0x104) & 0x84) != 0x80) ; // No Bus Busy and TX_FIFO_Empty = 1
}
u32 cam_iic_read(u32 device_addr, u32 read_addr) {
u32 read_data;
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), (0x100 | (device_addr & 0xfe))); // Slave IIC Write Address
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), read_addr); // address
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), (0x101 | device_addr)); // Slave IIC Read Address
Xil_Out32((XPAR_AXI_IIC_MT9D111_BASEADDR + 0x108), 0x202); // 2 bytes data
while ((Xil_In32(XPAR_AXI_IIC_MT9D111_BASEADDR + 0x104) & 0x40) == 0x40) ;
read_data = Xil_In32(XPAR_AXI_IIC_MT9D111_BASEADDR + 0x10c) & 0xff;
read_data = read_data<<8 | (Xil_In32(XPAR_AXI_IIC_MT9D111_BASEADDR + 0x10c) & 0xff);
return(read_data);
}
int main()
{
static XGpio GPIOInstance_Ptr;
int xStatus;
// AXI GPIO Initialization
xStatus = XGpio_Initialize(&GPIOInstance_Ptr,XPAR_AXI_GPIO_0_DEVICE_ID);
if(XST_SUCCESS != xStatus)
print("GPIO INIT FAILED\n\r");
// AXI GPIO Set the Direction(Output setting)
XGpio_SetDataDirection(&GPIOInstance_Ptr, 1, 0);
// init_doneに1を出力
XGpio_DiscreteWrite(&GPIOInstance_Ptr, 1, 1);
// CMOS Camera initialize, MT9D111
// デフォルト値だったので設定を止めた
cam_iic_init();
cam_iic_write(0xba, 0xf0, 0x1); // IFP page 1 へレジスタ・マップを切り替える
cam_iic_write(0xba, 0x97, 0x20); // RGB Mode, RGB565
//cam_iic_write(0xba, 0xf0, 0x0); // Sensor Resigter へレジスタ・マップを切り替える
//regval = cam_iic_read(0xbb, 0x20, 1);
//cam_iic_write(0xba, 0x20, (regval | 0x1)); // Read out rows from bottom to top (upside down).
//cam_iic_write(0xba, 0x01, 0x4EB); // Row Start (row start + row size -1)
cam_iic_write_sync();
return 0;
}
日 | 月 | 火 | 水 | 木 | 金 | 土 |
---|---|---|---|---|---|---|
- | - | - | - | - | 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 | - | - | - | - | - | - |