view loadtools/hexdecode.c @ 995:74024eb17e04

fc-loadtool help: improve language regarding 16 MiB flash chips In FC project history, 16 MiB flash originally meant Pirelli DP-L10. Then we got FCDEV3B with the same flash (our own design), but now we are discovering more Calypso devices that used such large flash, both late Calypso era (Sony Ericsson K2x0) as well as much earlier ones (FIC FLUID devices.txt file with 2004 dates, Leonardo+ rev 5). Hence we need to migrate to more generic or neutral language in associated documentation, without giving elevated status to specific examples that drove our early project history.
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 03 Dec 2023 21:11:12 +0000
parents e7502631a0f9
children
line wrap: on
line source

/*
 * This module contains the decode_hex_byte() function,
 * which is used by the SREC file reader and will likely be used
 * by other code as well, such as the dump-to-file function
 * of loadtool.
 */

#include <ctype.h>

decode_hex_byte(s)
	char *s;
{
	register int u, l;

	if (!isxdigit(s[0]) || !isxdigit(s[1]))
		return(-1);
	if (isdigit(s[0]))
		u = s[0] - '0';
	else if (isupper(s[0]))
		u = s[0] - 'A' + 10;
	else
		u = s[0] - 'a' + 10;
	if (isdigit(s[1]))
		l = s[1] - '0';
	else if (isupper(s[1]))
		l = s[1] - 'A' + 10;
	else
		l = s[1] - 'a' + 10;
	return((u << 4) | l);
}