Hi,
I'm working on MKE1xF family over SDK2.5 and I'm looking for a solution for endian to host converter like htons().
My problem is that if I had a number and I want to convert to little/big endian, what is the method to use? The idea is use a common method for multiplatform, like htob (host to big endian) or htol (host to littel endian). In other platforms K60 MQX 4.1 there is support for this conversions
Is there any support for this family and SDK?
Thanks
Jordi
Solved! Go to Solution.
Hi Jordi,
There is some ARM function you can use.
__REV: Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
For example: A=__REV(B); //A,B is 32bit variable
__REVSH: Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
For example: C=__REVSH(D); //C,D is 16bit variable
Regards,
Jing
Hi Jordi,
There is some ARM function you can use.
__REV: Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
For example: A=__REV(B); //A,B is 32bit variable
__REVSH: Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
For example: C=__REVSH(D); //C,D is 16bit variable
Regards,
Jing
Hi Jing,
thanks for the feedback.
I didn't know this macros, and them are very useful.
Regards
Jordi