Skip to content

Leonana69/POD-Firmware

Repository files navigation

POD-Firmware

This project is based on the crazyflie-firmware. It uses STM32CubeMX to generate the initialization code and uses HAL library instead of STM32 Standard Peripheral Libraries (SPL), which is deprecated.

Documentation Coming Soon

STM32CubeMX Setup

  1. Active TIM7 as USEC_TIM

    • Prescaler: 84 (ABP1 timer clock / 1000000)
    • Counter Mode: up
    • Counter Period: 0xFFFF (65535)
    • auto-reload preload: Disable
    • Tigger Event Selection: Reset
    • Enable NVIC with Preemption Pri = 4
  2. NVIC

    • ...
  3. SYS

    • Timebase Source: TIM6 (Systick is used by FreeRTOS)
  4. Enable FreeRTOS CMSIS V2

    • ...
  5. Enable I2C1 and I2C3

    • I2C Speed Mode: Fast Mode
    • I2C Clock Speed: 400000
    • Fast Mode Duty Cycle: 2
    • Enable Rx DMA
      • Mode: Normal
      • Increment Address: enable Memory Inc
      • Data Width: Byte, Byte
    • Enable I2C1 event interrupt: 7
    • Enable I2C1 error interrupt: 7
  6. Enable USART6

    • Baud Rate: 1000000
    • Word Length: 8 Bits
    • Parity: None
    • Stop Bits: 1
    • Data Direction: Receive and Transmit
    • Over Sampling: 16 Samples
    • Enable TX DMA: DMA2 Stream 7
    • Pull up GPIOs
    • Enable DMA2 strem7 global interrupt and USART6 global interrupt
  7. Enable PA4 (GPIO_EXTI4)

    • GPIO Mode: External Interrupt Mode with Rising/Falling edge trigger detection
    • GPIO Pull-up/Pull-down: Pull-up
    • NVIC: Enable EXTI line4 interrupt: 5, 0
  8. LED GPIOs

    • PD2, PC0, PC1, PC2, PC3
  9. ...

  10. Enable PC14 (GPIO_EXTI14)

    • GPIO Mode: External Interrupt Mode with Rising edge trigger detection
    • GPIO Pull-up/Pull-down: No
    • NVIC: Enable EXTI line4 interrupt: 5, 0
  11. Motor GPIOs

    • Enable TIM2: Prescaler(0), Mode(Up), Period(255), No Division, Auto-reload(Enable), Trig M/S Mode(Disable), Trig Event Selection(Reset)
      • Channel1: PWM Generation CH1 on PA15
        • Mode: PWM mode 1
        • Pulse: 0
        • Output compare preload: Enable
        • Fast Mode: Disable
        • CH: High
      • Channel2: PWM Generation CH2 on PA1
      • Channel4: PWM Generation CH4 on PB11
    • Enable TIM4: Prescaler(0), Mode(Up), Period(255), No Division, Auto-reload(Enable), Trig M/S Mode(Disable), Trig Event Selection(Reset)
      • Channel4: PWM Generation CH4 on PB9
    • The HAL_TIM_PWM_START needs to be called to enable the output.
  12. Enable SPI1 and GPIO PB4

    • Mode: Full-Duplex Master
    • Prescaler: 64
    • Enable Rx DMA: DMA2 Stream 0
      • NVIC PP: 7
    • Enable Tx DMA: DMA2 Stream 5
      • NVIC PP: 7

Modifications to Auto-generated Files

STM32F405RGTx_FLASH.ld

Change the flash origin address to 0x8004000:

FLASH (rx) : ORIGIN = 0x8004000, LENGTH = 1008K

Add _param and _log to .text section.

stm32f4xx_it.c

freertos.c

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages