diff --git a/tools/atrf-id/atrf-id.c b/tools/atrf-id/atrf-id.c index e0c9920..89d7871 100644 --- a/tools/atrf-id/atrf-id.c +++ b/tools/atrf-id/atrf-id.c @@ -1,8 +1,8 @@ /* * atrf-id/atrf-id.c - Identify a ben-wpan AT86RF230 board * - * Written 2010 by Werner Almesberger - * Copyright 2010 Werner Almesberger + * Written 2010-2011 by Werner Almesberger + * Copyright 2010-2011 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -116,12 +116,30 @@ static void show_info(struct atrf_dsc *dsc) show_usb_info(dsc); + printf("%10s", ""); + + switch (atrf_identify(dsc)) { + case atrf_unknown_chip: + printf("???"); + break; + case artf_at86rf230: + printf("AT86RF230"); + break; + case artf_at86rf231: + printf("AT86RF231"); + break; + default: + abort(); + } + part = atrf_reg_read(dsc, REG_PART_NUM); version = atrf_reg_read(dsc, REG_VERSION_NUM); man_id_0 = atrf_reg_read(dsc, REG_MAN_ID_0); man_id_1 = atrf_reg_read(dsc, REG_MAN_ID_1); - printf("%10spart 0x%02x version %u manufacturer xxxx%02x%02x\n", "", + printf(", part 0x%02x version %u manufacturer xxxx%02x%02x", part, version, man_id_1, man_id_0); + + printf(" (%s)\n", man_id_1 == 0 && man_id_0 == 0x1f ? "Atmel" : "???"); } diff --git a/tools/include/atrf.h b/tools/include/atrf.h index f5e015f..36febea 100644 --- a/tools/include/atrf.h +++ b/tools/include/atrf.h @@ -16,6 +16,13 @@ #include +enum atrf_chip_id { + atrf_unknown_chip = 0, + artf_at86rf230 = 1, + artf_at86rf231 = 2, +}; + + struct atrf_dsc; @@ -29,6 +36,9 @@ int atrf_clear_error(struct atrf_dsc *dsc); void atrf_reset(struct atrf_dsc *dsc); void atrf_reset_rf(struct atrf_dsc *dsc); + +enum atrf_chip_id atrf_identify(struct atrf_dsc *dsc); + int atrf_test_mode(struct atrf_dsc *dsc); void atrf_reg_write(struct atrf_dsc *dsc, uint8_t reg, uint8_t value); diff --git a/tools/lib/atrf.c b/tools/lib/atrf.c index 9edad56..29738dc 100644 --- a/tools/lib/atrf.c +++ b/tools/lib/atrf.c @@ -1,8 +1,8 @@ /* * lib/atrf.c - ATRF access functions library * - * Written 2010 by Werner Almesberger - * Copyright 2010 Werner Almesberger + * Written 2010-2011 by Werner Almesberger + * Copyright 2010-2011 Werner Almesberger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,6 +14,8 @@ #include #include +#include "at86rf230.h" + #include "driver.h" #include "atrf.h" @@ -99,6 +101,37 @@ void atrf_reset_rf(struct atrf_dsc *dsc) } +enum atrf_chip_id atrf_identify(struct atrf_dsc *dsc) +{ + uint8_t part, version; + + part = atrf_reg_read(dsc, REG_PART_NUM); + version = atrf_reg_read(dsc, REG_VERSION_NUM); + switch (part) { + case 2: /* AT86RF230 */ + switch (version) { + case 1: /* rev A */ + case 2: /* rev B */ + return artf_at86rf230; + default: + return atrf_unknown_chip; + } + break; + case 3: /* AT86RF231 */ + switch (version) { + case 2: /* rev A */ + return artf_at86rf231; + default: + return atrf_unknown_chip; + } + break; + default: + return atrf_unknown_chip; + } + return atrf_unknown_chip; +} + + int atrf_test_mode(struct atrf_dsc *dsc) { if (!dsc->driver->test_mode)