-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add support for the AS5x47U encoder #511
Merged
Merged
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
Making tabbing match coding standard for switch cases. Moving comments so they are less confusing.
Adjusting whitespace to adhere to coding style.
Adding support for the AS5x47U encoder.
ZachOB
commented
Jul 20, 2022
Comment on lines
-45
to
+52
palSetPadMode(cfg->sck_gpio, cfg->sck_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->miso_gpio, cfg->miso_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->nss_gpio, cfg->nss_pin, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->mosi_gpio, cfg->mosi_pin, PAL_MODE_ALTERNATE(6) | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->sck_gpio, cfg->sck_pin, | ||
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->miso_gpio, cfg->miso_pin, | ||
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->nss_gpio, cfg->nss_pin, | ||
PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); | ||
palSetPadMode(cfg->mosi_gpio, cfg->mosi_pin, | ||
PAL_MODE_ALTERNATE(cfg->spi_af) | PAL_STM32_OSPEED_HIGHEST); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with this file as a base, and discovered that the alternate pin function was incorrect (at least for the 75_300). I modified the hardware SPI config to include a pin alternate function that is set using a define from hw_config
Looks nice, thanks for the PR! |
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.
This adds support for the SPI based AS5147U and AS5247U encoders. These are basically the same encoder, with the AS5247U just consisting of two AS5147U's stacked on top of each other in the same package.
This encoder is similar to the already supported AS5047 encoder, but includes extra hardware error detection and an 8 bit CRC instead of a parity bit, allowing it to reach automotive ISO26262 safety levels. I have also added an additional fault to better report internal errors reported by the encoder.
The encoder is connected to hardware SPI on the COMM port, requiring the UART app to be disabled and preventing use of ADC2, ADC3, and I2C. The SPI communication is implemented via DMA, resulting in extremely low CPU load. I've also tested to ensure the SPI and DMA are able to recover from all types of errors (disconnection, short to ground, and short to vcc of all 4 wires).
PR to update the VESC tool is here.