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

Enable DMA on AT32F435 SPI #12327

Merged
merged 1 commit into from Feb 8, 2023
Merged

Conversation

SteveCEvans
Copy link
Member

@SteveCEvans SteveCEvans commented Feb 7, 2023

This PR enables SPI DMA for AT32F435 processors and adds definitions to the AT32F435 target to support use of a gyro connected to the J7 connector of the AT-START-F435 eval card. Note that the AT-START-F435 specifics should be removed from the AT32F435 target definition, but this is just a convenience for now.

The gyro used to test this was a widely available BMI160 evaluation card. This source is just given as an example.

IMG_2723

Unfortunately the silk screen on the eval board (and all it's clones that I could find) was wrong.

To save anybody else struggling with this, with reference to the data sheet the wiring for SPI is shown as:

image

The eval card is silkscreened as shown below:

image

The required connections are:

AT-START-F435 J7 Eval card Expected
5V VIN
GND GND
SCLK SCL SCX
MOSI SDA SDX
MISO SA0
NSS CS
PB11 INT 1

The detection of both the interrupt and DMA is confirmed by

# status
MCU AT32F435 Clock=288MHz
Stack size: 2048, Stack address: 0x2002fff0
Configuration: CONFIGURED, size: 3114, max available: 16384
Devices detected: SPI:1
Gyros detected: gyro 1 locked dma
GYRO=BMI160, ACC=BMI160
System Uptime: 84 seconds, Current Time: 2023-02-07T22:41:05.662+00:00
CPU:4%, cycle time: 317, GYRO rate: 3154, RX rate: 15, System rate: 9
Voltage: 0 * 0.01V (0S battery - NOT PRESENT)
I2C Errors: 0
Arming disable flags: RXLOSS ANGLE CLI MSP MOTOR_PROTO

# dma show

Currently active DMA:
--------------------
DMA1 Channel 1: SPI_MOSI 2
DMA1 Channel 2: SPI_MISO 2
DMA1 Channel 3: FREE
DMA1 Channel 4: FREE
DMA1 Channel 5: FREE
DMA1 Channel 6: FREE
DMA1 Channel 7: FREE
DMA2 Channel 1: FREE
DMA2 Channel 2: FREE
DMA2 Channel 3: FREE
DMA2 Channel 4: FREE
DMA2 Channel 5: FREE
DMA2 Channel 6: FREE
DMA2 Channel 7: FREE

The traces below show the SPI transfer reading the gyro/accel date.

image

image

@SteveCEvans SteveCEvans self-assigned this Feb 7, 2023
@github-actions
Copy link

github-actions bot commented Feb 7, 2023

Do you want to test this code? Here you have an automated build:
Assets
WARNING: It may be unstable. Use only for testing! See: https://www.youtube.com/watch?v=I1uN9CN30gw for instructions for unified targets!

@haslinghuis haslinghuis added the Development Instrumentation To be removed before a release label Feb 7, 2023
@haslinghuis haslinghuis added this to the 4.5 milestone Feb 7, 2023
@blckmn
Copy link
Member

blckmn commented Feb 8, 2023

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> PASS
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> FAIL
  • commit count less or equal to three -> PASS
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> PASS
  • approver count at least three -> PASS

@SteveCEvans SteveCEvans merged commit 0ac9962 into betaflight:master Feb 8, 2023
davidbitton pushed a commit to davidbitton/betaflight that referenced this pull request Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: COMPLETED
Development

Successfully merging this pull request may close these issues.

None yet

5 participants