/*****************************************************************************/
/**
*
* @function Perform a 16-bit endian converion.
*
* @param Data: 16 bit value to be converted
*
* @return 16 bit Data with converted endianess
*
******************************************************************************/
u16 EndianSwap16(u16 Data)
{
return (u16) (((Data & 0xFF00U) >> 8U) | ((Data & 0x00FFU) << 8U));
}
/*****************************************************************************/
/**
*
* @function Perform a 32-bit endian converion.
*
* @param Data: 32 bit value to be converted
*
* @return 32 bit data with converted endianess
*
******************************************************************************/
u32 EndianSwap32(u32 Data)
{
u16 LoWord;
u16 HiWord;
/* get each of the half words from the 32 bit word */
LoWord = (u16) (Data & 0x0000FFFFU);
HiWord = (u16) ((Data & 0xFFFF0000U) >> 16U);
/* byte swap each of the 16 bit half words */
LoWord = (((LoWord & 0xFF00U) >> 8U) | ((LoWord & 0x00FFU) << 8U));
HiWord = (((HiWord & 0xFF00U) >> 8U) | ((HiWord & 0x00FFU) << 8U));
/* swap the half words before returning the value */
return ((((u32)LoWord) << (u32)16U) | (u32)HiWord);
}
11-14
1447
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)