📄 tty_char.c
字号:
/* Lucent Technologies Inc. or any other company. Specifically, */
/* Lucent Technologies Inc. reserves the right to modify, amend, or */
/* withdraw the statements contained herein. */
/* */
/* Permission is granted to 3GPP2 Technical Specifications Group C */
/* participants to copy any portion of this document for legitimate */
/* purposes of 3GPP2 Technical Specifications Group C. Copying for */
/* monetary gain or other non-3GPP2 Technical Specifications Group C */
/* purposes is prohibited. */
/* */
/*-------------------------------------------------------------------*/
/* */
/* Grant of license Motorola Inc. grants a free, irrevocable license */
/* to 3GPP2 and its organizational partners to incorporate Motorola- */
/* supplied text or other copyrightable material contained in the */
/* contribution and any modifications thereof in the creation of */
/* 3GPP2 publications, to copyright and sell in organizational */
/* partners name any organizational partners standards publications */
/* even though it may include portions of the contribution; and at */
/* the organizational partners sole discretion to permit others */
/* to reproduce in whole or in part such contributions or the */
/* resulting organizational partners standards publication. Motorola */
/* is also willing to grant licenses under such Motorola copyrights */
/* to third parties on reasonable, non-discriminatory terms and */
/* conditions, as appropriate. */
/* */
/* Notice: */
/* This document has been prepared by Motorola Inc. to assist the */
/* 3GPP2 standards committee. This document is offered to the */
/* committee as a basis for discussion and should not be considered */
/* as a binding proposal on Motorola Inc. or any other company. */
/* Specifically, Motorola Inc. reserves the right to modify, amend, */
/* or withdraw the statement contained herein. Permission is granted */
/* to 3GPP2 and its organizational partners to copy any portion of */
/* this document for the legitimate purposes of the 3GPP2. Copying */
/* this document for monetary gain or other non-3GPP2 purpose is */
/* prohibited. Motorola Inc. may hold one or more patents of */
/* copyrights that cover information contained in this contribution, */
/* and agrees that a license under those rights will be made */
/* available on reasonable and non-discriminatory terms and */
/* conditions, subject to receiving a reciprocal license in return. */
/* Nothing contained herein shall be construed as conferring by */
/* implication, estoppel, or otherwise any license or right under */
/* any patent, whether or not the use of information herein */
/* necessarily employs an invention of any existing or later issued */
/* patent, or copyright. */
/* */
/* Notice */
/* Permission is granted to 3GPP2 participants to copy any portion of*/
/* this contribution for the legitimate purpose of the 3GPP2. */
/* Copying this contribution for monetary gain or other non-3GPP2 */
/* purpose is prohibited. */
/* */
/*-------------------------------------------------------------------*/
/*********************************************************************
* get_tty_state()
*
**********************************************************************/
#include <stdio.h>
#include "typedef.h"
#include "tty.h"
#include "basic_op.h"
#define MAX_CHAR_LEN 72
#define MIN_CHAR_LEN 51
#define BAD_DITS_PER_CHAR 22
Word16 get_tty_char(
Word16 *tty_char, /* (o): TTY character */
Word16 tty_bit_hist[], /* (i): TTY bit history buffer */
Word16 tty_bit_len_hist[] /* (i): TTY bit length history buffer */
)
{
Word16 i;
Word16 char_len;
Word16 tmp_tty_char;
/* Check start bit, stop bit and bit before start bit */
if( sub(tty_bit_hist[MEM_BIT_IDX],LOGIC_0) == 0
|| sub(tty_bit_hist[START_BIT_IDX],LOGIC_0) != 0
|| sub(tty_bit_hist[STOP_BIT_IDX],LOGIC_1) != 0
)
{
return(0);
}
else
{
tmp_tty_char = 0;
for( i=STOP_BIT_IDX-1 ; i > START_BIT_IDX ; i-- )
{
if( sub(tty_bit_hist[i],LOGIC_0) == 0
|| sub(tty_bit_hist[i],LOGIC_1) == 0 )
{
tmp_tty_char = shl(tmp_tty_char,1);
tmp_tty_char = add(tmp_tty_char,tty_bit_hist[i]);
}
else
{
return(0);
}
}
}
/* Check the character length */
char_len = 0;
for( i= START_BIT_IDX ; i < STOP_BIT_IDX ; i++ )
{
char_len = add(char_len,tty_bit_len_hist[i]);
}
if( sub(char_len,MAX_CHAR_LEN) > 0 )
{
return(0);
}
if( sub(char_len,MIN_CHAR_LEN) < 0 )
{
return(0);
}
/* Check the total # of bad dits per character */
if( sub(tty_bit_len_hist[MEM_BIT_IDX],BAD_DITS_PER_CHAR) > 0 )
{
tty_bit_hist[MEM_BIT_IDX] = LOGIC_0;
tty_bit_len_hist[MEM_BIT_IDX] = 0;
return(0);
}
/*
* Update the bit and length buffers, wiping out all of
* info that was used to form this character.
*/
tty_bit_len_hist[MEM_BIT_IDX] = 0;
for( i=0 ; i <= STOP_BIT_IDX ; i++ )
{
tty_bit_hist[i] = UNKNOWN;
}
*tty_char = tmp_tty_char;
return(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -