From 7017d1286593a2e4a6654f8f0798cd8eab464323 Mon Sep 17 00:00:00 2001 From: NĂ©lio Laranjeiro Date: Thu, 14 Feb 2008 22:26:28 +0100 Subject: Added a function to request the a data from a addr. useful to read memories. --- digital/avr/modules/spi/spi.c | 12 ++++++++++++ digital/avr/modules/spi/spi.h | 7 +++++++ 2 files changed, 19 insertions(+) (limited to 'digital/avr') 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 */ -- cgit v1.2.3