Modularizando o src
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
utils.cpp
- Committer:
- klauss
- Date:
- 2015-05-11
- Revision:
- 122:480c44b0e205
- Parent:
- 121:ee02790d00b7
- Child:
- 124:c1b6c893e1c3
File content as of revision 122:480c44b0e205:
#include "utils.h" static char itoh[16]; char hexbuf[10]; int 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'; return ( 0 ); } 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 ); } int convert_ext_to_port( int ext ){ if( ext < 1000 ) return ext; else{ int aux = 0; aux = ( ext / 1000 ) * 1000; ext -= aux; aux += ext % 100; return( aux ); } } void xstrcpy(uint8_t * dest, const uint8_t * src ){ while (*src) *dest++ = *src++; *dest = 0; } void xmemcpy(uint8_t * dest, const uint8_t * src, uint16_t size ){ while (size--) *dest++ = *src++; } void xmemcpy32(uint32_t * dest, uint32_t * src, uint16_t size){ size >>= 2; while (size--) *dest++ = *src++; } uint8_t xstrmatch(const uint8_t * s1, const uint8_t * s2){ while (*s1) { if (*s1++ != *s2++) return 0; /* does not match */ } if ( *s2 == 0 ) return 1; /* matches */ else return 0; /* does not match */ } uint8_t xmemmatch(const uint8_t * s1, const uint8_t * s2, uint16_t size){ while (size--) { if (*s1++ != *s2++) return 0; /* does not match */ } return 1; /* matches */ }