中级会员
 
- 积分
- 224
- 金钱
- 224
- 注册时间
- 2016-11-30
- 在线时间
- 42 小时
|
发表于 2020-2-25 15:05:08
|
显示全部楼层
#define ZeroSuppress -30
#define Data_Highest NTCTAB[0]
#define Data_Lowest NTCTAB[TableSize-1]
void Lookup_TAB(uint16_t data,const int16_t *TABLE,int16_t *aptr)
{
uint16_t i;
int16_t *eptr=(int16_t *)&TABLE[TableSize-1]; //高端指针
int16_t *sptr=(int16_t *)TABLE; //低端指针
int16_t *ptr; //查数指针
for(i=0;i<9;i++) //搜索全表
{
// ptr = (int16_t *)((int16_t)sptr+(((int16_t)(eptr-sptr))>>1));
ptr = (int16_t *)(sptr+(((eptr-sptr))>>1));
if(*ptr>data) sptr = ptr;
else if(*ptr<data) eptr = ptr;
else //查到相等的节点
{
aptr[2] = *ptr; //Y1
aptr[1] = *(ptr+1); //Y2
aptr[0] = (int16_t)(ptr-TABLE);//X1
break;
}
if(eptr-sptr==1) //查到节点的范围
{
aptr[2] = *sptr; //Y1
aptr[1] = *eptr; //Y2
aptr[0] = (int16_t)(sptr-TABLE);//X1
break;
}
}
}
|
|