MicroModemGP/main.c

58 lines
1.1 KiB
C
Raw Permalink Normal View History

2015-04-26 21:23:13 +02:00
#include <stdbool.h>
2015-04-26 22:06:55 +02:00
#include <string.h>
2015-04-26 21:23:13 +02:00
#include <avr/io.h>
#include "device.h"
#include "config.h"
2015-04-26 21:23:13 +02:00
#include "util/FIFO.h"
#include "util/time.h"
#include "hardware/AFSK.h"
#include "hardware/Serial.h"
#include "protocol/AX25.h"
2015-04-26 22:06:55 +02:00
#include "protocol/LLP.h"
#include "protocol/KISS.h"
2015-04-26 21:23:13 +02:00
Serial serial;
Afsk modem;
2015-04-26 22:06:55 +02:00
LLPAddress localAdress;
LLPCtx llp;
2015-04-26 21:23:13 +02:00
2015-04-26 22:06:55 +02:00
static void llp_callback(struct LLPCtx *ctx) {
kiss_messageCallback(ctx);
}
2015-04-26 21:23:13 +02:00
void init(void) {
sei();
AFSK_init(&modem);
2015-04-26 22:06:55 +02:00
memset(&localAdress, 0, sizeof(localAdress));
2015-05-21 00:00:15 +02:00
localAdress.network = LLP_ADDR_BROADCAST;
localAdress.host = LLP_ADDR_BROADCAST;
2015-04-26 22:06:55 +02:00
llp_init(&llp, &localAdress, &modem.fd, llp_callback);
2015-04-26 21:23:13 +02:00
serial_init(&serial);
stdout = &serial.uart0;
stdin = &serial.uart0;
2015-04-26 22:06:55 +02:00
kiss_init(&llp, &modem, &serial);
2015-04-26 21:23:13 +02:00
}
int main (void) {
init();
2015-04-26 22:06:55 +02:00
while (true) {
llp_poll(&llp);
if (serial_available(0)) {
char sbyte = uart0_getchar_nowait();
kiss_serialCallback(sbyte);
2015-04-26 21:23:13 +02:00
}
#if SERIAL_FRAMING == SERIAL_FRAMING_DIRECT
kiss_checkTimeout(false);
#endif
2015-04-26 22:06:55 +02:00
}
2015-04-26 21:23:13 +02:00
return(0);
}