Page 15 of 15

Re: Where to start STM32H7 support

Posted: Sun Mar 10, 2019 12:08 pm
by tridge
Giovanni wrote:The SPI driver should allow for mixed DMA and non-DMA operations, is leaving those 2 bits enable a problem? DMA channels are disabled. It is not a problem apparently for other SPI implementations.

you're right, it works fine to leave those enabled, and that means we can mix DMA and non-DMA.

Re: Where to start STM32H7 support

Posted: Sun Mar 10, 2019 12:10 pm
by Giovanni
So just that synchronization loop is required, good.

Giovanni

Re: Where to start STM32H7 support

Posted: Thu Mar 14, 2019 12:22 am
by pkocmoud
Hi Giovanni,

In the file: os/hal/ports/STM32/STM32H7xx/hal_lld.h Line 1227, should this test include both the STM32H743 and STM32H753 to require STM32H743_MCUCONF be defined or should it be broken into separate tests for the STM32H743 and STM32H753?

Maybe the STM32H753 processors were to be supported with the STM32H743_MCUCONF?

In my hwdef.dat, I defined my processor as "MCU STM32H7xx STM32H753xx" and modified the test as I mentioned above and it now compiles fine.

Patch is shown here: https://github.com/ArduPilot/ChibiOS/co ... 03c383e0e2

Thank you for your time!

Phil

Re: Where to start STM32H7 support

Posted: Sun Mar 17, 2019 9:07 am
by Giovanni
Hi,

The modified polled exchange looks like this:

Code: Select all

uint32_t spi_lld_polled_exchange(SPIDriver *spip, uint32_t frame) {
  uint32_t dsize = (spip->spi->CFG1 & SPI_CFG1_DSIZE_Msk) + 1U;
  uint32_t rxframe;

  spip->spi->CR1 |= SPI_CR1_CSTART;

  /* wait for room in TX FIFO.*/
  while ((spip->spi->SR & SPI_SR_TXP) == 0U)
    ;

  /* Data register must be accessed with the appropriate data size.
     Byte size access (uint8_t *) for transactions that are <= 8-bit etc.*/
  if (dsize <= 8U) {
    /* Frame width is between 4 and 8 bits.*/
    volatile uint8_t *txdrp8 = (volatile uint8_t *)&spip->spi->TXDR;
    volatile uint8_t *rxdrp8 = (volatile uint8_t *)&spip->spi->RXDR;
    *txdrp8 = (uint8_t)frame;
    while ((spip->spi->SR & SPI_SR_RXP) == 0U)
      ;
    rxframe = (uint32_t)*rxdrp8;
  }
  else if (dsize <= 16U) {
    /* Frame width is between 9 and 16 bits.*/
    volatile uint16_t *txdrp16 = (volatile uint16_t *)&spip->spi->TXDR;
    volatile uint16_t *rxdrp16 = (volatile uint16_t *)&spip->spi->RXDR;
    *txdrp16 = (uint16_t)frame;
    while ((spip->spi->SR & SPI_SR_RXP) == 0U)
      ;
    rxframe = (uint32_t)*rxdrp16;
  }
  else {
    /* Frame width is between 16 and 32 bits.*/
    spip->spi->TXDR = frame;
    while ((spip->spi->SR & SPI_SR_RXP) == 0U)
      ;
    rxframe = spip->spi->RXDR;
  }

  spip->spi->CR1 |= SPI_CR1_CSUSP;

  return rxframe;
}


My problem is that I don't understand under which condition the TX FIFO is not empty on entry, all SPI operations synchronize of received frames, if you receive a frame then it means that you also transmitted one and the TX FIFO needs to be empty.

I committed this change on trunk anyway.

Giovanni

Re: Where to start STM32H7 support

Posted: Sun Mar 17, 2019 9:12 am
by Giovanni
pkocmoud wrote:In the file: os/hal/ports/STM32/STM32H7xx/hal_lld.h Line 1227, should this test include both the STM32H743 and STM32H753 to require STM32H743_MCUCONF be defined or should it be broken into separate tests for the STM32H743 and STM32H753?

Maybe the STM32H753 processors were to be supported with the STM32H743_MCUCONF?

In my hwdef.dat, I defined my processor as "MCU STM32H7xx STM32H753xx" and modified the test as I mentioned above and it now compiles fine.


I think that mcuconf.h files should list all compatible platforms, so define both STM32H743_MCUCONF and STM32H753_MCUCONF. See how L4 mcuconf.h files do for an example.

I made this change both in trunk and in 19.1.x.

Giovanni

Re: Where to start STM32H7 support

Posted: Mon Mar 18, 2019 2:24 am
by tridge
Giovanni wrote:My problem is that I don't understand under which condition the TX FIFO is not empty on entry, all SPI operations synchronize of received frames, if you receive a frame then it means that you also transmitted one and the TX FIFO needs to be empty.

I can re-test it if you like. I see what you mean about why it shouldn't be needed.
I don't use polled any more, but I can enable it again for a test

Re: Where to start STM32H7 support

Posted: Mon Mar 18, 2019 8:32 am
by Giovanni
Thanks, that would be helpful, try to do a DMA transfer followed by a series of polled transfers then another DMA transfer (with and without the change).

Giovanni