2010-02-26 17:44:39 -05:00
|
|
|
#include <mc1322x.h>
|
|
|
|
#include <board.h>
|
2010-03-03 13:39:14 -05:00
|
|
|
#include <stdio.h>
|
2009-04-01 17:57:02 -04:00
|
|
|
|
2010-02-26 17:44:39 -05:00
|
|
|
#include "tests.h"
|
|
|
|
#include "config.h"
|
2009-04-02 14:54:02 -04:00
|
|
|
|
2010-03-07 15:39:56 -05:00
|
|
|
#define LED LED_GREEN
|
2009-04-13 15:54:10 -04:00
|
|
|
|
2010-03-08 18:39:08 -05:00
|
|
|
void maca_rx_callback(volatile packet_t *p) {
|
|
|
|
(void)p;
|
2010-03-16 22:03:38 -04:00
|
|
|
gpio_data_set(1ULL<< LED);
|
|
|
|
gpio_data_reset(1ULL<< LED);
|
2010-03-08 18:39:08 -05:00
|
|
|
}
|
2010-03-08 18:12:31 -05:00
|
|
|
|
2009-04-01 17:57:02 -04:00
|
|
|
void main(void) {
|
2010-03-06 21:47:22 -05:00
|
|
|
volatile packet_t *p;
|
2009-04-02 14:54:02 -04:00
|
|
|
|
2010-03-16 22:03:38 -04:00
|
|
|
gpio_data(0);
|
|
|
|
|
|
|
|
gpio_pad_dir_set( 1ULL << LED );
|
2010-03-07 15:39:56 -05:00
|
|
|
/* read from the data register instead of the pad */
|
|
|
|
/* this is needed because the led clamps the voltage low */
|
2010-03-16 22:03:38 -04:00
|
|
|
gpio_data_sel( 1ULL << LED);
|
2010-03-07 15:39:56 -05:00
|
|
|
|
2010-03-08 14:49:31 -05:00
|
|
|
/* trim the reference osc. to 24MHz */
|
2010-03-16 10:40:25 -04:00
|
|
|
trim_xtal();
|
2009-04-01 17:57:02 -04:00
|
|
|
|
2010-03-09 18:23:40 -05:00
|
|
|
uart_init(INC, MOD, SAMP);
|
2010-03-06 21:47:22 -05:00
|
|
|
|
2009-04-11 17:17:37 -04:00
|
|
|
vreg_init();
|
2009-04-02 18:05:13 -04:00
|
|
|
|
2010-03-08 14:49:31 -05:00
|
|
|
maca_init();
|
2010-03-01 13:01:51 -05:00
|
|
|
|
2010-03-08 17:36:42 -05:00
|
|
|
/* sets up tx_on, should be a board specific item */
|
2010-03-16 22:03:38 -04:00
|
|
|
// *GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2));
|
|
|
|
gpio_pad_dir_set( 1ULL << 44 );
|
2010-03-08 18:39:08 -05:00
|
|
|
|
2009-04-13 14:11:18 -04:00
|
|
|
set_power(0x0f); /* 0dbm */
|
2009-08-04 10:54:23 -04:00
|
|
|
set_channel(0); /* channel 11 */
|
2009-04-07 18:19:00 -04:00
|
|
|
|
2010-03-08 14:49:31 -05:00
|
|
|
print_welcome("rftest-rx");
|
2009-04-02 14:54:02 -04:00
|
|
|
while(1) {
|
2010-03-06 21:47:22 -05:00
|
|
|
if((p = rx_packet())) {
|
|
|
|
/* print and free the packet */
|
|
|
|
printf("rftest-rx --- ");
|
|
|
|
print_packet(p);
|
|
|
|
free_packet(p);
|
2009-04-13 15:54:10 -04:00
|
|
|
}
|
2010-03-06 21:47:22 -05:00
|
|
|
}
|
2009-04-01 17:57:02 -04:00
|
|
|
}
|