summaryrefslogtreecommitdiff
path: root/digital/avr
diff options
context:
space:
mode:
authorNélio Laranjeiro2008-02-14 22:26:28 +0100
committerNélio Laranjeiro2008-02-14 22:26:28 +0100
commit7017d1286593a2e4a6654f8f0798cd8eab464323 (patch)
tree4c0d210e4401d7c87bcf18f1f78cedb485722503 /digital/avr
parent5d4ae99fe61fd0d78b8c1523828ed3eefb926ed5 (diff)
Added a function to request the a data from a addr. useful to read
memories.
Diffstat (limited to 'digital/avr')
-rw-r--r--digital/avr/modules/spi/spi.c12
-rw-r--r--digital/avr/modules/spi/spi.h7
2 files changed, 19 insertions, 0 deletions
diff --git a/digital/avr/modules/spi/spi.c b/digital/avr/modules/spi/spi.c
index 1098b260..8fb35bb9 100644
--- a/digital/avr/modules/spi/spi.c
+++ b/digital/avr/modules/spi/spi.c
@@ -91,6 +91,18 @@ spi_recv(void)
return SPDR;
}
+/** Receive a date from the SPI bus from the address provided by parameters.
+ * \param addr the address from which the data shall be read
+ * \return the data at the address requested.
+ */
+uint8_t
+spi_recv_from (uint8_t addr)
+{
+ SPDR = addr;
+
+ return spi_recv();
+}
+
/** Return the status register from the SPI driver.
* \return the status register value
*/
diff --git a/digital/avr/modules/spi/spi.h b/digital/avr/modules/spi/spi.h
index f8771326..59e09fc7 100644
--- a/digital/avr/modules/spi/spi.h
+++ b/digital/avr/modules/spi/spi.h
@@ -91,6 +91,13 @@ spi_send(uint8_t *data, uint8_t length);
uint8_t
spi_recv(void);
+/** Receive a date from the SPI bus from the address provided by parameters.
+ * \param addr the address from which the data shall be read
+ * \return the data at the address requested.
+ */
+uint8_t
+spi_recv_from (uint8_t addr);
+
/** Return the status register from the SPI driver.
* \return the status register value
*/