Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EALib EthernetInterface_vz mbed-rtos mbed
Fork of header_main_colinas_V0-20-09-14 by
utils.cpp
00001 #include "utils.h" 00002 00003 static char itoh[16]; 00004 char hexbuf[10]; 00005 00006 int hex_init(void) { 00007 itoh[0] = '0'; itoh[1] = '1'; itoh[2] = '2'; itoh[3] = '3'; 00008 itoh[4] = '4'; itoh[5] = '5'; itoh[6] = '6'; itoh[7] = '7'; 00009 itoh[8] = '8'; itoh[9] = '9'; itoh[10] = 'a'; itoh[11] = 'b'; 00010 itoh[12] = 'c'; itoh[13] = 'd'; itoh[14] = 'e'; itoh[15] = 'f'; 00011 return ( 0 ); 00012 } 00013 00014 char * hex8 (uint8_t i) { 00015 hexbuf[0] = itoh[(i>>4) & 0x0f]; 00016 hexbuf[1] = itoh[i & 0x0f]; 00017 hexbuf[2] = 0; 00018 return hexbuf; 00019 } 00020 00021 char * hex16 (uint16_t i) { 00022 hexbuf[0] = itoh[(i>>12) & 0x0f]; 00023 hexbuf[1] = itoh[(i>>8) & 0x0f]; 00024 hexbuf[2] = itoh[(i>>4) & 0x0f]; 00025 hexbuf[3] = itoh[i & 0x0f]; 00026 hexbuf[4] = 0; 00027 return hexbuf; 00028 } 00029 00030 int ls_comp ( const void * a, const void * b ) 00031 { 00032 if ( reverse_list ) return( *( int * )b - *( int * )a ); 00033 00034 else return( *( int * )a - *( int * )b ); 00035 00036 } 00037 00038 int wake_comp ( const void * a, const void * b ) 00039 { 00040 return( *( int * )a - *( int * )b ); 00041 } 00042 00043 int 00044 convert_ext_to_port( int ext ) { return ( ext ); } 00045 00046 void xmemcpy(uint8_t * dest, const uint8_t * src, uint16_t size ){ 00047 while (size--) *dest++ = *src++; 00048 } 00049 00050 void xmemcpy32(uint32_t * dest, uint32_t * src, uint16_t size){ 00051 size >>= 2; 00052 while (size--) *dest++ = *src++; 00053 } 00054 00055 uint8_t xstrmatch(const uint8_t * s1, const uint8_t * s2){ 00056 while (*s1) { 00057 if (*s1++ != *s2++) return 0; /* does not match */ 00058 } 00059 if ( *s2 == 0 ) 00060 return 1; /* matches */ 00061 else 00062 return 0; /* does not match */ 00063 } 00064 00065 uint8_t xmemmatch(const uint8_t * s1, const uint8_t * s2, uint16_t size){ 00066 while (size--) { 00067 if (*s1++ != *s2++) return 0; /* does not match */ 00068 } 00069 return 1; /* matches */ 00070 }
Generated on Tue Jul 12 2022 16:25:14 by
