aboutsummaryrefslogtreecommitdiffstats
path: root/docs/spi_driver.md
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2020-04-13 17:09:50 +1000
committerGitHub <noreply@github.com>2020-04-13 17:09:50 +1000
commit46e449376163779413b74f81e320a7d7bbd7e13b (patch)
tree8bd54b95a66d0f2db3a01ce137b3e6bba5ba6f8d /docs/spi_driver.md
parent157d121c71104abb564643f7b6152d149c01fc20 (diff)
downloadfirmware-46e449376163779413b74f81e320a7d7bbd7e13b.tar.gz
firmware-46e449376163779413b74f81e320a7d7bbd7e13b.tar.bz2
firmware-46e449376163779413b74f81e320a7d7bbd7e13b.zip
Fix AVR SPI parameter configuration, remove timeouts due to sync protocol. (#8775)
Diffstat (limited to 'docs/spi_driver.md')
-rw-r--r--docs/spi_driver.md31
1 files changed, 12 insertions, 19 deletions
diff --git a/docs/spi_driver.md b/docs/spi_driver.md
index 360796d2a..e2b5b140b 100644
--- a/docs/spi_driver.md
+++ b/docs/spi_driver.md
@@ -16,7 +16,7 @@ No special setup is required - just connect the `SS`, `SCK`, `MOSI` and `MISO` p
You may use more than one slave select pin, not just the `SS` pin. This is useful when you have multiple devices connected and need to communicate with them individually.
`SPI_SS_PIN` can be passed to `spi_start()` to refer to `SS`.
-## ARM Configuration
+## ChibiOS/ARM Configuration
ARM support for this driver is not ready yet. Check back later!
@@ -28,7 +28,7 @@ Initialize the SPI driver. This function must be called only once, before any of
---
-### `void spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint8_t divisor)`
+### `bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor)`
Start an SPI transaction.
@@ -48,12 +48,16 @@ Start an SPI transaction.
|`2` |Leading edge falling|Sample on leading edge |
|`3` |Leading edge falling|Sample on trailing edge|
- - `uint8_t divisor`
+ - `uint16_t divisor`
The SPI clock divisor, will be rounded up to the nearest power of two. This number can be calculated by dividing the MCU's clock speed by the desired SPI clock speed. For example, an MCU running at 8 MHz wanting to talk to an SPI device at 4 MHz would set the divisor to `2`.
+#### Return Value
+
+`false` if the supplied parameters are invalid or the SPI peripheral is already in use, or `true`.
+
---
-### `spi_status_t spi_write(uint8_t data, uint16_t timeout)`
+### `spi_status_t spi_write(uint8_t data)`
Write a byte to the selected SPI device.
@@ -61,8 +65,6 @@ Write a byte to the selected SPI device.
- `uint8_t data`
The byte to write.
- - `uint16_t timeout`
- The amount of time to wait, in milliseconds, before timing out.
#### Return Value
@@ -70,22 +72,17 @@ Write a byte to the selected SPI device.
---
-### `spi_status_t spi_read(uint16_t timeout)`
+### `spi_status_t spi_read(void)`
Read a byte from the selected SPI device.
-#### Arguments
-
- - `uint16_t timeout`
- The amount of time to wait, in milliseconds, before timing out.
-
#### Return Value
`SPI_STATUS_TIMEOUT` if the timeout period elapses, or the byte read from the device.
---
-### `spi_status_t spi_transmit(const uint8_t *data, uint16_t length, uint16_t timeout)`
+### `spi_status_t spi_transmit(const uint8_t *data, uint16_t length)`
Send multiple bytes to the selected SPI device.
@@ -95,8 +92,6 @@ Send multiple bytes to the selected SPI device.
A pointer to the data to write from.
- `uint16_t length`
The number of bytes to write. Take care not to overrun the length of `data`.
- - `uint16_t timeout`
- The amount of time to wait, in milliseconds, before timing out.
#### Return Value
@@ -104,7 +99,7 @@ Send multiple bytes to the selected SPI device.
---
-### `spi_status_t spi_receive(uint8_t *data, uint16_t length, uint16_t timeout)`
+### `spi_status_t spi_receive(uint8_t *data, uint16_t length)`
Receive multiple bytes from the selected SPI device.
@@ -114,12 +109,10 @@ Receive multiple bytes from the selected SPI device.
A pointer to the buffer to read into.
- `uint16_t length`
The number of bytes to read. Take care not to overrun the length of `data`.
- - `uint16_t timeout`
- The amount of time to wait, in milliseconds, before timing out.
#### Return Value
-`SPI_STATUS_TIMEOUT` if the timeout period elapses, `SPI_STATUS_SUCCESS` on success, or `SPI_STATUS_ERROR` otherwise.
+`SPI_STATUS_TIMEOUT` if the internal transmission timeout period elapses, `SPI_STATUS_SUCCESS` on success, or `SPI_STATUS_ERROR` otherwise.
---