projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/easymega-v2.0: Handle different mpu9250 orientation
[fw/altos]
/
src
/
avr
/
ao_spi_slave.c
diff --git
a/src/avr/ao_spi_slave.c
b/src/avr/ao_spi_slave.c
index 76f574c6480f6ac1012f9a43295d1c75fa4a765b..3504739d683d35b9c2e4334917f22be875b61d34 100644
(file)
--- a/
src/avr/ao_spi_slave.c
+++ b/
src/avr/ao_spi_slave.c
@@
-3,7
+3,8
@@
*
* 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
*
* 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; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-18,22
+19,24
@@
#include "ao.h"
uint8_t
#include "ao.h"
uint8_t
-ao_spi_
read(uint8_t *buf, uint8
_t len)
+ao_spi_
slave_recv(void *buf, uint16
_t len)
{
{
+ uint8_t *b = buf;
while (len--) {
while (!(SPSR & (1 << SPIF)))
if ((PINB & (1 << PINB0)))
return 0;
while (len--) {
while (!(SPSR & (1 << SPIF)))
if ((PINB & (1 << PINB0)))
return 0;
- *b
uf
++ = SPDR;
+ *b++ = SPDR;
}
return 1;
}
void
}
return 1;
}
void
-ao_spi_
write(uint8_t *buf, uint8
_t len)
+ao_spi_
slave_send(void *buf, uint16
_t len)
{
{
+ uint8_t *b = buf;
while (len--) {
while (len--) {
- SPDR = *b
uf
++;
+ SPDR = *b++;
while (!(SPSR & (1 << SPIF)))
if ((PINB & (1 << PINB0)))
return;
while (!(SPSR & (1 << SPIF)))
if ((PINB & (1 << PINB0)))
return;
@@
-44,9
+47,8
@@
ao_spi_write(uint8_t *buf, uint8_t len)
static uint8_t ao_spi_slave_running;
static uint8_t ao_spi_slave_running;
-ISR(PCINT0_vect)
+ISR(PCINT0_vect
, ISR_BLOCK
)
{
{
- cli();
#if SPI_SLAVE_PIN_0_3
if ((PINB & (1 << PORTB0)) == 0)
#endif
#if SPI_SLAVE_PIN_0_3
if ((PINB & (1 << PORTB0)) == 0)
#endif
@@
-61,7
+63,6
@@
ISR(PCINT0_vect)
} else {
ao_spi_slave_running = 0;
}
} else {
ao_spi_slave_running = 0;
}
- sei();
}
void
}
void
@@
-87,7
+88,7
@@
ao_spi_slave_init(void)
(1 << 3) | /* MISO, output */
(0 << 2) | /* MOSI, no pull-up */
(0 << 1) | /* SCK, no pull-up */
(1 << 3) | /* MISO, output */
(0 << 2) | /* MOSI, no pull-up */
(0 << 1) | /* SCK, no pull-up */
- (
0 << 0)); /* SS, no
pull-up */
+ (
1 << 0)); /* SS,
pull-up */
#endif
#if SPI_SLAVE_PIN_2_5
PCMSK0 |= (1 << PCINT2); /* Enable PCINT2 pin change */
#endif
#if SPI_SLAVE_PIN_2_5
PCMSK0 |= (1 << PCINT2); /* Enable PCINT2 pin change */
@@
-103,7
+104,7
@@
ao_spi_slave_init(void)
(0 << 5) | /* SCK, no pull-up */
(1 << 4) | /* MISO, output */
(0 << 3) | /* MOSI, no pull-up */
(0 << 5) | /* SCK, no pull-up */
(1 << 4) | /* MISO, output */
(0 << 3) | /* MOSI, no pull-up */
- (
0 << 2)); /* SS, no
pull-up */
+ (
1 << 2)); /* SS,
pull-up */
#endif
SPCR = (0 << SPIE) | /* Disable SPI interrupts */
#endif
SPCR = (0 << SPIE) | /* Disable SPI interrupts */