📄 basic_fun.c
字号:
/*==============================================================================*/
/* file name : basic_fun.c (user's basic function add there) */
/* compiler : SPARC-RTEMS-GCC */
/* author : mr.zhou */
/* copyright : ORBITA Co.,Ltd. All Right Reserved.At 2005-9-2 */
/*==============================================================================*/
#include"stdio.h"
#include"System.h"
/**************************************************
Description:
convert len of bytes in *Input buffer from
line mode to row mode;
as:
from
__ __
__ __
__ __
__ __
__ __
__ __
__ __
__ __
to:
||||||||
||||||||
Parameters:
BYTE *Input;
BYTE len;
Return:
none
Syntax:
void __convert_byte(BYTE *Input,BYTE len)
**************************************************/
void __convert_byte(BYTE *Input,BYTE len)
{
BYTE i,j,tru=1;
BYTE ok[32]={0};
BYTE a_ok[16]={0};
BYTE scaler = 0x80,temp,point=8;
if(len == 32)
{
for(j=0;j<8;j++) //convert byte 1;
{
temp =0;
ok[j] = 0;
for(i=8;i>0;i--)
{
temp = Input[(i-1)*2] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
ok[j] = ok[j] | temp;
}
scaler = scaler >> 1;
point--;
}
scaler = 0x80;
point=8;
for(j=0;j<8;j++) //convert byte 2;
{
temp =0;
ok[j+8] = 0;
for(i=8;i>0;i--)
{
temp = Input[(i-1)*2 + 16] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
ok[j+8] = ok[j+8] | temp;
}
scaler = scaler >> 1;
point--;
}
scaler = 0x80;
point=8;
for(j=0;j<8;j++) //convert byte 3;
{
temp =0;
ok[j+16] = 0;
for(i=8;i>0;i--)
{
temp = Input[(i-1)*2 +1] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
ok[j+16] = ok[j+16] | temp;
}
scaler = scaler >> 1;
point--;
}
scaler = 0x80;
point=8;
for(j=0;j<8;j++) //convert byte 4;
{
temp =0;
ok[j+24] = 0;
for(i=8;i>0;i--)
{
temp = Input[(i-1)*2 +17] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
ok[j+24] = ok[j+24] | temp;
}
scaler = scaler >> 1;
point--;
}
for(i=0;i<len;i++)Input[i]=ok[i];
} // len == 32
if(len == 16) //len == 16
{
scaler = 0x80;
point=8;
for(j=0;j<8;j++) //convert byte 1;
{
temp =0;
a_ok[j] = 0;
for(i=8;i>0;i--)
{
temp = Input[i-1] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
a_ok[j] = a_ok[j] | temp;
}
scaler = scaler >> 1;
point--;
}
scaler = 0x80;
point=8;
for(j=0;j<8;j++) //convert byte 2;
{
temp =0;
a_ok[j+8] = 0;
for(i=8;i>0;i--)
{
temp = Input[(i-1) + 8] & scaler;
if(i>point)
temp = temp << (i-point);
if(i == point ) ;
if(i<point)
temp = temp >> (point -i);
a_ok[j+8] = a_ok[j+8] | temp;
}
scaler = scaler >> 1;
point--;
}
for(i=0;i<len;i++)Input[i]=a_ok[i];
}
}
void Delay(int delay)
{
int i;
for(i=0; i<delay; i++);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -