2010-02-27 00:27:58 +01:00
|
|
|
#include <mc1322x.h>
|
|
|
|
#include <board.h>
|
2010-03-02 23:52:31 +01:00
|
|
|
#include <stdio.h>
|
2009-04-02 20:54:02 +02:00
|
|
|
|
2010-02-27 00:27:58 +01:00
|
|
|
#include "tests.h"
|
|
|
|
#include "config.h"
|
2009-04-02 20:54:02 +02:00
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
#define LED LED_RED
|
2009-04-02 20:54:02 +02:00
|
|
|
|
2010-03-07 23:14:00 +01:00
|
|
|
#define PAYLOAD_LEN 120
|
2010-03-07 22:49:57 +01:00
|
|
|
#define DELAY 400000
|
2009-04-14 00:19:13 +02:00
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
void fill_packet(volatile packet_t *p) {
|
|
|
|
static volatile uint8_t count=0;
|
|
|
|
volatile uint8_t i;
|
|
|
|
p->length = PAYLOAD_LEN;
|
2010-03-07 23:04:30 +01:00
|
|
|
p->offset = 0;
|
2009-04-14 00:19:13 +02:00
|
|
|
for(i=0; i<PAYLOAD_LEN; i++) {
|
2010-03-07 22:49:57 +01:00
|
|
|
p->data[i] = count++;
|
2009-04-14 00:19:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-02 20:54:02 +02:00
|
|
|
void main(void) {
|
|
|
|
volatile uint32_t i;
|
2010-03-07 22:49:57 +01:00
|
|
|
volatile packet_t *p;
|
|
|
|
|
|
|
|
*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 );
|
2009-04-02 20:54:02 +02:00
|
|
|
|
2010-02-27 00:27:58 +01:00
|
|
|
uart_init(INC,MOD);
|
2009-04-16 23:59:00 +02:00
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
print_welcome("rftest-tx");
|
|
|
|
|
2009-04-14 00:19:13 +02:00
|
|
|
reset_maca();
|
|
|
|
radio_init();
|
|
|
|
vreg_init();
|
2009-04-16 23:59:00 +02:00
|
|
|
flyback_init();
|
2009-04-03 00:05:13 +02:00
|
|
|
init_phy();
|
2010-03-07 22:49:57 +01:00
|
|
|
free_all_packets();
|
2009-04-03 00:05:13 +02:00
|
|
|
|
2010-03-01 19:01:51 +01:00
|
|
|
/* trim the reference osc. to 24MHz */
|
|
|
|
pack_XTAL_CNTL(CTUNE_4PF, CTUNE, FTUNE, IBIAS);
|
|
|
|
|
2009-04-14 00:19:13 +02:00
|
|
|
set_power(0x0f); /* 0dbm */
|
2009-08-04 16:54:23 +02:00
|
|
|
set_channel(0); /* channel 11 */
|
2009-04-14 00:19:13 +02:00
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
/* initial radio command */
|
|
|
|
/* nop, promiscuous, no cca */
|
|
|
|
*MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE);
|
2009-04-14 00:19:13 +02:00
|
|
|
|
2009-04-02 20:54:02 +02:00
|
|
|
while(1) {
|
2010-03-07 22:49:57 +01:00
|
|
|
|
|
|
|
p = get_free_packet();
|
|
|
|
if(p) {
|
|
|
|
fill_packet(p);
|
2009-04-14 00:19:13 +02:00
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
toggle_gpio0(LED);
|
|
|
|
printf("rftest-tx --- ");
|
|
|
|
print_packet(p);
|
|
|
|
|
|
|
|
tx_packet(p);
|
|
|
|
|
|
|
|
for(i=0; i<DELAY; i++) { continue; }
|
2009-04-14 00:19:13 +02:00
|
|
|
}
|
|
|
|
|
2010-03-07 22:49:57 +01:00
|
|
|
}
|
2009-04-14 00:19:13 +02:00
|
|
|
|
2009-04-02 20:54:02 +02:00
|
|
|
}
|