1 #include <section_config.h> 2 #include <basic_types.h> 3 4 LIBC_ROM_TEXT_SECTION 5 _LONG_CALL_ _char2num(u8 ch)6u8 _char2num(u8 ch) 7 { 8 if((ch>='0')&&(ch<='9')) 9 return ch - '0'; 10 else if ((ch>='a')&&(ch<='f')) 11 return ch - 'a' + 10; 12 else if ((ch>='A')&&(ch<='F')) 13 return ch - 'A' + 10; 14 else 15 return 0xff; 16 } 17 18 LIBC_ROM_TEXT_SECTION 19 _LONG_CALL_ _2char2dec(u8 hch,u8 lch)20u8 _2char2dec(u8 hch, u8 lch) 21 { 22 return ((_char2num(hch) * 10 ) + _char2num(lch)); 23 } 24 25 LIBC_ROM_TEXT_SECTION 26 _LONG_CALL_ _2char2hex(u8 hch,u8 lch)27u8 _2char2hex(u8 hch, u8 lch) 28 { 29 return ((_char2num(hch) << 4) | _char2num(lch)); 30 }