2014-04-03 14:21:37 -06:00
|
|
|
|
|
|
|
#include <cpu/irq.h>
|
|
|
|
#include <cfg/debug.h>
|
|
|
|
|
2014-04-04 03:17:47 -06:00
|
|
|
#include "afsk.h" // Header for AFSK modem
|
|
|
|
#include "protocol/mp1.h" // Header for MP.1 protocol
|
2014-04-03 14:21:37 -06:00
|
|
|
|
|
|
|
#include <drv/ser.h>
|
|
|
|
#include <drv/timer.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static Afsk afsk;
|
|
|
|
static Serial ser;
|
|
|
|
|
2014-04-04 03:17:47 -06:00
|
|
|
static MP1 mp1;
|
|
|
|
|
2014-04-03 14:21:37 -06:00
|
|
|
#define ADC_CH 0
|
|
|
|
|
2014-04-04 03:40:43 -06:00
|
|
|
#define TEST_PACKET "Test MP1 AFSK Packet!"
|
2014-04-03 16:39:51 -06:00
|
|
|
|
2014-04-04 03:17:47 -06:00
|
|
|
static void mp1Callback(struct MP1Packet *packet) {
|
|
|
|
kfile_printf(&ser.fd, "\nMP1 Packet Received:\n");
|
|
|
|
kfile_printf(&ser.fd, "%.*s\r\n", packet->dataLength, packet->data);
|
|
|
|
}
|
2014-04-03 16:39:51 -06:00
|
|
|
|
2014-04-03 14:21:37 -06:00
|
|
|
static void init(void)
|
|
|
|
{
|
|
|
|
IRQ_ENABLE;
|
|
|
|
kdbg_init();
|
|
|
|
timer_init();
|
|
|
|
|
|
|
|
afsk_init(&afsk, ADC_CH, 0);
|
2014-04-04 03:17:47 -06:00
|
|
|
mp1Init(&mp1, &afsk.fd, mp1Callback);
|
|
|
|
|
2014-04-03 14:21:37 -06:00
|
|
|
|
|
|
|
ser_init(&ser, SER_UART0);
|
|
|
|
ser_setbaudrate(&ser, 115200);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
init();
|
2014-04-03 16:39:51 -06:00
|
|
|
ticks_t start = timer_clock();
|
2014-04-03 14:21:37 -06:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2014-04-04 03:17:47 -06:00
|
|
|
mp1Poll(&mp1);
|
2014-04-03 16:39:51 -06:00
|
|
|
|
2014-04-04 03:40:43 -06:00
|
|
|
// Periodically send test data
|
2014-04-04 00:48:34 -06:00
|
|
|
if (timer_clock() - start > ms_to_ticks(4000L))
|
2014-04-03 16:39:51 -06:00
|
|
|
{
|
|
|
|
kputs("Test TX\n");
|
|
|
|
start = timer_clock();
|
2014-04-04 03:40:43 -06:00
|
|
|
mp1Send(&mp1, TEST_PACKET, sizeof(TEST_PACKET));
|
2014-04-03 16:39:51 -06:00
|
|
|
}
|
2014-04-03 14:21:37 -06:00
|
|
|
}
|
|
|
|
return 0;
|
2014-04-03 14:41:49 -06:00
|
|
|
}
|