mirror of
git://projects.qi-hardware.com/ben-wpan.git
synced 2024-11-25 21:18:26 +02:00
atusb/fw/: add SPI block reception
This decreases the retrieval time for a frame of 102 bytes from 660 us to 384 us, corresponding to a speed change from about 1.26 Mbps to 2.17 Mbps (102 bytes plus 2 bytes overhead).
This commit is contained in:
parent
d1b65cb058
commit
7fd9044d94
@ -113,7 +113,7 @@ static void rx_done(void *user)
|
|||||||
|
|
||||||
static void receive_frame(void)
|
static void receive_frame(void)
|
||||||
{
|
{
|
||||||
uint8_t size, i;
|
uint8_t size;
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
|
||||||
spi_begin();
|
spi_begin();
|
||||||
@ -128,8 +128,7 @@ static void receive_frame(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf = rx_buf[rx_in];
|
buf = rx_buf[rx_in];
|
||||||
for (i = 0; i != size+1; i++)
|
spi_recv_block(buf+1, size+1);
|
||||||
buf[i+1] = spi_recv();
|
|
||||||
spi_end();
|
spi_end();
|
||||||
|
|
||||||
buf[0] = size;
|
buf[0] = size;
|
||||||
|
@ -47,6 +47,21 @@ void spi_end(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void spi_recv_block(uint8_t *buf, uint8_t n)
|
||||||
|
{
|
||||||
|
if (!n)
|
||||||
|
return;
|
||||||
|
UDR1 = 0;
|
||||||
|
while (--n) {
|
||||||
|
while (!(UCSR1A & 1 << RXC1));
|
||||||
|
*buf++ = UDR1;
|
||||||
|
UDR1 = 0;
|
||||||
|
}
|
||||||
|
while (!(UCSR1A & 1 << RXC1));
|
||||||
|
*buf++ = UDR1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void spi_off(void)
|
void spi_off(void)
|
||||||
{
|
{
|
||||||
spi_initialized = 0;
|
spi_initialized = 0;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
* fw/spi.h - ATmega8 family SPI I/O
|
* fw/spi.h - ATmega8 family SPI I/O
|
||||||
*
|
*
|
||||||
* Written 2011 by Werner Almesberger
|
* Written 2011, 2013 by Werner Almesberger
|
||||||
* Copyright 2011 Werner Almesberger
|
* Copyright 2011, 2013 Werner Almesberger
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -25,4 +25,6 @@ void spi_init(void);
|
|||||||
#define spi_send(v) (void) spi_io(v)
|
#define spi_send(v) (void) spi_io(v)
|
||||||
#define spi_recv(v) spi_io(0)
|
#define spi_recv(v) spi_io(0)
|
||||||
|
|
||||||
|
void spi_recv_block(uint8_t *buf, uint8_t n);
|
||||||
|
|
||||||
#endif /* !SPI_H */
|
#endif /* !SPI_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user