You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hal/rfcs/0000-spi-overhaul.md
+9-2Lines changed: 9 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,8 @@ In order to provide a meaningful API, this RFC will consider the following use c
57
57
- SPI Slave block transfer : Not supported in current API
58
58
59
59
The asynchronous API is particularly important when dealing with multiple interfaces. Indeed, handling simultaneously two SPI transfers would require two thread with a blocking API while only one is required by the asynchronous API saving kilobytes of RAM.
60
-
60
+
- Half-duplex mode:
61
+
The [LPS22HB](https://www.st.com/en/mems-and-sensors/lps22hb.html) product family can be controlled through a half-duplex SPI interface (called 3 wire mode in the data sheet).
61
62
62
63
## API Changes
63
64
@@ -144,6 +145,7 @@ void spi_free(spi_t *obj);
144
145
- The shortest part of the duty cycle must not be shorter than 50% of the expected period.
145
146
- `spi_init()` initializes the pins leaving the configuration registers unchanged.
146
147
- `spi_init()` ignores the `SS` pin if `is_slave` is false.
148
+
- if `miso` (exclusive) or `mosi` is missing in any function that expects pins, the bus is assumed to be half-duplex.
147
149
- `spi_free()` resets the pins to their default state.
148
150
- `spi_free()` disables the peripheral clock.
149
151
- `spi_format()` sets :
@@ -162,9 +164,13 @@ void spi_free(spi_t *obj);
162
164
- `spi_transfer()` :
163
165
- writes `tx_len` symbols to the bus.
164
166
- reads `rx_len` symbols from the bus.
165
-
- if `rx_len` > `tx_len` then it sends `(rx_len-tx_len)` additional `fill_symbol` to the bus.
166
167
- if `rx` is NULL then inputs are discarded.
167
168
- if `tx` is NULL then `fill_symbol` is used instead.
169
+
- In Full-duplex mode :
170
+
- if `rx_len` > `tx_len` then it sends `(rx_len-tx_len)` additional `fill_symbol` to the bus.
171
+
- In Half-duplex mode :
172
+
- as master, `spi_transfer()` sends `tx_len` symbols and then reads `rx_len` symbols.
173
+
- as slave, `spi_transfer()` receives `rx_len` symbols and then sends `tx_len` symbols.
168
174
- `spi_transter_async()` schedules a transfer to be process the same way ̀`spi_transfer()` would have but asynchronously.
169
175
- `spi_transter_async()` returns immediately with a boolean indicating whether the transfer was successfully scheduled or not.
170
176
- The callback given to `spi_transfer_async()` is invoked when the transfer completes (with a success or an error).
@@ -186,6 +192,7 @@ void spi_free(spi_t *obj);
186
192
- Passing an invalid pointer as `fill_symbol` to `spi_transfer` and `spi_transfer_async` while they would be required by the transfer (`rx_len != tx_len` or `tx==NULL`).
187
193
- Passing an invalid pointer as `handler` to `spi_transfer_async`.
188
194
- Calling `spi_transfer_async_abort()` while no async transfer is being processed (no transfer or a synchronous transfer).
195
+
- In half-duplex mode, any mechanism (if any is present) to detect or prevent collision is implementation defined.
189
196
190
197
### Updated flow
191
198
The IRQ flow has slightly changed. In the new API the flow is as follow :
0 commit comments