wireless/ieee802154/i8sak/i8sak_main.c
/****************************************************************************
 * Name: i8sak_char2nibble
 *
 * Description:
 *   Convert an hexadecimal character to a 4-bit nibble.
 *
 ****************************************************************************/
i8sak_char2nibble
Description:
Convert an hexadecimal character to a 4-bit nibble.
i8sak_char2nibble Description : Convert an hexadecimal character to a 4 - bit nibble .
uint8_t i8sak_char2nibble(char ch)
{
  if (ch >= '0' && ch <= '9')
    {
      return ch - '0';
    }
  else if (ch >= 'a' && ch <= 'f')
    {
      return ch - 'a' + 10;
    }
  else if (ch >= 'A' && ch <= 'F')
    {
      return ch - 'A' + 10;
    }
  else if (ch == '\0')
    {
      fprintf(stderr, "ERROR: Unexpected end hex\n");
      exit(EXIT_FAILURE);
    }
  else
    {
      fprintf(stderr, "ERROR: Unexpected character in hex value: %02x\n", ch);
      exit(EXIT_FAILURE);
    }
}
uint8_t i8sak_char2nibble ( char ch ) { if ( ch >= ' ' && ch <= ' ' ) { return ch - ' ' ; } else if ( ch >= ' ' && ch <= ' ' ) { return ch - ' ' + 10 ; } else if ( ch >= ' ' && ch <= ' ' ) { return ch - ' ' + 10 ; } else if ( ch == ' \0 ' ) { fprintf ( stderr , " \n " ) ; exit ( EXIT_FAILURE ) ; } else { fprintf ( stderr , " \n " , ch ) ; exit ( EXIT_FAILURE ) ; } }
Name: i8sak_char2nibble
 Description:
   Convert an hexadecimal character to a 4-bit nibble.
Name : i8sak_char2nibble Description : Convert an hexadecimal character to a 4 - bit nibble .