Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
Diff: utils.cpp
- Revision:
- 117:e9facba9db27
- Parent:
- 114:472502b31a12
- Child:
- 119:ee6a53069455
diff -r 39a41ebb675c -r e9facba9db27 utils.cpp --- a/utils.cpp Thu Apr 23 20:24:09 2015 +0000 +++ b/utils.cpp Thu Apr 23 21:53:28 2015 +0000 @@ -1,5 +1,31 @@ #include "utils.h" +static char itoh[16]; +char hexbuf[10]; + +void hex_init(void) { + itoh[0] = '0'; itoh[1] = '1'; itoh[2] = '2'; itoh[3] = '3'; + itoh[4] = '4'; itoh[5] = '5'; itoh[6] = '6'; itoh[7] = '7'; + itoh[8] = '8'; itoh[9] = '9'; itoh[10] = 'a'; itoh[11] = 'b'; + itoh[12] = 'c'; itoh[13] = 'd'; itoh[14] = 'e'; itoh[15] = 'f'; +} + +char * hex8 (uint8_t i) { + hexbuf[0] = itoh[(i>>4) & 0x0f]; + hexbuf[1] = itoh[i & 0x0f]; + hexbuf[2] = 0; + return hexbuf; +} + +char * hex16 (uint16_t i) { + hexbuf[0] = itoh[(i>>12) & 0x0f]; + hexbuf[1] = itoh[(i>>8) & 0x0f]; + hexbuf[2] = itoh[(i>>4) & 0x0f]; + hexbuf[3] = itoh[i & 0x0f]; + hexbuf[4] = 0; + return hexbuf; +} + int ls_comp( const void * a, const void * b ){ return( *( int * )a - *( int * )b ); } void reverse( char str[], int length ){