2010-02-26 22:44:39 +00:00
|
|
|
#include <mc1322x.h>
|
|
|
|
#include <board.h>
|
2010-03-03 18:39:14 +00:00
|
|
|
#include <stdio.h>
|
2009-04-01 21:57:02 +00:00
|
|
|
|
2010-02-26 22:44:39 +00:00
|
|
|
#include "tests.h"
|
|
|
|
#include "config.h"
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-03-07 20:39:56 +00:00
|
|
|
#define LED LED_GREEN
|
2009-04-13 19:54:10 +00:00
|
|
|
|
2009-04-01 21:57:02 +00:00
|
|
|
void main(void) {
|
2010-03-07 02:47:22 +00:00
|
|
|
volatile packet_t *p;
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-03-07 20:39:56 +00:00
|
|
|
*GPIO_DATA0 = 0x00000000;
|
|
|
|
*GPIO_PAD_DIR0 = ( 1 << LED );
|
|
|
|
/* read from the data register instead of the pad */
|
|
|
|
/* this is needed because the led clamps the voltage low */
|
|
|
|
*GPIO_DATA_SEL0 = ( 1 << LED );
|
|
|
|
|
2010-02-26 22:44:39 +00:00
|
|
|
uart_init(INC,MOD);
|
2009-04-01 21:57:02 +00:00
|
|
|
|
2010-03-07 02:47:22 +00:00
|
|
|
print_welcome("rftest-rx");
|
|
|
|
|
2009-04-07 22:19:00 +00:00
|
|
|
reset_maca();
|
2009-04-07 22:52:12 +00:00
|
|
|
radio_init();
|
2009-04-11 21:17:37 +00:00
|
|
|
flyback_init();
|
|
|
|
vreg_init();
|
2009-04-02 22:05:13 +00:00
|
|
|
init_phy();
|
2010-03-07 02:47:22 +00:00
|
|
|
free_all_packets();
|
2009-04-02 22:05:13 +00:00
|
|
|
|
2010-03-01 18:01:51 +00:00
|
|
|
/* trim the reference osc. to 24MHz */
|
|
|
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
|
|
|
|
2009-04-13 18:11:18 +00:00
|
|
|
set_power(0x0f); /* 0dbm */
|
2009-08-04 14:54:23 +00:00
|
|
|
set_channel(0); /* channel 11 */
|
2009-04-07 22:19:00 +00:00
|
|
|
|
2010-03-07 02:47:22 +00:00
|
|
|
enable_irq(MACA);
|
2009-04-02 18:54:02 +00:00
|
|
|
|
2010-03-07 02:47:22 +00:00
|
|
|
/* initial radio command */
|
|
|
|
/* nop, promiscuous, no cca */
|
|
|
|
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
2009-04-02 18:54:02 +00:00
|
|
|
|
|
|
|
while(1) {
|
2010-03-07 02:47:22 +00:00
|
|
|
if((p = rx_packet())) {
|
2010-03-07 20:39:56 +00:00
|
|
|
toggle_gpio0(LED);
|
2010-03-07 02:47:22 +00:00
|
|
|
/* print and free the packet */
|
|
|
|
printf("rftest-rx --- ");
|
|
|
|
print_packet(p);
|
|
|
|
free_packet(p);
|
2009-04-13 19:54:10 +00:00
|
|
|
}
|
2010-03-07 02:47:22 +00:00
|
|
|
}
|
2009-04-01 21:57:02 +00:00
|
|
|
}
|