move Read* functions to common.h
parent
654fe5af8a
commit
98eec98361
|
@ -569,64 +569,6 @@ static float FloatNoSwap(float f)
|
|||
return f;
|
||||
}
|
||||
|
||||
int16_t ReadBigShort(byte *bytes)
|
||||
{
|
||||
int16_t v;
|
||||
v = bytes[1];
|
||||
v |= bytes[0] << 8;
|
||||
return v;
|
||||
}
|
||||
|
||||
int32_t ReadBigLong(byte *bytes)
|
||||
{
|
||||
int32_t v;
|
||||
v = bytes[3];
|
||||
v |= bytes[2] << 8;
|
||||
v |= bytes[1] << 16;
|
||||
v |= bytes[0] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
float ReadBigFloat(byte *bytes)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
} data;
|
||||
data.i = ReadBigLong(bytes);
|
||||
return data.f;
|
||||
}
|
||||
|
||||
int16_t ReadLittleShort(byte *bytes)
|
||||
{
|
||||
int16_t v;
|
||||
v = bytes[0];
|
||||
v |= bytes[1] << 8;
|
||||
return v;
|
||||
}
|
||||
|
||||
int32_t ReadLittleLong(byte *bytes)
|
||||
{
|
||||
int32_t v;
|
||||
v = bytes[0];
|
||||
v |= bytes[1] << 8;
|
||||
v |= bytes[2] << 16;
|
||||
v |= bytes[3] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
float ReadLittleFloat(byte *bytes)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
} data;
|
||||
data.i = ReadLittleLong(bytes);
|
||||
return data.f;
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
|
|
|
@ -74,13 +74,63 @@ extern int16_t (*LittleShort)(int16_t l);
|
|||
extern int32_t (*LittleLong)(int32_t l);
|
||||
extern float (*LittleFloat)(float l);
|
||||
|
||||
int16_t ReadBigShort(byte *bytes);
|
||||
int32_t ReadBigLong(byte *bytes);
|
||||
float ReadBigFloat(byte *bytes);
|
||||
static inline int16_t ReadBigShort(byte const *bytes)
|
||||
{
|
||||
int16_t v;
|
||||
v = bytes[1];
|
||||
v |= bytes[0] << 8;
|
||||
return v;
|
||||
}
|
||||
|
||||
int16_t ReadLittleShort(byte *bytes);
|
||||
int32_t ReadLittleLong(byte *bytes);
|
||||
float ReadLittleFloat(byte *bytes);
|
||||
static inline int32_t ReadBigLong(byte const *bytes)
|
||||
{
|
||||
int32_t v;
|
||||
v = bytes[3];
|
||||
v |= bytes[2] << 8;
|
||||
v |= bytes[1] << 16;
|
||||
v |= bytes[0] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline float ReadBigFloat(byte const *bytes)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
} data;
|
||||
data.i = ReadBigLong(bytes);
|
||||
return data.f;
|
||||
}
|
||||
|
||||
static inline int16_t ReadLittleShort(byte const *bytes)
|
||||
{
|
||||
int16_t v;
|
||||
v = bytes[0];
|
||||
v |= bytes[1] << 8;
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline int32_t ReadLittleLong(byte const *bytes)
|
||||
{
|
||||
int32_t v;
|
||||
v = bytes[0];
|
||||
v |= bytes[1] << 8;
|
||||
v |= bytes[2] << 16;
|
||||
v |= bytes[3] << 24;
|
||||
return v;
|
||||
}
|
||||
|
||||
static inline float ReadLittleFloat(byte const *bytes)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
uint32_t i;
|
||||
} data;
|
||||
data.i = ReadLittleLong(bytes);
|
||||
return data.f;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
|
Loading…
Reference in New Issue