80 lines
2.8 KiB
C
Raw Normal View History

2022-01-18 00:58:54 +08:00
/*********************************************************************************************************************
* COPYRIGHT NOTICE
* Copyright (c) 2020,<EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>
* All rights reserved.
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>QQȺ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ⱥ<EFBFBD><EFBFBD>824575535
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>;<EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>ӭ<EFBFBD><EFBFBD>λʹ<EFBFBD>ò<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD>İ<EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*
* @file FUN
* @company <EFBFBD>ɶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>޹<EFBFBD>˾
* @author <EFBFBD><EFBFBD><EFBFBD>ɿƼ<EFBFBD>(QQ3184284598)
* @version <EFBFBD>doc<EFBFBD><EFBFBD>version<EFBFBD>ļ<EFBFBD> <EFBFBD>˵<EFBFBD><EFBFBD>
* @Software ADS v1.2.2
* @Target core TC264D
* @Taobao https://seekfree.taobao.com/
* @date 2020-3-23
********************************************************************************************************************/
#include "SEEKFREE_FUN.h"
//-------------------------------------------------------------------------------------------------------------------
// @brief <20><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
// @param dat <09><>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>
// @return int <09><><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>ֵ
// Sample usage: dat = myabs(dat);//<2F><>dat<61><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//-------------------------------------------------------------------------------------------------------------------
int myabs(int dat)
{
if(dat>=0) return dat;
else return -dat;
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ
// @param t <09><>ʱʱ<CAB1><CAB1>
// @return void
// Sample usage:
//-------------------------------------------------------------------------------------------------------------------
void my_delay(long t)
{
while(t--);
}
//-------------------------------------------------------------------------------------------------------------------
// @brief <20>޷<EFBFBD>
// @param x <09><><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param y <09>޷<EFBFBD><DEB7><EFBFBD>Χ(<28><><EFBFBD>ݻᱻ<DDBB><E1B1BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-y<><79>+y֮<79><D6AE>)
// @return float <09>޷<EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Sample usage: float dat = limit(500,300);//<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-300<30><30>+300֮<30><D6AE> <20><><EFBFBD>˷<EFBFBD><CBB7>صĽ<D8B5><C4BD><EFBFBD><EFBFBD><EFBFBD>300
//-------------------------------------------------------------------------------------------------------------------
float limit(float x, int32 y)
{
if(x>y) return (float)y;
else if(x<-y) return (float)(-y);
else return x;
}
//-------------------------------------------------------------------------------------------------------------------
// @brief ˫<><CBAB><EFBFBD>޷<EFBFBD>
// @param x <09><><EFBFBD>޷<EFBFBD><DEB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// @param a <09>޷<EFBFBD><DEB7><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD>߽<EFBFBD>
// @param b <09>޷<EFBFBD><DEB7><EFBFBD>Χ<EFBFBD>ұ߽<D2B1>
// @return float <09>޷<EFBFBD>֮<EFBFBD><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// Sample usage: int16 dat = limit_ab(500,-300<30><30>400);//<2F><><EFBFBD>ݱ<EFBFBD><DDB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-300<30><30>+400֮<30><D6AE> <20><><EFBFBD>˷<EFBFBD><CBB7>صĽ<D8B5><C4BD><EFBFBD><EFBFBD><EFBFBD>400
//-------------------------------------------------------------------------------------------------------------------
int16 limit_ab(int16 x, int16 a, int16 b)
{
if(x<a) x = a;
if(x>b) x = b;
return x;
}