2012-06-17 04:16:37 +03:00
|
|
|
/*
|
2012-06-19 00:22:56 +03:00
|
|
|
* fw/antorcha.c - Initialization of Antorcha application firmware
|
2012-06-17 04:16:37 +03:00
|
|
|
*
|
|
|
|
* Written 2012 by Werner Almesberger
|
|
|
|
* Copyright 2012 Werner Almesberger
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-06-19 00:22:56 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-06-17 04:16:37 +03:00
|
|
|
#include "rf.h"
|
2012-06-19 00:22:56 +03:00
|
|
|
#include "dispatch.h"
|
2012-06-20 13:26:52 +03:00
|
|
|
#include "sweep.h"
|
2012-06-20 16:41:27 +03:00
|
|
|
#include "image.h"
|
|
|
|
|
|
|
|
|
|
|
|
static struct sweep sweep = {
|
|
|
|
.wait_ticks = 100000, /* 100 ms */
|
|
|
|
.pixel_ticks = 5000, /* 5 ms */
|
|
|
|
.left = 0,
|
|
|
|
.right = MAX_LINES,
|
|
|
|
.forward = 1,
|
|
|
|
};
|
2012-06-17 04:16:37 +03:00
|
|
|
|
|
|
|
|
2012-06-19 00:22:56 +03:00
|
|
|
static const struct handler *protos[] = {
|
2012-06-20 16:30:40 +03:00
|
|
|
&image_handler,
|
2012-06-19 02:31:20 +03:00
|
|
|
&reset_handler,
|
2012-06-19 00:22:56 +03:00
|
|
|
NULL
|
|
|
|
};
|
2012-06-17 04:16:37 +03:00
|
|
|
|
|
|
|
|
2012-06-19 00:22:56 +03:00
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
uint8_t buf[PAYLOAD+5]; /* 3 bytes header, 2 bytes CRC */
|
|
|
|
uint8_t got;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The boot loader has already initialized PORTx, DDRx, and MCUCR.PUD.
|
|
|
|
* It has also brought up RF and the underlying SPI.
|
|
|
|
*/
|
|
|
|
|
2012-06-20 13:26:52 +03:00
|
|
|
sweep_init();
|
|
|
|
|
2012-06-19 00:22:56 +03:00
|
|
|
while (1) {
|
|
|
|
got = rf_recv(buf, sizeof(buf));
|
|
|
|
if (got > 2)
|
|
|
|
dispatch(buf, got-2, protos);
|
2012-06-20 16:41:27 +03:00
|
|
|
if (!sweeping)
|
|
|
|
sweep_image(&sweep);
|
2012-06-17 04:16:37 +03:00
|
|
|
}
|
|
|
|
}
|