typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned long int u32;
typedef signed long int s32;
typedef unsigned short WORD;
typedef unsigned char BOOL;
#define PinWrite_ADSCLK(x) ( (x) ? (P0_bit.no6 = 1 , PM0_bit.no6 = 1) : (PM0_bit.no6 = 0 , P0_bit.no6 = 0) ) //
#define PinMode_ADSCLK(x) ( (x == GPIO_MODE_OUT) ? (PM0_bit.no6 = 0) : (PM0_bit.no6 = 1) )
#define PinRead_ADSDI() (P4_bit.no4)
#define PinWrite_ADSDO(x) ( (x) ? (P6_bit.no0 = 1 , PM6_bit.no0 = 1) : (PM6_bit.no0 = 0 , P6_bit.no0 = 0) ) //
#define PinWrite_ADCS(x) ( (x) ? (P6_bit.no1 = 1 , PM6_bit.no1 = 1) : (PM6_bit.no1 = 0 , P6_bit.no1 = 0 ) )
#define PinWrite_ADRST(x) ( (x) ? (P0_bit.no5 = 1 , PM0_bit.no5 = 1) : (PM0_bit.no5 = 0 , P0_bit.no5 = 0 ) )
typedef enum {ERROR = 0 , SUCCESS = !ERROR} ErrorStatus;
typedef struct {
// u32 Dat : 23;
// u32 S : 1;
u8 Dat0;
u8 Dat1;
u8 Dat2 : 7;
u8 S : 1;
} sDF09;
typedef struct {
u32 Dat;
} sDF11;
typedef sDF11 sFsEgSh_TypeDef;
#pragma vector = INTTM01_vect
__interrupt void MD_INTTM01(void)
{
TMIF01 = 0; SysStamp ++ ;
}
u16 fnStamp_Through(u16 Ago)
{
extern u16 SysStamp;
if (SysStamp >= Ago)
{return (SysStamp - Ago);}
else
{return ( (0xffff - Ago) + SysStamp);}
}
u16 fnHexToBcd_u16(u16 Dat)
{
u16 Result = 0;
Dat = Dat % 10000;
Result += (Dat / 1000) * 0x1000;
Dat = Dat % 1000;
Result += (Dat / 100) * 0x100;
Dat = Dat % 100;
Result += (Dat / 10) * 0x10;
Dat = Dat % 10;
Result += Dat;
return(Result);
}
u32 fnHexToBcd_u32(u32 Dat)
{
u32 result = 0;
Dat = Dat % 100000000;
result += (Dat / 10000000) * 0x10000000;
Dat = Dat % 10000000;
result += (Dat / 1000000) * 0x1000000;
Dat = Dat % 1000000;
result += (Dat / 100000) * 0x100000;
Dat = Dat % 100000;
result += (Dat / 10000) * 0x10000;
Dat = Dat % 10000;
result += (Dat / 1000) * 0x1000;
Dat = Dat % 1000;
result += (Dat / 100) * 0x100;
Dat = Dat % 100;
result += (Dat / 10) * 0x10;
Dat = Dat % 10;
result += Dat;
return(result);
}
u16 fnDFConver_Bcd16To16(s16 Dat)
{
u16 Result;
Result = abs(Dat) % 8000;
Result = fnHexToBcd_u16(Result);
if(Dat < 0 ) Result |= 0x8000;
else Result &= 0x7fff;
return(Result);
}
u32 fnDFConver_Bcd32To32(s32 Dat)
{
u32 Result;
Result = labs(Dat) % 80000000;
Result = fnHexToBcd_u32(Result);
if(Dat < 0 ) Result |= 0x80000000;
else Result &= 0x7fffffff;
return(Result);
}
sDF09 fnDFConver_Hex32ToDF09(s32 Dat) {
sDF09 Result;
memset(&Result , 0 , sizeof(sDF09) );
if(Dat < 0) Result.S = 1;
else Result.S = 0;
Dat = labs(Dat) % 800000;
Dat = fnHexToBcd_u32(Dat);
Result.Dat0 = Dat;
Result.Dat1 = Dat >> 8;
Result.Dat2 = Dat >> 16;
return(Result);