/* ascii_tohex() takes an ascii character and translates it
* to the corresponding hexadecimal value
*/
uint8_t ascii_to_hex(uint8_t ascii){
uint8_t hex = 0;
switch (tolower(ascii)){
case 'f': hex = 0xf; break;
case 'e': hex = 0xe; break;
case 'd': hex = 0xd; break;
case 'c': hex = 0xc; break;
case 'b': hex = 0xb; break;
case 'a': hex = 0xa; break;
case '9': hex = 0x9; break;
case '8': hex = 0x8; break;
case '7': hex = 0x7; break;
case '6': hex = 0x6; break;
case '5': hex = 0x5; break;
case '4': hex = 0x4; break;
case '3': hex = 0x3; break;
case '2': hex = 0x2; break;
case '1': hex = 0x1; break;
case '0': hex = 0x0; break;
default: hex = 0x0; break;
}
return hex;
}