parent
386f190720
commit
06e3e0b207
|
@ -106,6 +106,7 @@
|
||||||
#define MACA_KEY0 ((volatile uint32_t *) (MACA_BASE+0x164))
|
#define MACA_KEY0 ((volatile uint32_t *) (MACA_BASE+0x164))
|
||||||
#define MACA_OPTIONS ((volatile uint32_t *) (MACA_BASE+0x180))
|
#define MACA_OPTIONS ((volatile uint32_t *) (MACA_BASE+0x180))
|
||||||
|
|
||||||
|
void maca_init(void);
|
||||||
void reset_maca(void);
|
void reset_maca(void);
|
||||||
void init_phy(void);
|
void init_phy(void);
|
||||||
void flyback_init(void);
|
void flyback_init(void);
|
||||||
|
|
20
lib/maca.c
20
lib/maca.c
|
@ -42,8 +42,23 @@ static volatile uint8_t last_post = NO_POST;
|
||||||
#define safe_irq_disable(x) volatile uint32_t saved_irq; saved_irq = *INTENABLE; disable_irq(x)
|
#define safe_irq_disable(x) volatile uint32_t saved_irq; saved_irq = *INTENABLE; disable_irq(x)
|
||||||
#define irq_restore() *INTENABLE = saved_irq
|
#define irq_restore() *INTENABLE = saved_irq
|
||||||
|
|
||||||
#define print_packets(x) Print_Packets(x)
|
void maca_init(void) {
|
||||||
|
reset_maca();
|
||||||
|
radio_init();
|
||||||
|
flyback_init();
|
||||||
|
init_phy();
|
||||||
|
free_all_packets();
|
||||||
|
|
||||||
|
/* initial radio command */
|
||||||
|
/* nop, promiscuous, no cca */
|
||||||
|
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
||||||
|
|
||||||
|
enable_irq(MACA);
|
||||||
|
maca_isr();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#define print_packets(x) Print_Packets(x)
|
||||||
void Print_Packets(char *s) {
|
void Print_Packets(char *s) {
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@ -232,11 +247,8 @@ void free_all_packets(void) {
|
||||||
|
|
||||||
free_head = 0;
|
free_head = 0;
|
||||||
for(i=0; i<NUM_PACKETS; i++) {
|
for(i=0; i<NUM_PACKETS; i++) {
|
||||||
printf("free packet %d\n\r",i);
|
|
||||||
free_packet((volatile packet_t *)&(packet_pool[i]));
|
free_packet((volatile packet_t *)&(packet_pool[i]));
|
||||||
printf("packet %d left %x right %x \n\r",i);
|
|
||||||
}
|
}
|
||||||
printf("free head %x\n",free_head);
|
|
||||||
rx_head = 0; rx_end = 0;
|
rx_head = 0; rx_end = 0;
|
||||||
tx_head = 0; tx_end = 0;
|
tx_head = 0; tx_end = 0;
|
||||||
|
|
||||||
|
|
31
tests/per.c
31
tests/per.c
|
@ -13,8 +13,6 @@
|
||||||
/* session with a node. After opening a session, the nodes begin the */
|
/* session with a node. After opening a session, the nodes begin the */
|
||||||
/* test sequence */
|
/* test sequence */
|
||||||
|
|
||||||
#define DEBUG_MACA 1
|
|
||||||
|
|
||||||
/* how long to wait between session requests */
|
/* how long to wait between session requests */
|
||||||
#define SESSION_REQ_TIMEOUT 10000 /* phony seconds */
|
#define SESSION_REQ_TIMEOUT 10000 /* phony seconds */
|
||||||
|
|
||||||
|
@ -81,33 +79,18 @@ void main(void) {
|
||||||
ptype_t type;
|
ptype_t type;
|
||||||
short_addr_t addr, my_addr;
|
short_addr_t addr, my_addr;
|
||||||
|
|
||||||
uart_init(INC,MOD);
|
|
||||||
|
|
||||||
print_welcome("Packet error test");
|
|
||||||
|
|
||||||
/* standard radio initialization */
|
|
||||||
reset_maca();
|
|
||||||
radio_init();
|
|
||||||
vreg_init();
|
|
||||||
flyback_init();
|
|
||||||
init_phy();
|
|
||||||
free_all_packets();
|
|
||||||
|
|
||||||
/* trim the reference osc. to 24MHz */
|
/* trim the reference osc. to 24MHz */
|
||||||
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
||||||
|
|
||||||
|
uart_init(INC,MOD);
|
||||||
|
|
||||||
|
vreg_init();
|
||||||
|
|
||||||
|
maca_init();
|
||||||
|
|
||||||
set_power(0x0f); /* 0dbm */
|
set_power(0x0f); /* 0dbm */
|
||||||
set_channel(0); /* channel 11 */
|
set_channel(0); /* channel 11 */
|
||||||
|
|
||||||
/* enable MACA interrupts */
|
|
||||||
/* call the handler once to start the maca cycle */
|
|
||||||
enable_irq(MACA);
|
|
||||||
maca_isr();
|
|
||||||
|
|
||||||
/* initial radio command */
|
|
||||||
/* nop, promiscuous, no cca */
|
|
||||||
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
|
||||||
|
|
||||||
/* generate a random short address */
|
/* generate a random short address */
|
||||||
my_addr = random_short_addr();
|
my_addr = random_short_addr();
|
||||||
|
|
||||||
|
@ -115,6 +98,8 @@ void main(void) {
|
||||||
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||||
*GPIO_PAD_DIR0 = *GPIO_PAD_DIR0 | (1<<(44-32));
|
*GPIO_PAD_DIR0 = *GPIO_PAD_DIR0 | (1<<(44-32));
|
||||||
|
|
||||||
|
print_welcome("Packet error test");
|
||||||
|
|
||||||
state = SCANNING;
|
state = SCANNING;
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
|
|
|
@ -16,30 +16,19 @@ void main(void) {
|
||||||
/* this is needed because the led clamps the voltage low */
|
/* this is needed because the led clamps the voltage low */
|
||||||
*GPIO_DATA_SEL0 = ( 1 << LED );
|
*GPIO_DATA_SEL0 = ( 1 << LED );
|
||||||
|
|
||||||
uart_init(INC,MOD);
|
|
||||||
|
|
||||||
print_welcome("rftest-rx");
|
|
||||||
|
|
||||||
reset_maca();
|
|
||||||
radio_init();
|
|
||||||
flyback_init();
|
|
||||||
vreg_init();
|
|
||||||
init_phy();
|
|
||||||
free_all_packets();
|
|
||||||
|
|
||||||
/* trim the reference osc. to 24MHz */
|
/* trim the reference osc. to 24MHz */
|
||||||
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
||||||
|
|
||||||
|
uart_init(INC,MOD);
|
||||||
|
|
||||||
|
vreg_init();
|
||||||
|
|
||||||
|
maca_init();
|
||||||
|
|
||||||
set_power(0x0f); /* 0dbm */
|
set_power(0x0f); /* 0dbm */
|
||||||
set_channel(0); /* channel 11 */
|
set_channel(0); /* channel 11 */
|
||||||
|
|
||||||
enable_irq(MACA);
|
print_welcome("rftest-rx");
|
||||||
maca_isr();
|
|
||||||
|
|
||||||
/* initial radio command */
|
|
||||||
/* nop, promiscuous, no cca */
|
|
||||||
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if((p = rx_packet())) {
|
if((p = rx_packet())) {
|
||||||
toggle_gpio0(LED);
|
toggle_gpio0(LED);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
/* 2 bytes are the FCS */
|
/* 2 bytes are the FCS */
|
||||||
/* therefore 125 is the max payload length */
|
/* therefore 125 is the max payload length */
|
||||||
#define PAYLOAD_LEN 16
|
#define PAYLOAD_LEN 16
|
||||||
#define DELAY 1
|
#define DELAY 400000
|
||||||
|
|
||||||
void fill_packet(volatile packet_t *p) {
|
void fill_packet(volatile packet_t *p) {
|
||||||
static volatile uint8_t count=0;
|
static volatile uint8_t count=0;
|
||||||
|
@ -28,35 +28,32 @@ void main(void) {
|
||||||
volatile uint32_t i;
|
volatile uint32_t i;
|
||||||
volatile packet_t *p;
|
volatile packet_t *p;
|
||||||
|
|
||||||
|
/* trim the reference osc. to 24MHz */
|
||||||
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
||||||
|
|
||||||
|
uart_init(INC,MOD);
|
||||||
|
|
||||||
|
vreg_init();
|
||||||
|
|
||||||
|
maca_init();
|
||||||
|
|
||||||
|
set_channel(0); /* channel 11 */
|
||||||
|
// set_power(0x0f); /* 0xf = -1dbm, see 3-22 */
|
||||||
|
// set_power(0x11); /* 0x11 = 3dbm, see 3-22 */
|
||||||
|
set_power(0x12); /* 0x12 is the highest, not documented */
|
||||||
|
|
||||||
*GPIO_DATA0 = 0x00000000;
|
*GPIO_DATA0 = 0x00000000;
|
||||||
*GPIO_PAD_DIR0 = ( 1 << LED );
|
*GPIO_PAD_DIR0 = ( 1 << LED );
|
||||||
/* read from the data register instead of the pad */
|
/* read from the data register instead of the pad */
|
||||||
/* this is needed because the led clamps the voltage low */
|
/* this is needed because the led clamps the voltage low */
|
||||||
*GPIO_DATA_SEL0 = ( 1 << LED );
|
*GPIO_DATA_SEL0 = ( 1 << LED );
|
||||||
|
|
||||||
uart_init(INC,MOD);
|
/* sets up tx_on, should be a board specific item */
|
||||||
|
*GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
||||||
|
*GPIO_PAD_DIR0 = *GPIO_PAD_DIR0 | (1<<(44-32));
|
||||||
|
|
||||||
print_welcome("rftest-tx");
|
print_welcome("rftest-tx");
|
||||||
|
|
||||||
reset_maca();
|
|
||||||
radio_init();
|
|
||||||
vreg_init();
|
|
||||||
flyback_init();
|
|
||||||
init_phy();
|
|
||||||
free_all_packets();
|
|
||||||
|
|
||||||
/* trim the reference osc. to 24MHz */
|
|
||||||
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
|
||||||
|
|
||||||
// set_power(0x0f); /* 0xf = -1dbm, see 3-22 */
|
|
||||||
// set_power(0x11); /* 0x11 = 3dbm, see 3-22 */
|
|
||||||
set_power(0x12); /* 0x12 is the highest, not documented*/
|
|
||||||
set_channel(0); /* channel 11 */
|
|
||||||
|
|
||||||
/* initial radio command */
|
|
||||||
/* nop, promiscuous, no cca */
|
|
||||||
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
p = get_free_packet();
|
p = get_free_packet();
|
||||||
|
|
Loading…
Reference in New Issue