-
Notifications
You must be signed in to change notification settings - Fork 95
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
Initial partial SPI support #97
Merged
Merged
+277
−1
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
All code assumes default chip clock configuration. Code assumes STM32F303xB / STM32F3030xC. Code supports only 8 data bits, 1 stop bit.
This is done by implementing `debugWrite()` for the board, which only initializes UART1 if that was not yet done, and flushes afterwards to make sure the host receives all.
This is done by implementing `rx()` and `canRead()`.
This includes correctly masking the parity bit on reads.
Support uart stm32f3discovery: Make UART1 support complete
Allows only writing and reading single bytes.
Now using controller/device terminology, instead of master/slave. Now using 'transfer objects' to make STOPs and re-STARTs explicit, and allow using Writer and Reader APIs. Added 'register' abstraction. STM32F303 I2C now supports this new API, and multi-byte transfers. Now waiting for I2C_ISR.BUSY == 0, after setting I2C_CR2.STOP == 1. Without this, the sequence write-stop-write caused an additional STOP to be sent immediately the START and address of the second write.
It needs to be a non-`comptime` `var` for `@export` to work properly. The only 'documentation' for this behavior currently seems GitHub comment ziglang/zig#5157 (comment) . This issue was introduced in 1c17304 for PR ZigEmbeddedGroup#27, which broke at least ARM-based STM32F303.
Specifically, top-level `Spi` is now `SpiBus`; and the internal API has an additional `switchToDevice()`, and receives `DeviceConfig` in more places.
ikskuh
approved these changes
Feb 1, 2023
mattnite
added a commit
that referenced
this pull request
Feb 26, 2024
mattnite
added a commit
that referenced
this pull request
Feb 26, 2024
mattnite
added a commit
that referenced
this pull request
Mar 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here is an initial SPI support PR; still draft for now, see below.
It adds an API much like in Discord #microzig message https://discord.com/channels/824493524413710336/824629907089784832/947090519484411945.
And an implementation for that API for the STM32F303.
Here is some code that I've got working on my STM32F3DISCOVERY revision E.02 board, which has an I3G4250D gyroscope connected to the STM32's SPI1 with CS on pin PE3:
What really must go in here before merging:
PE3
pin parameter, it is currently hardcoded in the STM32F303 implementation.What should be in here before merging:
transceive...()
functions.Update Dec 31, 2022, 15:03 UTC: All of the above was completed, I consider this PR ready for review, removing draft status.
What I would like to leave for later:
ReadError
orWriteError
values as appropriate.