Post Go back to editing

AD7771 STM32 sample project example

Category: Software
Product Number: AD7771

Hello Team,

Can anyone send me sample project to interface AD7771 to STM32 platform for my reference

With Regards,

Aalakh

Parents
  • I am using no_os ad7779 driver with STM32H745 MCU

    Facing following issues in stm32_spi.c source file.

    'SPI_CR1_BR_Pos' undeclared (first use in this function); did you mean 'SPI_CFG1_MBR_Pos'?

    'SPI_SR_RXNE' undeclared (first use in this function); did you mean 'SPI_SR_RXWNE'?

    'SPI_SR_TXE' undeclared (first use in this function); did you mean 'SPI_SR_TXP'?  

    'SPI_TypeDef' has no member named 'DR'; did you mean 'SR'?    

     

    Macros are not defined in stm32h7xx_hal.h

    DR is not a member in SPI_TypeDef

     

    Can you please check and confirm whether these drivers supports stm32H7 platform

  • Hi  ,

    I believe the drivers do not support the STM32H7 platform.

    But as a temporary solution, the macro SPI_CR1_BR_Pos can be replaced with the  SPI_CFG1_MBR_Pos.

    The stm32_spi_write_and_read() function can be replaced with the following:

    int32_t stm32_spi_write_and_read(struct spi_desc *desc,
                     uint8_t *data,
                     uint16_t bytes_number)
    {
        int32_t ret;
        struct stm32_spi_desc *sdesc;
        if (!desc || !desc->extra || !data)
            return -EINVAL;
        if (!bytes_number)
            return 0;
        sdesc = desc->extra;
        ret = gpio_set_value(sdesc->chip_select, GPIO_LOW);
        if (ret < 0)
            goto error;
        ret = HAL_SPI_TransmitReceive(&sdesc->hspi, data, data, bytes_number,
                          HAL_MAX_DELAY);
        if (ret != HAL_OK) {
            if (ret == HAL_TIMEOUT)
                ret = -ETIMEDOUT;
            else
                ret = -EIO;
        }
    error:
        return gpio_set_value(sdesc->chip_select, GPIO_HIGH);
    }

Reply
  • Hi  ,

    I believe the drivers do not support the STM32H7 platform.

    But as a temporary solution, the macro SPI_CR1_BR_Pos can be replaced with the  SPI_CFG1_MBR_Pos.

    The stm32_spi_write_and_read() function can be replaced with the following:

    int32_t stm32_spi_write_and_read(struct spi_desc *desc,
                     uint8_t *data,
                     uint16_t bytes_number)
    {
        int32_t ret;
        struct stm32_spi_desc *sdesc;
        if (!desc || !desc->extra || !data)
            return -EINVAL;
        if (!bytes_number)
            return 0;
        sdesc = desc->extra;
        ret = gpio_set_value(sdesc->chip_select, GPIO_LOW);
        if (ret < 0)
            goto error;
        ret = HAL_SPI_TransmitReceive(&sdesc->hspi, data, data, bytes_number,
                          HAL_MAX_DELAY);
        if (ret != HAL_OK) {
            if (ret == HAL_TIMEOUT)
                ret = -ETIMEDOUT;
            else
                ret = -EIO;
        }
    error:
        return gpio_set_value(sdesc->chip_select, GPIO_HIGH);
    }

Children