mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-29 17:04:04 +02:00
libatrf: new function atrf_identify to identify the chip
- tools/lib/atrf.h, tools/lib/atrf.c (atrf_identify): added chip identification function to library - tools/atrf-id/atrf-id.c (show_info): print information returned by atrf_identify - tools/atrf-id/atrf-id.c (show_info): decode JEDEC manufacturer ID
This commit is contained in:
parent
4ef7a829c2
commit
a9321cea7c
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* atrf-id/atrf-id.c - Identify a ben-wpan AT86RF230 board
|
* atrf-id/atrf-id.c - Identify a ben-wpan AT86RF230 board
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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);
|
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);
|
part = atrf_reg_read(dsc, REG_PART_NUM);
|
||||||
version = atrf_reg_read(dsc, REG_VERSION_NUM);
|
version = atrf_reg_read(dsc, REG_VERSION_NUM);
|
||||||
man_id_0 = atrf_reg_read(dsc, REG_MAN_ID_0);
|
man_id_0 = atrf_reg_read(dsc, REG_MAN_ID_0);
|
||||||
man_id_1 = atrf_reg_read(dsc, REG_MAN_ID_1);
|
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);
|
part, version, man_id_1, man_id_0);
|
||||||
|
|
||||||
|
printf(" (%s)\n", man_id_1 == 0 && man_id_0 == 0x1f ? "Atmel" : "???");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
|
enum atrf_chip_id {
|
||||||
|
atrf_unknown_chip = 0,
|
||||||
|
artf_at86rf230 = 1,
|
||||||
|
artf_at86rf231 = 2,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct atrf_dsc;
|
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(struct atrf_dsc *dsc);
|
||||||
void atrf_reset_rf(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);
|
int atrf_test_mode(struct atrf_dsc *dsc);
|
||||||
|
|
||||||
void atrf_reg_write(struct atrf_dsc *dsc, uint8_t reg, uint8_t value);
|
void atrf_reg_write(struct atrf_dsc *dsc, uint8_t reg, uint8_t value);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* lib/atrf.c - ATRF access functions library
|
* lib/atrf.c - ATRF access functions library
|
||||||
*
|
*
|
||||||
* Written 2010 by Werner Almesberger
|
* Written 2010-2011 by Werner Almesberger
|
||||||
* Copyright 2010 Werner Almesberger
|
* Copyright 2010-2011 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -14,6 +14,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "at86rf230.h"
|
||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "atrf.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)
|
int atrf_test_mode(struct atrf_dsc *dsc)
|
||||||
{
|
{
|
||||||
if (!dsc->driver->test_mode)
|
if (!dsc->driver->test_mode)
|
||||||
|
Loading…
Reference in New Issue
Block a user