📄 tw2834.c.bak
字号:
* Set the pic size of each channel for the record path.
* @param ch: channel number
* @param pos: the size of the channel (can be 0 1 2 3)
* @return value: null.
*/
static void tw2834_set_record_pic_size(unsigned char ch, unsigned char size)
{
unsigned char byte_tmp;
if(ch > 3 || size > 3)
{
printf("\tTW2834_ERROR: Channel number or size input error\n");
return;
}
byte_tmp = tw2834_read_byte(PAGE1, REG_PIC_SIZE);
CLEAR_BIT(byte_tmp, (3 << (ch << 1)));
SET_BIT(byte_tmp, (size << (ch << 1)));
tw2834_write_byte(PAGE1, REG_PIC_SIZE, byte_tmp);
}
/*
* Set the operation mode of each channel for the record path.
* @param op_mod: operation mode (can be FUNC_MODE_LIVE/STROBE/SWITCH )
* @return value: null.
*/
static void tw2834_set_op_mode(unsigned char op_mod)
{
unsigned char byte_tmp;
unsigned char byte_op_mod;
byte_op_mod = op_mod << 4;
/*set switch mod for record path channel 0*/
byte_tmp = tw2834_read_byte(PAGE1, 0x60);
CLEAR_BIT(byte_tmp, 0x30);
SET_BIT(byte_tmp, byte_op_mod);
tw2834_write_byte(PAGE1, 0x60, byte_tmp);
/*set switch mod for record path channel 1*/
byte_tmp = tw2834_read_byte(PAGE1, 0x63);
CLEAR_BIT(byte_tmp, 0x30);
SET_BIT(byte_tmp, byte_op_mod);
tw2834_write_byte(PAGE1, 0x63, byte_tmp);
/*set switch mod for record path channel 2*/
byte_tmp = tw2834_read_byte(PAGE1, 0x66);
CLEAR_BIT(byte_tmp, 0x30);
SET_BIT(byte_tmp, byte_op_mod);
tw2834_write_byte(PAGE1, 0x66, byte_tmp);
/*set switch mod for record path channel 3*/
byte_tmp = tw2834_read_byte(PAGE1, 0x69);
CLEAR_BIT(byte_tmp, 0x30);
SET_BIT(byte_tmp, byte_op_mod);
tw2834_write_byte(PAGE1, 0x69, byte_tmp);
}
/******************************************************************************/
/*
* Set the record path to frame quad mod.
* @return value: null.
*/
static void set_record_frame_quad(void)
{
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0x7fff, 0xffff);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*set record mod frame*/
tw2834_set_record_mod(1, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 0);
tw2834_set_record_pic_size(1, 0);
tw2834_set_record_pic_size(2, 0);
tw2834_set_record_pic_size(3, 0);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 1);
tw2834_set_record_pic_pos(2, 2);
tw2834_set_record_pic_pos(3, 3);
}
/*
* Set the record path to normal quad mod.
* @return value: null.
*/
static void set_record_normal_quad(void)
{
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0x7fff, 0x7fff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0x7fff, 0x7fff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0x7fff, 0x7fff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0x7fff, 0x7fff);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*set record mod normal*/
tw2834_set_record_mod(0, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 0);
tw2834_set_record_pic_size(1, 0);
tw2834_set_record_pic_size(2, 0);
tw2834_set_record_pic_size(3, 0);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 1);
tw2834_set_record_pic_pos(2, 2);
tw2834_set_record_pic_pos(3, 3);
}
/*
* Set the record path to normal full mod.
* @param ch: channel number
* @return value: null.
*/
static void set_record_normal_full(unsigned char ch)
{
unsigned char byte_tmp;
if(ch > 3)
{
printf("\tTW2834_ERROR: Channel number input error\n");
return;
}
/*select the input for channel 0*/
byte_tmp = tw2834_read_byte(PAGE1, 0x60);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, ch);
tw2834_write_byte(PAGE1, 0x60, byte_tmp);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0xffff, 0xffff);
/*set record mod normal*/
tw2834_set_record_mod(0, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 3);
tw2834_set_record_pic_size(1, 3);
tw2834_set_record_pic_size(2, 3);
tw2834_set_record_pic_size(3, 3);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 1);
tw2834_set_record_pic_pos(2, 2);
tw2834_set_record_pic_pos(3, 3);
}
/*
* Set the record path to half d1.
* @return value: null.
*/
static void set_record_2half_d1(void)
{
unsigned char byte_tmp;
/*select the input for channel 0 */
byte_tmp = tw2834_read_byte(PAGE1, 0x60);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, 0x00);
tw2834_write_byte(PAGE1, 0x60, byte_tmp);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*select the input for channel 1 */
byte_tmp = tw2834_read_byte(PAGE1, 0x63);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, 0x01);
tw2834_write_byte(PAGE1, 0x63, byte_tmp);
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0xffff, 0xffff);
/*set record mod frame*/
tw2834_set_record_mod(1, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 1);
tw2834_set_record_pic_size(1, 1);
tw2834_set_record_pic_size(2, 1);
tw2834_set_record_pic_size(3, 1);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 2);
tw2834_set_record_pic_pos(2, 1);
tw2834_set_record_pic_pos(3, 3);
}
/*
* Set the record path to normal 1cif mod.
* @param ch: channel number
* @return value: null.
*/
static void set_record_normal_1cif(unsigned char ch)
{
unsigned char byte_tmp;
if(ch > 3)
{
printf("\tTW2834_ERROR: Channel number input error\n");
return;
}
/*select the input for channel 0*/
byte_tmp = tw2834_read_byte(PAGE1, 0x60);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, ch);
tw2834_write_byte(PAGE1, 0x60, byte_tmp);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0x7fff, 0xffff);
/*set record mod normal*/
tw2834_set_record_mod(0, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 2);
tw2834_set_record_pic_size(1, 2);
tw2834_set_record_pic_size(2, 2);
tw2834_set_record_pic_size(3, 2);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 0);
tw2834_set_record_pic_pos(2, 0);
tw2834_set_record_pic_pos(3, 0);
}
/*
* Set the record path to normal 2cif mod.
* @param ch: channel number
* @return value: null.
*/
static void set_record_normal_2cif(void)
{
unsigned char byte_tmp;
/*select the input for channel 0 */
byte_tmp = tw2834_read_byte(PAGE1, 0x60);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, 0x00);
tw2834_write_byte(PAGE1, 0x60, byte_tmp);
/*set live mod for record path */
tw2834_set_op_mode(FUNC_MODE_LIVE);
/*select the input for channel 1 */
byte_tmp = tw2834_read_byte(PAGE1, 0x63);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, 0x01);
tw2834_write_byte(PAGE1, 0x63, byte_tmp);
/*set vin scaling*/
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0x7fff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0x7fff, 0xffff);
/*set record mod normal*/
tw2834_set_record_mod(0, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 2);
tw2834_set_record_pic_size(1, 2);
tw2834_set_record_pic_size(2, 2);
tw2834_set_record_pic_size(3, 2);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 1);
tw2834_set_record_pic_pos(2, 0);
tw2834_set_record_pic_pos(3, 0);
}
/*
* set record path switch mode
* @param period: switch period(count of field)
* @return value: null.
*/
static void set_record_switch(unsigned long period)
{
unsigned char byte_tmp;
unsigned char byte_tmp1;
if(period > 1023)
{
printf("\tTW2834_ERROR: switch mod period input error\n");
return;
}
/*set scale of each channel */
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 0, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 1, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 2, 0xffff, 0xffff);
tw2834_setvin_scale_ratio(TW2834_PATH_Y, 3, 0xffff, 0xffff);
/*set record mod normal*/
tw2834_set_record_mod(0, 0);
/*set pic_size for each channel*/
tw2834_set_record_pic_size(0, 3);
tw2834_set_record_pic_size(1, 3);
tw2834_set_record_pic_size(2, 3);
tw2834_set_record_pic_size(3, 3);
/*set pic_pos for each channel*/
tw2834_set_record_pic_pos(0, 0);
tw2834_set_record_pic_pos(1, 0);
tw2834_set_record_pic_pos(2, 0);
tw2834_set_record_pic_pos(3, 0);
/*set switch mod for record path */
tw2834_set_op_mode(FUNC_MODE_SWITCH);
/*set mux mod live,set the trig mode,Capture frame*/
byte_tmp = tw2834_read_byte(PAGE1, 0x56);
CLEAR_BIT(byte_tmp, 0xf0);
SET_BIT(byte_tmp, 0xf0);
tw2834_write_byte(PAGE1, 0x56, byte_tmp);
/*set size of the queue to 3*/
tw2834_write_byte(PAGE1, 0x57, 0x03);
/*updata channnel 0 to the queue*/
byte_tmp = tw2834_read_byte(PAGE1, 0x59);
CLEAR_BIT(byte_tmp, 0x0f);
SET_BIT(byte_tmp, 0x00);
tw2834_write_byte(PAGE1, 0x59, byte_tmp);
tw2834_write_byte(PAGE1, 0x5a, 0x00);
tw2834_write_byte(PAGE1, 0x5a, 0x80);
/*updata channnel 1 to the queue*/
byte_tmp = tw2834_read_byte(PAGE1, 0x59);
CLEAR_BIT(byte_tmp, 0x0f);
SET_BIT(byte_tmp, 0x01);
tw2834_write_byte(PAGE1, 0x59, byte_tmp);
tw2834_write_byte(PAGE1, 0x5a, 0x01);
tw2834_write_byte(PAGE1, 0x5a, 0x81);
/*updata channnel 2 to the queue*/
byte_tmp = tw2834_read_byte(PAGE1, 0x59);
CLEAR_BIT(byte_tmp, 0x0f);
SET_BIT(byte_tmp, 0x02);
tw2834_write_byte(PAGE1, 0x59, byte_tmp);
tw2834_write_byte(PAGE1, 0x5a, 0x02);
tw2834_write_byte(PAGE1, 0x5a, 0x82);
/*updata channnel 3 to the queue*/
byte_tmp = tw2834_read_byte(PAGE1, 0x59);
CLEAR_BIT(byte_tmp, 0x0f);
SET_BIT(byte_tmp, 0x03);
tw2834_write_byte(PAGE1, 0x59, byte_tmp);
tw2834_write_byte(PAGE1, 0x5a, 0x03);
tw2834_write_byte(PAGE1, 0x5a, 0x83);
/*set switch period*/
byte_tmp = (unsigned char)period & 0xff;
byte_tmp1 = (unsigned char)(period & 0x0300) >> 2;
tw2834_write_byte(PAGE1, 0x58, byte_tmp);
byte_tmp = tw2834_read_byte(PAGE1, 0x59);
CLEAR_BIT(byte_tmp, 0xc0);
SET_BIT(byte_tmp, byte_tmp1);
tw2834_write_byte(PAGE1, 0x59, byte_tmp);
/*reset queue*/
byte_tmp = tw2834_read_byte(PAGE1, 0x5B);
CLEAR_BIT(byte_tmp, 0x03);
SET_BIT(byte_tmp, 0x03);
tw2834_write_byte(PAGE1, 0x5B, byte_tmp);
}
/****************************record path mod***********************************/
/*
* set tw2834 record path mod to 1 d1
* return value: nothing
*/
static void setd1(int chn)
{
set_record_normal_full(chn);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -