aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCynerd <cynerd@email.cz>2015-11-03 01:59:14 +0100
committerCynerd <cynerd@email.cz>2015-11-03 01:59:14 +0100
commit96d4026f492b56ac67779ab8e74ed4c483337ec7 (patch)
tree9c2c2006a39e15a561cd2d816bbea91e619b238b /doc
parent7cfe3590af2a05306794dd9bc757920122ab9427 (diff)
downloadavr-ioe-96d4026f492b56ac67779ab8e74ed4c483337ec7.tar.gz
avr-ioe-96d4026f492b56ac67779ab8e74ed4c483337ec7.tar.bz2
avr-ioe-96d4026f492b56ac67779ab8e74ed4c483337ec7.zip
Small updates to spi.md
Diffstat (limited to 'doc')
-rw-r--r--doc/spi.md33
1 files changed, 21 insertions, 12 deletions
diff --git a/doc/spi.md b/doc/spi.md
index 3237882..438d32d 100644
--- a/doc/spi.md
+++ b/doc/spi.md
@@ -1,23 +1,23 @@
Serial peripheral interface
---------------------------
+This interface is link to MOSI and MISO pins. Also SS pin is used when slave mode initialized.
## Functions
### spi_init
```C
static inline void spi_init(enum spiMode mode)
```
-Initializes SPI interface.
-Parameters:
- mode - Specify mode of SPI interface
-
+Initializes SPI interface.
+Parameters:
+ mode - Specify mode of SPI interface
+
NOTE: Global interrupt must be enabled for right function of SPI.
- { SREG |= _BV(7) }
### spi_busy
```C
static inline int8_t spi_busy(void)
```
-Returns NULL when device is not busy.
+Returns NULL when device is not busy.
When device is busy return values in non-zero.
### spi_join
@@ -30,17 +30,17 @@ Blocks processor until device is not busy.
```C
static inline uint8_t spi_send(uint8_t data)
```
-Swap bytes with slave over SPI.
-This function blocks execution until device isn't busy (transfer completed).
+Swap bytes with slave over SPI.
+This function blocks execution until device isn't busy (transfer completed).
WARNING: Invoke this only when interface is initialized in MASTER mode.
### spi_transfer
```C
static inline void spi_transfer(uint8_t data)
```
-Transfer byte to slave over SPI.
-This function isn't blocking execution until transfer is complete.
-Always call spi_join before this function when called outside of spi_receive().
+Transfer byte to slave over SPI.
+This function isn't blocking execution until transfer is complete.
+Always call spi_join before this function when called outside of spi_receive().
WARNING: Invoke this only when interface is initialized in MASTER mode.
### spi_expose
@@ -49,7 +49,7 @@ static inline void spi_expose(uint8_t data)
```
Expose data for next master request.
Please don't use this when device is busy.
-Best place to call this is spi_receive().
+Best place to call this is spi_receive().
WARNING: Invoke this only when interface is initialized in SLAVE mode.
## Function pointer spi_receive
@@ -58,3 +58,12 @@ extern void (*spi_receive)(uint8_t data)
```
This function is called every time transfer is finished.
And until return from this function interrupts are disabled.
+
+## Enum spiMode
+```C
+enum spiMode {
+ SPI_MODE_MASTER,
+ SPI_MODE_SLAVE
+};
+```
+This is used as parameter for spi_init function.