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