Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about SPI ASYNCH transfer API (documentation need?) #2599

Closed
LMESTM opened this issue Sep 1, 2016 · 14 comments
Closed

Question about SPI ASYNCH transfer API (documentation need?) #2599

LMESTM opened this issue Sep 1, 2016 · 14 comments

Comments

@LMESTM
Copy link
Contributor

LMESTM commented Sep 1, 2016

Hello

I've started to deliver STM32 support for SPI ASYNCH. While doing this, I discussed with colleagues and this triggered a question on the trasnfer asynch API (documented here and header file) https://developer.mbed.org/users/mbed_official/code/mbed/docs/6c34061e7c34/group__AsynchSPI.html

The SPI transfer API is very similar to I2C one.
In I2C, even if this is not clearly documented (AFAIK), the transfer consist in sending a Tx command (with Tx_lenght) and then reading the Rx response from slave (with Rx_lenght that might be different from Tx_lenght). Very useful for using many I2C devices indeed.
Note that this could help new comers to explicitely explain that Tx happens first, then Rx happens.

Now coming to my SPI question: do we expect a similar steps approach as in I2C, that is, sending a command, then reading the corresponding response. That could make it easy to use some SPI devices ... or do we consider that because SPI is full duplex (Rx and Tx can happen at the same time) so transfer of Tx and Rx shall happen simultenaously. This takes benefit of the full duplex link, but this is not clear to us which SPI devices would benefit of such interface. For full duplex communication, one could easily consider that having the same Rx and Tx lenght makes things simpler (and allow full usage of the bandwidth).

Thanks in advance for clarifiying this point,
Br
Laurent

@LMESTM
Copy link
Contributor Author

LMESTM commented Sep 8, 2016

@Sissors hi - do you have a view or even final answer to the above questions ?

@Sissors
Copy link
Contributor

Sissors commented Sep 8, 2016

Are you sure you meant me? Because I have an opinion. I have an opinion about many things. But few people here really care about it :P.

I agree with your statement that there are very few SPI devices that actually really use full duplex. At the same time I feel that SPI is a full duplex protocol, and I wouldn't limit it to half duplex in the API. Also for example if you need to send 2 bytes to request 500 bytes, you can just send those 2 synchronous, and then start an asynchronous operation for those 500 bytes.

Now what I do dislike about the (SPI) async API, is that in my opinion it is needlessly complicated: As you mentioned why would you have different read and write lengths if you do both at the same time? And if your read is shorter than your write, do you not read at the beginning or at the end of the transaction?. And I really miss the possibility to easily send constant values, which is extensively used in for example LCD TFT displays, but also has some other use cases.

@LMESTM
Copy link
Contributor Author

LMESTM commented Sep 8, 2016

Yes I was right to ask for your opinion because now there is a discussion :-) - and I feel like we're on the same line here. So that may pop up higher in the pile of issues ...
Now I still would be happy to get MBED staff' word on this topic

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 12, 2016

Now what I do dislike about the (SPI) async API, is that in my opinion it is needlessly complicated: As you mentioned why would you have different read and write lengths if you do both at the same time?

And if your read is shorter than your write, do you not read at the beginning or at the end of the transaction?

This was highlighted previously, we agreed that this could be done. We can still add a new transfer method with just one length argument, and deprecate the rx/tx lengths.

And I really miss the possibility to easily send constant values, which is extensively used in for example LCD TFT displays, but also has some other use cases.

Any proposals for this. We discussed earlier to reuse default SPI write value or introduce a new transfer with just 2 arguments?

// constant value transferred
spi.transfer(value, count, callback, event_type);

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 12, 2016

Besides adding new API or deprecating, how the docs can be improved @LMESTM ? Please send a pull request or pinpoint here what's missing. Thanks

@LMESTM
Copy link
Contributor Author

LMESTM commented Sep 12, 2016

@0xc0170 : the doc here https://developer.mbed.org/users/mbed_official/code/mbed/docs/6c34061e7c34/group__AsynchSPI.html says :

Begin the SPI transfer.

This needs to be clarified to specify whether Rx and Tx will happen at the same time or if Rx happens first and then Tx will go on in a second step. Once decided, we can conclude on how to actually send a PR for updating the description (and maybe APIs)

there is also a note below which seems outdated I think as we now have a pointer and a length as paramters

Buffer pointers and lengths are specified in tx_buff and rx_buff

@LMESTM
Copy link
Contributor Author

LMESTM commented Sep 12, 2016

@0xc0170 reading again your comment

This was highlighted previously, we agreed that this could be done. We can still add a new transfer method with just one length argument, and deprecate the rx/tx lengths.

does it mean that the answer to my question is : SPI transfer API is meant for sending both Tx and Rx at the same time (full duplex) ?

@Sissors
Copy link
Contributor

Sissors commented Sep 12, 2016

Any proposals for this. We discussed earlier to reuse default SPI write value or introduce a new transfer with just 2 arguments?

One option I see would be just get the current one:
int transfer(const Type *tx_buffer, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT), and add the function:

int transfer(const Type tx_value, int tx_length, Type *rx_buffer, int rx_length, const event_callback_t& callback, int event = SPI_EVENT)

(and then the lengths merged also into one length argument). I don't know if that will be save with the template that is used, and I can imagine it could cause confusion maybe sometimes. But my initial idea would be to just re-use the same function, only instead of a pointer to a buffer, give a value. Alternative would be calling it 'transfer_value', or 'transfer_constant'.

How that is being handled then in the API code would be another question (quite easy to implement, but it must be implemented).

@LMESTM
Copy link
Contributor Author

LMESTM commented Sep 13, 2016

Hi all

I know understand that yes the answer to my question is :
SPI transfer API is meant for sending both Tx and Rx at the same time (full duplex) ?

And I now understand that transfer API is meant to be used with;
Tx only with Tx size (and Rx null / rx size 0)
Rx only (and Tx null / Tx size 0)
Rx and Tx with same size
Rx and Tx with different doesn't seem to make much sense and makes things much more complex in the target layers ... so I'll consider to not support this case in my ongoing developments.

Is this a common understanding and shall we make such comments in the API description ?

If ok, the issue can be closed on my side.
Another one could be created to follow-up on Sissors proposal for sending constants

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 14, 2016

Another one could be created to follow-up on Sissors proposal for sending constants

+1, shall be separete issue

Is this a common understanding and shall we make such comments in the API description ?

Please send a patch for the documentation of those functions.

@AnotherButler
Copy link
Contributor

@LMESTM Do you think we still need to add comments to the API description, or is it OK to close this issue?

@LMESTM
Copy link
Contributor Author

LMESTM commented Jan 25, 2017

@AnotherButler
yes I still think this could help new comers.
I don't know how to update this page
https://developer.mbed.org/users/mbed_official/code/mbed/docs/6c34061e7c34/group__AsynchSPI.html
Would someone at ARM take care of the update ?

@Sissors
Copy link
Contributor

Sissors commented Jan 25, 2017

That should be generated from the Doxygen automatically. I think for update to documentation also this issue is relevant to take into account: #3261

@AnotherButler
Copy link
Contributor

@0xc0170 Are you the best person to help with this?

@ghost ghost closed this as completed Oct 27, 2017
artokin pushed a commit to artokin/mbed-os that referenced this issue Apr 15, 2021
…..0903b81

0903b81 Merge remote-tracking branch 'origin/release_internal' into release_external
51429c9 FHSS WS: api function to set TX allowance level (ARMmbed#2612)
01b1188 Fix Child NUD with long ARO registrations
20b49ce Optimize out of memory handler to remove more memory in EF mode
f1b03bc FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609)
2f5e5e2 Generic forwarding callback and EF state enabler for Wi-SUN BBR.
007dfa2 Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607)
6524872 Implemented FHSS expedited forwarding mode (ARMmbed#2606)
91e0b4c QoS traffic class documentation update.
3acd3a4 Fix warnings found by cppcheck (ARMmbed#2605)
d2f5347 MPX and MAC API update
7310cc0 MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602)
cd109c3 Clear Ack tx and tx process in MAC reset (ARMmbed#2601)
45504fd Optimize stagger based on uptime and startup type
ed5209e Iotthd 4584 (ARMmbed#2599)
60726dc Fixed blacklisting overflow (ARMmbed#2597)
23334b7 Added support for High Priority forward state
3ec2a2c Corrected freed memory access on incoming EAPOL handling
aecadc4 Fixed delayed interrupt (ARMmbed#2596)
1fca2c1 CCA backoffs max to 9 (ARMmbed#2595)
f3d2fa1 Added API function to get neighbor table information from Wi-SUN
3bb089b Validate randomized fixed channel (ARMmbed#2592)
70743a1 MAC stabilisation fixes (ARMmbed#2591)
e936a26 Reduce periodic DNS traces
a45fe3f Improved CSMA-CA logic for Wi-SUN (ARMmbed#2585)
56b7735 improved Wi-SUN stack statistics added
e656190 Wi-SUN neighbour allocate update
799f837 Added address check for Whiteboard address ADD
0b6caa3 Wi-SUN network timing parameter tuning
4921465 Supress warnings
f5cecd7 Enable external connection for routers
e129a0a Added LLC EAPOL temporary neighbor remove when authentication completes (ARMmbed#2583)
fa20fb9 Added calculation of LLC and LLC EAPOL message queue average (ARMmbed#2582)
7f7c01a Added retry traces to authenticator EAP-TLS, 4WH, and GKH
a87646d On startup deletes NVM GTKs if EUI-64 has been changed (ARMmbed#2576)
509a6f9 Add CI commands to PR template (ARMmbed#2579)
eb6a4f7 Change stagger calculation to give more bandwidth to application
82f1d54 Wi-SUN bpptstrap clear destination cache at discovery phase.
71b0588 Destination cache update:
f92c385 Enabled PMTU timeout to destination cache after used.
957b358 DHCP server and Agent relay update

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 0903b81
artokin pushed a commit to artokin/mbed-os that referenced this issue Apr 20, 2021
…..0903b81

0903b81 Merge remote-tracking branch 'origin/release_internal' into release_external
51429c9 FHSS WS: api function to set TX allowance level (ARMmbed#2612)
01b1188 Fix Child NUD with long ARO registrations
20b49ce Optimize out of memory handler to remove more memory in EF mode
f1b03bc FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609)
2f5e5e2 Generic forwarding callback and EF state enabler for Wi-SUN BBR.
007dfa2 Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607)
6524872 Implemented FHSS expedited forwarding mode (ARMmbed#2606)
91e0b4c QoS traffic class documentation update.
3acd3a4 Fix warnings found by cppcheck (ARMmbed#2605)
d2f5347 MPX and MAC API update
7310cc0 MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602)
cd109c3 Clear Ack tx and tx process in MAC reset (ARMmbed#2601)
45504fd Optimize stagger based on uptime and startup type
ed5209e Iotthd 4584 (ARMmbed#2599)
60726dc Fixed blacklisting overflow (ARMmbed#2597)
23334b7 Added support for High Priority forward state
3ec2a2c Corrected freed memory access on incoming EAPOL handling
aecadc4 Fixed delayed interrupt (ARMmbed#2596)
1fca2c1 CCA backoffs max to 9 (ARMmbed#2595)
f3d2fa1 Added API function to get neighbor table information from Wi-SUN
3bb089b Validate randomized fixed channel (ARMmbed#2592)
70743a1 MAC stabilisation fixes (ARMmbed#2591)
e936a26 Reduce periodic DNS traces
a45fe3f Improved CSMA-CA logic for Wi-SUN (ARMmbed#2585)
56b7735 improved Wi-SUN stack statistics added
e656190 Wi-SUN neighbour allocate update
799f837 Added address check for Whiteboard address ADD
0b6caa3 Wi-SUN network timing parameter tuning
4921465 Supress warnings
f5cecd7 Enable external connection for routers
e129a0a Added LLC EAPOL temporary neighbor remove when authentication completes (ARMmbed#2583)
fa20fb9 Added calculation of LLC and LLC EAPOL message queue average (ARMmbed#2582)
7f7c01a Added retry traces to authenticator EAP-TLS, 4WH, and GKH
a87646d On startup deletes NVM GTKs if EUI-64 has been changed (ARMmbed#2576)
509a6f9 Add CI commands to PR template (ARMmbed#2579)
eb6a4f7 Change stagger calculation to give more bandwidth to application
82f1d54 Wi-SUN bpptstrap clear destination cache at discovery phase.
71b0588 Destination cache update:
f92c385 Enabled PMTU timeout to destination cache after used.
957b358 DHCP server and Agent relay update
25b9124 Merge remote-tracking branch 'origin/release_internal' into release_external
c825b04 Corrected covery warning on delay_us multiplication
be63bbb Updated changelog
77a76c7 Corrected nw size set on automatic mode
65e6c2d Updated unit tests
16e3402 Added waiting queue to EAPOL authentications to Border Router
b9c0b7d Wi-SUN border router starts faster in static configuration
2f427e1 Local repair start and stop clear advertised_dodag_membership_since_last_repair when state is updated.
0a01ab1 RPL dio send update
dd39963 Wi-SUN Border router uses Static address as DODAGID
7a3c833 Additional check to detect parent connection problem
ffe48c9 WS management: domain configuration functions implemented (ARMmbed#2567)
5e9ac4e Added new Callback to RPL indicate Multicast DIS received from RPL Parent
85b949e Bootstrap and EAPOL treats all MAC TX failure causes similarly
b57d9bc Add support for anonymous addressing in Wi-SUN border router (ARMmbed#2565)
7400c8b CFG: API for PHY mode id and channel plan id get & validate (ARMmbed#2564)
2832fe8 Added Socket reference limitter
890aad1 Wi-SUN MTU size update and IPv6 minium MTU routing skip
3ad28c1 Added throttling of number of simultaneous EAPOL authentications
0b84299 Source route handler call Wi-Sun border router alive function.
c8343b1 Added support for dynamic RPL default lifetime
d258068 Iotthd 4478 (ARMmbed#2560)
7ca6c24 Enable and modify memory limits for packet receiving
e2b028d Close CHANGELOG.md for v12.8.1 (ARMmbed#2557)
91f3ff6 Merge branch 'release_internal' into release_external
3999b6e Iotthd 4495 (ARMmbed#2556)
90c3263 RPL Prefix handling update:
f761409 Close Nanostack v12.8.0 ChangeLog (ARMmbed#2549)
f8ae0e9 Merge remote-tracking branch 'origin/release_internal' into release_external
3275f83 Added support for handle RPL hop by Hop sender rank 0.
d62c589 Activated RPL force tunnel for wi-sun.
3e1064a RPL tunnel force functionality update
3207e5c RPL parent select timer random update from 1.0-1.2 to 1.0-1.5.
bc09cba MAC Ack wait fixed for OFDM (ARMmbed#2552)
5106b1d Fixed unused variable and function warnings.
4096c1a Wi-SUN bootstrap support RPL poison from Connected state to Discovery
66378d1 RPL Poison update

git-subtree-dir: features/nanostack/sal-stack-nanostack
git-subtree-split: 0903b81
artokin pushed a commit to artokin/mbed-os that referenced this issue Apr 21, 2021
…183d87..0903b81

0903b81 Merge remote-tracking branch 'origin/release_internal' into release_external
51429c9 FHSS WS: api function to set TX allowance level (ARMmbed#2612)
01b1188 Fix Child NUD with long ARO registrations
20b49ce Optimize out of memory handler to remove more memory in EF mode
f1b03bc FHSS WS: Allow transmitting unicast frames on broadcast channel for 1st hop node in EF mode (ARMmbed#2609)
2f5e5e2 Generic forwarding callback and EF state enabler for Wi-SUN BBR.
007dfa2 Allow transmitting on RX slot for 1st hop device in expedited forwarding mode (ARMmbed#2607)
6524872 Implemented FHSS expedited forwarding mode (ARMmbed#2606)
91e0b4c QoS traffic class documentation update.
3acd3a4 Fix warnings found by cppcheck (ARMmbed#2605)
d2f5347 MPX and MAC API update
7310cc0 MAC: "CCA fail on RX" event for TX done callback (ARMmbed#2602)
cd109c3 Clear Ack tx and tx process in MAC reset (ARMmbed#2601)
45504fd Optimize stagger based on uptime and startup type
ed5209e Iotthd 4584 (ARMmbed#2599)
60726dc Fixed blacklisting overflow (ARMmbed#2597)
23334b7 Added support for High Priority forward state
3ec2a2c Corrected freed memory access on incoming EAPOL handling
aecadc4 Fixed delayed interrupt (ARMmbed#2596)
1fca2c1 CCA backoffs max to 9 (ARMmbed#2595)
f3d2fa1 Added API function to get neighbor table information from Wi-SUN
3bb089b Validate randomized fixed channel (ARMmbed#2592)
70743a1 MAC stabilisation fixes (ARMmbed#2591)
e936a26 Reduce periodic DNS traces
a45fe3f Improved CSMA-CA logic for Wi-SUN (ARMmbed#2585)
56b7735 improved Wi-SUN stack statistics added
e656190 Wi-SUN neighbour allocate update
799f837 Added address check for Whiteboard address ADD
0b6caa3 Wi-SUN network timing parameter tuning
4921465 Supress warnings
f5cecd7 Enable external connection for routers
e129a0a Added LLC EAPOL temporary neighbor remove when authentication completes (ARMmbed#2583)
fa20fb9 Added calculation of LLC and LLC EAPOL message queue average (ARMmbed#2582)
7f7c01a Added retry traces to authenticator EAP-TLS, 4WH, and GKH
a87646d On startup deletes NVM GTKs if EUI-64 has been changed (ARMmbed#2576)
509a6f9 Add CI commands to PR template (ARMmbed#2579)
eb6a4f7 Change stagger calculation to give more bandwidth to application
82f1d54 Wi-SUN bpptstrap clear destination cache at discovery phase.
71b0588 Destination cache update:
f92c385 Enabled PMTU timeout to destination cache after used.
957b358 DHCP server and Agent relay update
25b9124 Merge remote-tracking branch 'origin/release_internal' into release_external
c825b04 Corrected covery warning on delay_us multiplication
be63bbb Updated changelog
77a76c7 Corrected nw size set on automatic mode
65e6c2d Updated unit tests
16e3402 Added waiting queue to EAPOL authentications to Border Router
b9c0b7d Wi-SUN border router starts faster in static configuration
2f427e1 Local repair start and stop clear advertised_dodag_membership_since_last_repair when state is updated.
0a01ab1 RPL dio send update
dd39963 Wi-SUN Border router uses Static address as DODAGID
7a3c833 Additional check to detect parent connection problem
ffe48c9 WS management: domain configuration functions implemented (ARMmbed#2567)
5e9ac4e Added new Callback to RPL indicate Multicast DIS received from RPL Parent
85b949e Bootstrap and EAPOL treats all MAC TX failure causes similarly
b57d9bc Add support for anonymous addressing in Wi-SUN border router (ARMmbed#2565)
7400c8b CFG: API for PHY mode id and channel plan id get & validate (ARMmbed#2564)
2832fe8 Added Socket reference limitter
890aad1 Wi-SUN MTU size update and IPv6 minium MTU routing skip
3ad28c1 Added throttling of number of simultaneous EAPOL authentications
0b84299 Source route handler call Wi-Sun border router alive function.
c8343b1 Added support for dynamic RPL default lifetime
d258068 Iotthd 4478 (ARMmbed#2560)
7ca6c24 Enable and modify memory limits for packet receiving
e2b028d Close CHANGELOG.md for v12.8.1 (ARMmbed#2557)
91f3ff6 Merge branch 'release_internal' into release_external
3999b6e Iotthd 4495 (ARMmbed#2556)
90c3263 RPL Prefix handling update:
f761409 Close Nanostack v12.8.0 ChangeLog (ARMmbed#2549)
f8ae0e9 Merge remote-tracking branch 'origin/release_internal' into release_external
3275f83 Added support for handle RPL hop by Hop sender rank 0.
d62c589 Activated RPL force tunnel for wi-sun.
3e1064a RPL tunnel force functionality update
3207e5c RPL parent select timer random update from 1.0-1.2 to 1.0-1.5.
bc09cba MAC Ack wait fixed for OFDM (ARMmbed#2552)
5106b1d Fixed unused variable and function warnings.
4096c1a Wi-SUN bootstrap support RPL poison from Connected state to Discovery
66378d1 RPL Poison update

git-subtree-dir: connectivity/nanostack/sal-stack-nanostack
git-subtree-split: 0903b81
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants