mirror of
git://projects.qi-hardware.com/antorcha.git
synced 2024-11-22 07:36:17 +02:00
tornado/fw/tornado.c: experimental code to log ADC samples to memory card
For a yet unknown reason, writing to the card fails if also processing the samples. Maybe it's some side-effect of switching the LEDs.
This commit is contained in:
parent
2c7d7b78b0
commit
45f14d214a
@ -8,6 +8,7 @@
|
||||
|
||||
#include "io.h"
|
||||
#include "led.h"
|
||||
#include "mmc.h"
|
||||
#include "accel.h"
|
||||
|
||||
|
||||
@ -106,10 +107,14 @@ static const uint8_t img[] PROGMEM = {
|
||||
};
|
||||
|
||||
|
||||
static uint8_t one[LED_BYTES] =
|
||||
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
|
||||
static volatile uint16_t sample_t = 0, sample_v;
|
||||
|
||||
|
||||
static void zxing(uint16_t x, uint16_t y)
|
||||
{
|
||||
static uint8_t one[LED_BYTES] =
|
||||
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
|
||||
static uint16_t e = 512 << E_SHIFT;
|
||||
static uint32_t m = 512 << M_SHIFT;
|
||||
int16_t d;
|
||||
@ -118,6 +123,10 @@ static void zxing(uint16_t x, uint16_t y)
|
||||
static const prog_uint8_t *p;
|
||||
static uint16_t cols = 0;
|
||||
|
||||
sample_t++;
|
||||
sample_v = x;
|
||||
return;
|
||||
|
||||
e = y+(e-(e >> E_SHIFT));
|
||||
m = y+(m-(m >> M_SHIFT));
|
||||
d = (e >> E_SHIFT)-(m >> M_SHIFT);
|
||||
@ -142,6 +151,18 @@ static void zxing(uint16_t x, uint16_t y)
|
||||
}
|
||||
|
||||
|
||||
static void panic(void)
|
||||
{
|
||||
cli();
|
||||
while (1) {
|
||||
led_show(one);
|
||||
_delay_ms(100);
|
||||
led_off();
|
||||
_delay_ms(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(void)
|
||||
{
|
||||
PORTB = HIGH(B);
|
||||
@ -164,12 +185,85 @@ int main(void)
|
||||
#endif
|
||||
|
||||
led_init();
|
||||
|
||||
#if 0
|
||||
led_show(one);
|
||||
|
||||
if (!mmc_init())
|
||||
panic();
|
||||
if (!mmc_begin_write(0))
|
||||
panic();
|
||||
|
||||
uint16_t n = 0;
|
||||
|
||||
for (n = 0; n != 512; n += 2) {
|
||||
mmc_write(n);
|
||||
mmc_write(n >> 8);
|
||||
}
|
||||
|
||||
if (!mmc_end_write())
|
||||
panic();
|
||||
|
||||
if (!mmc_begin_write(n))
|
||||
panic();
|
||||
|
||||
for (; n != 1024; n += 2) {
|
||||
mmc_write(n);
|
||||
mmc_write(n >> 8);
|
||||
}
|
||||
|
||||
if (!mmc_end_write())
|
||||
panic();
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
led_off();
|
||||
|
||||
while (1);
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
uint16_t last_t = 0;
|
||||
uint32_t n = 0;
|
||||
|
||||
sample = zxing;
|
||||
if (!mmc_init())
|
||||
panic();
|
||||
accel_start();
|
||||
sei();
|
||||
while (1);
|
||||
while (1) {
|
||||
uint16_t t, v;
|
||||
|
||||
if (!(n & 511)) {
|
||||
if (n && !mmc_end_write())
|
||||
panic();
|
||||
if (!mmc_begin_write(n))
|
||||
panic();
|
||||
}
|
||||
|
||||
#if 0
|
||||
t = n;
|
||||
v = 0;
|
||||
#else
|
||||
do {
|
||||
cli();
|
||||
t = sample_t;
|
||||
v = sample_v;
|
||||
sei();
|
||||
}
|
||||
while (t == last_t);
|
||||
#endif
|
||||
|
||||
last_t = t;
|
||||
mmc_write(t);
|
||||
mmc_write(t >> 8);
|
||||
mmc_write(v);
|
||||
mmc_write(v >> 8);
|
||||
n += 4;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static uint8_t p[LED_BYTES];
|
||||
uint8_t mode = 0;
|
||||
uint16_t n = 0, v;
|
||||
|
Loading…
Reference in New Issue
Block a user