STM32H7 SpiComIF and first device handler #9

Merged
muellerr merged 36 commits from mueller/stm32h7-spi-com-if-l3gd20h-handler into master 2021-06-15 15:50:54 +02:00
Owner

This was a lot more work than expected..

  • Added SpiComIF for the STM32H7. Only tested for the H743ZI board
  • Added L3GD20 device handler. Device handlers are generic, so we can add them here as well
  • Tested all 3 transfer modes: Polling, IRQ and DMA. All STM32H7 peripherals offer the same modes, so this ComIF will be an ideal base to implement other communication interfaces.
  • Only tested with one device
  • No GpioIF* which would allow custom callbacks. Not worth the effort as long as noone requires it explicitely.. Simple prototyping usually does not require complex decoding logic, SPI chip select are simply driven by dedicated GPIO pins
  • Bugfixes for the L3GD20H device, conversion was not exactly correct
  • No ugly macro magic necessary for complete MSP configuration, replaced by proper structs at the price of code size. MSP config struct is deleted automatically by the SpiComIF. Here is the example testing code:
    spi::MspCfgBase* mspCfg = nullptr;
    spi::TransferModes transferMode = spi::TransferModes::DMA;
    if(transferMode == spi::TransferModes::POLLING) {
        auto typedCfg = new spi::MspPollingConfigStruct();
        spi::h743zi::standardPollingCfg(*typedCfg);
        mspCfg = typedCfg;
    }
    else if(transferMode == spi::TransferModes::INTERRUPT) {
        auto typedCfg = new spi::MspIrqConfigStruct();
        spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS);
        mspCfg = typedCfg;
    }
    else if(transferMode == spi::TransferModes::DMA) {
        auto typedCfg = new spi::MspDmaConfigStruct();
        txHandle = new DMA_HandleTypeDef();
        rxHandle = new DMA_HandleTypeDef();
        spi::setDmaHandles(txHandle, rxHandle);
        spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS,
                IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS);
        mspCfg = typedCfg;
    }

    new SpiComIF(objects::SPI_COM_IF);
    auto spiCookie = new SpiCookie(0, spi::SpiBus::SPI_1, transferMode, mspCfg, 3900000,
            spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32);
    auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF,
            spiCookie);
    gyroDevice->setStartUpImmediately();
    gyroDevice->setGoNormalModeAtStartup();
This was a lot more work than expected.. - Added `SpiComIF` for the STM32H7. Only tested for the H743ZI board - Added L3GD20 device handler. Device handlers are generic, so we can add them here as well - Tested all 3 transfer modes: Polling, IRQ and DMA. All STM32H7 peripherals offer the same modes, so this ComIF will be an ideal base to implement other communication interfaces. - Only tested with one device - No GpioIF* which would allow custom callbacks. Not worth the effort as long as noone requires it explicitely.. Simple prototyping usually does not require complex decoding logic, SPI chip select are simply driven by dedicated GPIO pins - Bugfixes for the L3GD20H device, conversion was not exactly correct - No ugly macro magic necessary for complete MSP configuration, replaced by proper structs at the price of code size. MSP config struct is deleted automatically by the `SpiComIF`. Here is the example testing code: ```cpp spi::MspCfgBase* mspCfg = nullptr; spi::TransferModes transferMode = spi::TransferModes::DMA; if(transferMode == spi::TransferModes::POLLING) { auto typedCfg = new spi::MspPollingConfigStruct(); spi::h743zi::standardPollingCfg(*typedCfg); mspCfg = typedCfg; } else if(transferMode == spi::TransferModes::INTERRUPT) { auto typedCfg = new spi::MspIrqConfigStruct(); spi::h743zi::standardInterruptCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS); mspCfg = typedCfg; } else if(transferMode == spi::TransferModes::DMA) { auto typedCfg = new spi::MspDmaConfigStruct(); txHandle = new DMA_HandleTypeDef(); rxHandle = new DMA_HandleTypeDef(); spi::setDmaHandles(txHandle, rxHandle); spi::h743zi::standardDmaCfg(*typedCfg, IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS, IrqPriorities::HIGHEST_FREERTOS); mspCfg = typedCfg; } new SpiComIF(objects::SPI_COM_IF); auto spiCookie = new SpiCookie(0, spi::SpiBus::SPI_1, transferMode, mspCfg, 3900000, spi::SpiModes::MODE_3, GPIO_PIN_14, GPIOD, 32); auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF, spiCookie); gyroDevice->setStartUpImmediately(); gyroDevice->setGoNormalModeAtStartup(); ```
muellerr added 36 commits 2021-06-11 10:40:43 +02:00
muellerr merged commit f059aeb02d into master 2021-06-15 15:50:54 +02:00
muellerr deleted branch mueller/stm32h7-spi-com-if-l3gd20h-handler 2021-06-15 15:51:06 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: fsfw/fsfw-hal#9
No description provided.