1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-04 23:04:38 +02:00

atusd firmware now supports setting the TST pin.

- common/io.h: TST is connected to P0_7
- include/at86rf230.h: added test mode registers REG_CONT_TX_0 (0x36) and
  REG_CONT_TX_1 (0x3d), with their values
- atspi/atspi.c (set_test_mode): set or reset TST and the LED
- atspi/atspi.c (reset_rf): leave test mode
- atspi/atspi.c (test_mode): enter test mode
- atspi/atspi.c (main): flash the LED when in test mode
- include/atspi/ep0.h (enum atspi_requests), atspi/ep0.c (my_setup): new
  command ATSPI_TEST to enter test mode
- include/atspi/ep0.h (EP0ATSPI_MINOR): bumped protocol to version 0.1
- include/at86rf230.h: corrected comment before TRX_CMD field to indicate
  that the register is called TRX_STATE
This commit is contained in:
Werner Almesberger 2010-11-11 02:25:54 -03:00
parent c45f1bb3c8
commit 2337557a8c
5 changed files with 59 additions and 3 deletions

View File

@ -18,10 +18,31 @@
#include "version.h"
static int in_test_mode = 0;
static void set_test_mode(int on)
{
in_test_mode = on;
if (on) {
TST_MODE |= 1 << TST_BIT;
TST = 1;
LED_MODE |= 1 << LED_BIT;
} else {
TST = 0;
TST_MODE &= ~(1 << TST_BIT);
LED_MODE &= ~(1 << LED_BIT);
LED = 0;
}
}
void reset_rf(void)
{
int i;
set_test_mode(0);
nRST_RF = 0;
/*
* 11.4.12: min 625 ns.
@ -32,6 +53,12 @@ void reset_rf(void)
}
void test_mode(void)
{
set_test_mode(1);
}
static void init_io(void)
{
/*
@ -44,6 +71,7 @@ static void init_io(void)
* nRST_RF push-pull 1
* IRQ_RF open drain 1 (input)
* SLP_TR push-pull 0
* TST open drain 0
*
* LED push-pull 0 (set up by boot loader)
*
@ -63,7 +91,7 @@ static void init_io(void)
SLP_TR = 0;
SLP_TR_MODE |= 1 << SLP_TR_BIT;
P0 = 1; /* IRQ_RF = 1; LED = 0; the rest is unused */
P0 = 1; /* IRQ_RF = 1; LED = 0; TST = Z; the rest is unused */
P3 = 0;
#if 0
@ -104,6 +132,10 @@ void main(void)
ep0_init();
while (1) {
if (in_test_mode) {
i++;
LED = !(i >> 13);
}
usb_poll();
}
}

View File

@ -26,6 +26,7 @@
extern void reset_rf(void);
extern void test_mode(void);
#define debug(...)
@ -151,6 +152,11 @@ static __bit my_setup(struct setup_request *setup) __reentrant
usb_send(&ep0, buf, 1, NULL, NULL);
return 1;
case ATSPI_TO_DEV(ATSPI_TEST):
debug("ATSPI_TEST\n");
test_mode();
return 1;
case ATSPI_TO_DEV(ATSPI_REG_WRITE):
debug("ATSPI_REG_WRITE\n");
nSS = 0;

View File

@ -30,5 +30,6 @@
#define nRST_RF P2_0
#define IRQ_RF P0_0
#define SLP_TR P2_1
#define TST P0_7
#endif /* !IO_H */

View File

@ -67,6 +67,9 @@ enum {
REG_XAH_CTRL = 0x2c,
REG_CSMA_SEED_0 = 0x2d,
REG_CSMA_SEED_1 = 0x2e,
REG_CONT_TX_0 = 0x36,
REG_CONT_TX_1 = 0x3d,
};
/* --- TRX_STATUS [7] ------------------------------------------------------ */
@ -113,7 +116,7 @@ enum {
TRAC_STATUS_INVALID = 7
};
/* --- TRX_CMD [4:0] ----------------------------------------------------- */
/* --- TRX_STATE [4:0] ----------------------------------------------------- */
#define TRX_CMD_SHIFT 0
#define TRX_CMD_MASK 7
@ -285,4 +288,15 @@ enum {
#define CSMA_SEED_1_SHIFT 0
#define CSMA_SEED_1_MASK 7
/* --- REG_CONT_TX_0 [7:0] ------------------------------------------------- */
#define CONT_TX_MAGIC 0x0f
/* --- REG_CONT_TX_1 [7:0] ------------------------------------------------- */
#define CONT_TX_MOD 0x00 /* modulated */
#define CONT_TX_M2M 0x10 /* f_CH-2 MHz */
#define CONT_TX_M500K 0x80 /* f_CH-0.5 MHz */
#define CONT_TX_P500K 0xc0 /* f_CH+0.5 MHz */
#endif /* !AT86RF230_H */

View File

@ -23,6 +23,7 @@
*
* host-> ATSPI_RF_RESET - - 0
* ->host ATSPI_POLL_INT - - 1
* host-> ATSPI_TEST - - 0
*
* host-> ATSPI_REG_WRITE value addr 0
* ->host ATSPI_REG_READ - addr 1
@ -36,10 +37,11 @@
* EP0 protocol:
*
* 0.0 initial release
* 0.1 addition of ATSPI_TEST
*/
#define EP0ATSPI_MAJOR 0 /* EP0 protocol, major revision */
#define EP0ATSPI_MINOR 0 /* EP0 protocol, minor revision */
#define EP0ATSPI_MINOR 1 /* EP0 protocol, minor revision */
#define HW_TYPE_100813 0 /* 100813 */
@ -65,6 +67,7 @@ enum atspi_requests {
ATSPI_RESET,
ATSPI_RF_RESET = 0x10,
ATSPI_POLL_INT,
ATSPI_TEST,
ATSPI_REG_WRITE = 0x20,
ATSPI_REG_READ,
ATSPI_BUF_WRITE,