view miscutil/arfcn2ti.c @ 1012:11391cb6bdc0

patch from fixeria: doc change from SE K2x0 to K2xx Since their discovery in late 2022, Sony Ericsson K200 and K220 phones were collectively referred to as SE K2x0 in FreeCalypso documentation. However, now that SE K205 has been discovered as yet another member of the same family (same PCBA in different case), it makes more sense to refer to the whole family as SE K2xx.
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 23 Sep 2024 12:23:20 +0000
parents b8cb116a7dc7
children
line wrap: on
line source

/*
 * TI's TCS211 L1 does not use standard ARFCNs internally, instead it uses
 * its own non-standard radio_freq numbers in their place.  Other firmware
 * components and all external interfaces do use standard ARFCNs, thus
 * conversion functions are invoked at appropriate points in the firmware.
 * However, L1-internal radio_freq numbers are emitted in L1 debug traces,
 * thus anyone looking at these traces needs to be able to convert between
 * standard ARFCNs and L1-internal radio_freq.
 *
 * The present utility converts a standard ARFCN into TI L1 radio_freq.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

main(argc, argv)
	char **argv;
{
	int arfcn;

	if (argc != 3) {
usage:		fprintf(stderr, "usage: %s {eu|us} arfcn\n", argv[0]);
		exit(1);
	}
	arfcn = atoi(argv[2]);
	if (!strcmp(argv[1], "eu"))
		arfcn2ti_eu(arfcn);
	else if (!strcmp(argv[1], "us"))
		arfcn2ti_us(arfcn);
	else
		goto usage;
	exit(0);
}

arfcn2ti_eu(arfcn)
{
	if (arfcn == 0)
		arfcn = 174;
	else if ((arfcn >= 975) && (arfcn <= 1023))
		arfcn -= 850;
	else if ((arfcn >= 512) && (arfcn <= 885))
		arfcn -= 337;
	else if ((arfcn >= 1) && (arfcn <= 124))
		;
	else {
		fprintf(stderr,
			"error: specified ARFCN is invalid for dual-EU\n");
		exit(1);
	}
	printf("%d\n", arfcn);
}

arfcn2ti_us(arfcn)
{
	if ((arfcn >= 128) && (arfcn <= 251))
		arfcn -= 127;
	else if ((arfcn >= 512) && (arfcn <= 810))
		arfcn -= 387;
	else {
		fprintf(stderr,
			"error: specified ARFCN is invalid for dual-US\n");
		exit(1);
	}
	printf("%d\n", arfcn);
}