aboutsummaryrefslogtreecommitdiff
path: root/docs/references/spi.md
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-06-30 17:18:49 +0200
committerKarel Kočí <cynerd@email.cz>2016-06-30 17:18:49 +0200
commit4e1ce86af16307bf7d42657db07600867c7c4bbc (patch)
tree5d0dfddea221c91545a9bd57ac7face5842291d4 /docs/references/spi.md
parent147cb7f0e67d1f3c3274effa5476607e24664182 (diff)
downloadavr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.tar.gz
avr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.tar.bz2
avr-ioe-4e1ce86af16307bf7d42657db07600867c7c4bbc.zip
Add some more progress and split non-core functionality to separate repo
More progress to implementation and some changes in project it self. This library will implement only drivers for features on chip but nothing else. Everything connected externally is now in separate repository.
Diffstat (limited to 'docs/references/spi.md')
-rw-r--r--docs/references/spi.md80
1 files changed, 80 insertions, 0 deletions
diff --git a/docs/references/spi.md b/docs/references/spi.md
new file mode 100644
index 0000000..f63d304
--- /dev/null
+++ b/docs/references/spi.md
@@ -0,0 +1,80 @@
+Serial peripheral interface
+===========================
+To use include: `spi.h`
+This interface is link to MOSI and MISO pins. Also SS pin is used when slave mode
+initialized.
+
+Configuration
+-------------
+To use SPI you must enable `CONFIG_SPI` configuration symbol.
+
+References
+----------
+### Function spi\_init
+```C
+static inline void spi_init(enum spiMode mode)
+```
+Initializes SPI interface.
+Parameters:
+ mode - Specify mode of SPI interface
+
+NOTE: Global interrupts must be enabled for right function of SPI.
+
+### Function spi\_busy
+```C
+static inline int8_t spi_busy(void)
+```
+Returns NULL when device is not busy.
+When device is busy return values in non-zero.
+
+### Function spi\_join
+```C
+static inline void spi_join(void)
+```
+Blocks processor until device is not busy.
+
+### Function spi\_send
+```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).
+WARNING: Invoke this only when interface is initialized in MASTER mode.
+
+### Function 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().
+WARNING: Invoke this only when interface is initialized in MASTER mode.
+
+### Function spi\_expose
+```C
+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().
+WARNING: Invoke this only when interface is initialized in SLAVE mode.
+
+### Function pointer spi\_receive
+```C
+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.
+
+Relevant examples
+-----------------
+* spiblink