高级会员
- 积分
- 744
- 威望
- 384
- 贡献
- 222
- 兑换币
- 246
- 注册时间
- 2014-3-16
- 在线时间
- 69 小时
- 毕业学校
- 国防科大
|
//============================================================================
//函数名称:Startintegration
//函数返回:无
//参数说明:无
//功能概要:初始化CCD第一帧
//============================================================================
void StartIntegration(void)
{
unsigned char i;
//CCD_SI_Change(); /* SI = 1 */
hw_gpio_set(CCD1_SI_PORT,CCD1_SI_PIN,1);
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
//CCD_SI_Change(); /* SI = 0 */
hw_gpio_set(CCD1_SI_PORT,CCD1_SI_PIN,0);
delay2;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
for(i=0; i<127; i++)
{
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
}
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
}
//============================================================================
//函数名称:ImageCapture
//函数返回:无
//参数说明:uint8 * ImageData CCD数据指针
//功能概要:CCD采集
//============================================================================
void ImageCapture(uint8 * ImageData)
{
unsigned char i;
extern uint8 AtemP ;
//CCD_SI_Change(); /* SI = 1 */
hw_gpio_set(CCD1_SI_PORT,CCD1_SI_PIN,1);
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
//CCD_SI_Change(); /* SI = 0 */
hw_gpio_set(CCD1_SI_PORT,CCD1_SI_PIN,0);
delay2;
//Delay 10us for sample the first pixel
/**/
for(i = 0; i < 50; i++)
{
delay2; //200ns
}
//Sampling Pixel 1
*ImageData = hw_adc_once(CCD_1_MoudelNumber,CCD_1_Channel,8);
ImageData ++ ;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
for(i=0; i<127; i++)
{
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
delay2;
//Sampling Pixel 2~128
*ImageData = hw_adc_once(CCD_1_MoudelNumber,CCD_1_Channel,8);
ImageData ++ ;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
}
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 1 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,1);
delay2;
delay2;
//CCD_CLK_Change(); /* CLK = 0 */
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
}
hw_gpio_set(CCD1_CLK_PORT,CCD1_CLK_PIN,0);
uint8 hw_gpio_set(
uint8 port, //端口号。由宏定义。
uint8 pin, //引脚号。0~31。
uint8 state //引脚初始状态。1=高电平,0=低电平
)
{
//将GPIO端口号转换成端口寄存器组指针
GPIO_MemMapPtr pt = hw_gpio_get_pt_addr(port);
if (state == 0) //控制为低电平
GPIO_PDOR_REG(pt) &= ~(1<<pin);
else //控制为高电平
GPIO_PDOR_REG(pt) |= (1<<pin);
return 0;
}
|
|