Skocz do zawartości

STM32F722ZE i MPU6050 błąd przy kompilacji związany z DutyCycle, ClockSpeed


N3eemzi

Pomocna odpowiedź

Cześć.

Mam problem z kompilacja programu, wyskakują mi błędy. podłączenie modułu jest pod następujące piny :
  PB6     ------> I2C1_SCL
  PB7     ------> I2C1_SDA

Błędy przy kompilacji :
 

19:04:39 **** Incremental Build of configuration Debug for project Test5 ****
make all 
Building file: ../Src/gpio.c
Invoking: MCU GCC Compiler
C:\Users\N3Aroo\workspace\Test5\Debug
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32F722xx -I"C:/Users/N3Aroo/workspace/Test5/Inc" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/STM32F7xx_HAL_Driver/Inc" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/CMSIS/Device/ST/STM32F7xx/Include" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/CMSIS/Include"  -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF"Src/gpio.d" -MT"Src/gpio.o" -o "Src/gpio.o" "../Src/gpio.c"
Finished building: ../Src/gpio.c
 
Building file: ../Src/i2c.c
Invoking: MCU GCC Compiler
C:\Users\N3Aroo\workspace\Test5\Debug
arm-none-eabi-gcc -mcpu=cortex-m7 -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 '-D__weak=__attribute__((weak))' '-D__packed=__attribute__((__packed__))' -DUSE_HAL_DRIVER -DSTM32F722xx -I"C:/Users/N3Aroo/workspace/Test5/Inc" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/STM32F7xx_HAL_Driver/Inc" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/STM32F7xx_HAL_Driver/Inc/Legacy" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/CMSIS/Device/ST/STM32F7xx/Include" -I"C:/Users/N3Aroo/workspace/Test5/Drivers/CMSIS/Include"  -Og -g3 -Wall -fmessage-length=0 -ffunction-sections -c -fmessage-length=0 -MMD -MP -MF"Src/i2c.d" -MT"Src/i2c.o" -o "Src/i2c.o" "../Src/i2c.c"
../Src/i2c.c: In function 'MX_I2C1_Init':
../Src/i2c.c:34:13: error: 'I2C_InitTypeDef {aka struct <anonymous>}' has no member named 'ClockSpeed'
   hi2c1.Init.ClockSpeed = 400000;
             ^
../Src/i2c.c:35:13: error: 'I2C_InitTypeDef {aka struct <anonymous>}' has no member named 'DutyCycle'
   hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
             ^
../Src/i2c.c:35:26: error: 'I2C_DUTYCYCLE_2' undeclared (first use in this function)
   hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
                          ^~~~~~~~~~~~~~~
../Src/i2c.c:35:26: note: each undeclared identifier is reported only once for each function it appears in
make: *** [Src/i2c.o] Error 1
Src/subdir.mk:39: recipe for target 'Src/i2c.o' failed

19:04:40 Build Finished (took 1s.81ms)

a oto kod z I2C.

/**
  ******************************************************************************
  * File Name          : I2C.c
  * Description        : This file provides code for the configuration
  *                      of the I2C instances.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "i2c.h"

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

I2C_HandleTypeDef hi2c1;

/* I2C1 init function */
void MX_I2C1_Init(void)
{

  hi2c1.Instance = I2C1;
  hi2c1.Init.ClockSpeed = 400000;
  hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    Error_Handler();
  }

}

void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
{

  GPIO_InitTypeDef GPIO_InitStruct = {0};
  if(i2cHandle->Instance==I2C1)
  {
  /* USER CODE BEGIN I2C1_MspInit 0 */

  /* USER CODE END I2C1_MspInit 0 */
  
    __HAL_RCC_GPIOB_CLK_ENABLE();
    /**I2C1 GPIO Configuration    
    PB6     ------> I2C1_SCL
    PB7     ------> I2C1_SDA 
    */
    GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
    GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
    HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

    /* I2C1 clock enable */
    __HAL_RCC_I2C1_CLK_ENABLE();
  /* USER CODE BEGIN I2C1_MspInit 1 */

  /* USER CODE END I2C1_MspInit 1 */
  }
}

void HAL_I2C_MspDeInit(I2C_HandleTypeDef* i2cHandle)
{

  if(i2cHandle->Instance==I2C1)
  {
  /* USER CODE BEGIN I2C1_MspDeInit 0 */

  /* USER CODE END I2C1_MspDeInit 0 */
    /* Peripheral clock disable */
    __HAL_RCC_I2C1_CLK_DISABLE();
  
    /**I2C1 GPIO Configuration    
    PB6     ------> I2C1_SCL
    PB7     ------> I2C1_SDA 
    */
    HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);

  /* USER CODE BEGIN I2C1_MspDeInit 1 */

  /* USER CODE END I2C1_MspDeInit 1 */
  }
} 

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

Spotkał się ktoś z takim problemem? w google nic nie znalazłem.

Pozdrawiam.

Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.