2014-12-02 17:10:06 -07:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <avr/io.h>
|
|
|
|
|
|
|
|
#include "device.h"
|
|
|
|
#include "hardware/AFSK.h"
|
|
|
|
#include "hardware/Serial.h"
|
|
|
|
#include "protocol/AX25.h"
|
2018-12-27 12:24:21 -07:00
|
|
|
#include "protocol/KISS.h"
|
2019-01-01 12:34:02 -07:00
|
|
|
#include "util/time.h"
|
|
|
|
#include "util/FIFO.h"
|
2014-12-02 17:10:06 -07:00
|
|
|
|
|
|
|
Serial serial;
|
|
|
|
Afsk modem;
|
|
|
|
AX25Ctx AX25;
|
|
|
|
|
2018-12-27 12:24:21 -07:00
|
|
|
static void ax25_callback(struct AX25Ctx *ctx) {
|
|
|
|
kiss_messageCallback(ctx);
|
|
|
|
}
|
2014-12-02 17:10:06 -07:00
|
|
|
|
|
|
|
void init(void) {
|
2014-12-04 07:22:25 -07:00
|
|
|
sei();
|
2014-12-18 15:45:36 -07:00
|
|
|
|
2018-12-27 12:24:21 -07:00
|
|
|
// TODO: serial init was last before
|
2014-12-18 16:15:56 -07:00
|
|
|
serial_init(&serial);
|
|
|
|
stdout = &serial.uart0;
|
|
|
|
stdin = &serial.uart0;
|
|
|
|
|
2018-12-27 12:24:21 -07:00
|
|
|
AFSK_init(&modem);
|
|
|
|
ax25_init(&AX25, &modem, &modem.fd, ax25_callback);
|
2014-12-18 15:45:36 -07:00
|
|
|
|
2018-12-27 12:24:21 -07:00
|
|
|
kiss_init(&AX25, &modem, &serial);
|
2014-12-02 17:10:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int main (void) {
|
|
|
|
init();
|
|
|
|
|
2018-12-27 12:24:21 -07:00
|
|
|
while (true) {
|
|
|
|
ax25_poll(&AX25);
|
|
|
|
|
|
|
|
if (serial_available(0)) {
|
|
|
|
char sbyte = uart0_getchar_nowait();
|
|
|
|
kiss_serialCallback(sbyte);
|
2014-12-18 15:45:36 -07:00
|
|
|
}
|
2018-12-27 12:24:21 -07:00
|
|
|
}
|
2014-12-02 17:10:06 -07:00
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|