Modularizando o src

Dependencies:   EALib EthernetInterface_vz mbed-rtos mbed

Fork of header_main_colinas_V0-20-09-14 by VZTECH

Committer:
klauss
Date:
Tue Nov 24 14:06:22 2015 +0000
Revision:
137:32dd35a6dbc9
Parent:
135:2f4290590e51
core source of the .bin (09/21/2015) in the field

Who changed what in which revision?

UserRevisionLine numberNew contents of line
klauss 122:480c44b0e205 1 #include "utils.h"
klauss 0:4d17cd9c8f9d 2
klauss 117:e9facba9db27 3 static char itoh[16];
klauss 117:e9facba9db27 4 char hexbuf[10];
klauss 117:e9facba9db27 5
klauss 119:ee6a53069455 6 int hex_init(void) {
klauss 117:e9facba9db27 7 itoh[0] = '0'; itoh[1] = '1'; itoh[2] = '2'; itoh[3] = '3';
klauss 117:e9facba9db27 8 itoh[4] = '4'; itoh[5] = '5'; itoh[6] = '6'; itoh[7] = '7';
klauss 117:e9facba9db27 9 itoh[8] = '8'; itoh[9] = '9'; itoh[10] = 'a'; itoh[11] = 'b';
klauss 117:e9facba9db27 10 itoh[12] = 'c'; itoh[13] = 'd'; itoh[14] = 'e'; itoh[15] = 'f';
klauss 119:ee6a53069455 11 return ( 0 );
klauss 117:e9facba9db27 12 }
klauss 117:e9facba9db27 13
klauss 117:e9facba9db27 14 char * hex8 (uint8_t i) {
klauss 117:e9facba9db27 15 hexbuf[0] = itoh[(i>>4) & 0x0f];
klauss 117:e9facba9db27 16 hexbuf[1] = itoh[i & 0x0f];
klauss 117:e9facba9db27 17 hexbuf[2] = 0;
klauss 117:e9facba9db27 18 return hexbuf;
klauss 117:e9facba9db27 19 }
klauss 117:e9facba9db27 20
klauss 117:e9facba9db27 21 char * hex16 (uint16_t i) {
klauss 117:e9facba9db27 22 hexbuf[0] = itoh[(i>>12) & 0x0f];
klauss 117:e9facba9db27 23 hexbuf[1] = itoh[(i>>8) & 0x0f];
klauss 117:e9facba9db27 24 hexbuf[2] = itoh[(i>>4) & 0x0f];
klauss 117:e9facba9db27 25 hexbuf[3] = itoh[i & 0x0f];
klauss 117:e9facba9db27 26 hexbuf[4] = 0;
klauss 117:e9facba9db27 27 return hexbuf;
klauss 117:e9facba9db27 28 }
klauss 117:e9facba9db27 29
klauss 124:c1b6c893e1c3 30 int ls_comp ( const void * a, const void * b )
klauss 124:c1b6c893e1c3 31 {
klauss 124:c1b6c893e1c3 32 if ( reverse_list ) return( *( int * )b - *( int * )a );
klauss 124:c1b6c893e1c3 33
klauss 124:c1b6c893e1c3 34 else return( *( int * )a - *( int * )b );
klauss 124:c1b6c893e1c3 35
klauss 124:c1b6c893e1c3 36 }
klauss 124:c1b6c893e1c3 37
klauss 124:c1b6c893e1c3 38 int wake_comp ( const void * a, const void * b )
klauss 124:c1b6c893e1c3 39 {
klauss 124:c1b6c893e1c3 40 return( *( int * )a - *( int * )b );
klauss 124:c1b6c893e1c3 41 }
klauss 68:b54993674190 42
klauss 135:2f4290590e51 43 int
klauss 135:2f4290590e51 44 convert_ext_to_port( int ext ) { return ( ext ); }
klauss 0:4d17cd9c8f9d 45
klauss 78:1353744f01e1 46 void xmemcpy(uint8_t * dest, const uint8_t * src, uint16_t size ){
klauss 74:81c47fff88a5 47 while (size--) *dest++ = *src++;
klauss 0:4d17cd9c8f9d 48 }
klauss 0:4d17cd9c8f9d 49
klauss 74:81c47fff88a5 50 void xmemcpy32(uint32_t * dest, uint32_t * src, uint16_t size){
klauss 74:81c47fff88a5 51 size >>= 2;
klauss 74:81c47fff88a5 52 while (size--) *dest++ = *src++;
klauss 78:1353744f01e1 53 }
klauss 78:1353744f01e1 54
klauss 78:1353744f01e1 55 uint8_t xstrmatch(const uint8_t * s1, const uint8_t * s2){
klauss 78:1353744f01e1 56 while (*s1) {
klauss 78:1353744f01e1 57 if (*s1++ != *s2++) return 0; /* does not match */
klauss 78:1353744f01e1 58 }
klauss 78:1353744f01e1 59 if ( *s2 == 0 )
klauss 78:1353744f01e1 60 return 1; /* matches */
klauss 78:1353744f01e1 61 else
klauss 78:1353744f01e1 62 return 0; /* does not match */
klauss 81:3656f00ab3db 63 }
klauss 81:3656f00ab3db 64
klauss 81:3656f00ab3db 65 uint8_t xmemmatch(const uint8_t * s1, const uint8_t * s2, uint16_t size){
klauss 81:3656f00ab3db 66 while (size--) {
klauss 81:3656f00ab3db 67 if (*s1++ != *s2++) return 0; /* does not match */
klauss 81:3656f00ab3db 68 }
klauss 81:3656f00ab3db 69 return 1; /* matches */
klauss 74:81c47fff88a5 70 }