#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#include <avr/pgmspace.h>

#include "hd44780.h"
#include "lan_tester.h"

#define F_CPU 8000000UL

//----------------------------------------------------------------
float GetADCData (uchar nChannel)
{
	ADCSRA = 0;
	_delay_us (5);
	ADMUX = 0b01000000 | (nChannel & 0b00000111);
	_delay_us (5);
	ADCSRA = 0b10000101;
	_delay_us (500);
	ADCSRA = 0b11000101;
	while ((ADCSRA & (1 << 6)));
	_delay_us (5);
	int nResult = ((int) ADCL) + (((int) ADCH) << 8);
	return (float) nResult;
}

//----------------------------------------------------------------
void SetTestLines (uchar nPositive, uchar nNegative, bool bWait)
{
	DDRC = 0;
	PORTC = 0;
	if (nPositive != LINE_UNUSED)
	{
		DDRC |= (1 << nPositive);
		PORTC |= (1 << nPositive);
	}

	if (nNegative != LINE_UNUSED)
	{
		DDRC |= (1 << nNegative);
	}
	if (bWait) _delay_ms (20);
	return;
}

//----------------------------------------------------------------
void ShowFault (uchar nCode)
{
	lcdClear ();
	static char strMessage11 [] PROGMEM = "    на линии    ";
	static char strMessage12 [] PROGMEM = "есть напряжение!";
	static char strMessage21 [] PROGMEM = "замените батарею";
	static char strMessage31 [] PROGMEM = " АЦП неисправен ";

	switch (nCode)
	{
		case 0:
			lcdGotoXY (1, 0);
			lcdPutsFromFlash (strMessage11);
			lcdGotoXY (2, 0);
			lcdPutsFromFlash (strMessage12);
			break;
		case 1:
			lcdGotoXY (1, 0);
			lcdPutsFromFlash (strMessage21);
			break;
		case 2:
			lcdGotoXY (1, 0);
			lcdPutsFromFlash (strMessage31);
			break;
	}
	return;
}

//----------------------------------------------------------------
bool CheckLineVoltage (float *Umin, float *Umax)
{
	bool bFlag = false;

	SetTestLines (LINE_UNUSED, LINE_UNUSED, true);
	for (int i = 0; i < 8; i++)
	{
		if (GetADCData (i) > fZero) bFlag = true;
	}

	if (bFlag) 
	{
		ShowFault (0);
		return false;
	}

	if (!PINB2)
	{
		ShowFault (1);
		return false;
	}

	SetTestLines (LINE_UNUSED, 0, true);
	*Umin = GetADCData (0);

	SetTestLines (0, LINE_UNUSED, true);
	*Umax = GetADCData (0);
	if ((*Umax - *Umin) < 700)
	{
		ShowFault (2);
		return false;
	}

	return true;
}

//----------------------------------------------------------------
bool CheckConnection (char *Data, char *Mask)
{
	for (uchar i = 0; i < 8; i++)
	{
		if ((Data [i] != Mask [i]) && (Mask [i] != 'X')) return false;
	}
	return true;
}

//----------------------------------------------------------------
void RefreshDisplay (uchar *Data, int L, bool bShowLength)
{
	char str [9];

	static char strMessage0 [] PROGMEM = "Здесь:  12345678";
	static char strMessage1 [] PROGMEM = "1Gb LAN прямой  ";
	static char strMessage2 [] PROGMEM = "1Gb LAN кросс   ";
	static char strMessage3 [] PROGMEM = "100Mb LAN прямой";
	static char strMessage4 [] PROGMEM = "100Mb LAN кросс ";
	static char strMessage5 [] PROGMEM = "E1/T1           ";
	static char strMessage6 [] PROGMEM = "Нет связи       ";
	static char strMessage7 [] PROGMEM = "                ";

	lcdGotoXY (0, 0);
	lcdPutsFromFlash (strMessage0);
	lcdGotoXY (1, 0);
	lcdPutsFromRAM ("Там:    ");
	for (int i = 0; i < 8; i++) 
	{
		switch (Data [i])
		{
			case 1:
			case 2:
			case 3:
			case 4:
			case 5:
			case 6:
			case 7:
			case 8:				str [i] = Data [i] + 48; break;
			case LINE_UNKNOWN:	str [i] = '?'; break;
			case LINE_SHORTED:	str [i] = 'S'; break;
			case LINE_BROKEN:	str [i] = 'X';  break;

			default: str [i] = ' ';
		}
	}
	str [8] = 0;
	lcdPutsFromRAM (str);
	lcdPutsFromRAM ("    ");

	lcdGotoXY (2, 0);
	if (bShowLength)
	{
		if (L < 5)
		{
			lcdPutsFromRAM ("До обрыва <5 м  ");
		}
		else
		{
			lcdPutsFromRAM ("До обрыва ");
			itoa (L, str, 10);
			lcdPutsFromRAM (str);
			lcdPutsFromRAM (" м  ");			
		}
		
	}
	else
	{
		lcdPutsFromFlash (strMessage7);
	}


	lcdGotoXY (3, 0);
	if (CheckConnection (str, "12345678")) 		lcdPutsFromFlash (strMessage1);
	else if (CheckConnection (str, "36145278"))	lcdPutsFromFlash (strMessage2);
	else if (CheckConnection (str, "123XX6XX"))	lcdPutsFromFlash (strMessage3);
	else if (CheckConnection (str, "361XX2XX"))	lcdPutsFromFlash (strMessage4);
	else if (CheckConnection (str, "45X12XXX"))	lcdPutsFromFlash (strMessage5);
	else lcdPutsFromFlash (strMessage6);

	return;
}

//----------------------------------------------------------------
void Initialize ()
{
	DDRA = 0;
	DDRB = 0;
	DDRC = 0;
	DDRD = 0;
	PORTA = 0;
	PORTB = 0;
	PORTC = 0;
	PORTD = 0;
	MCUCSR = 0b10000000;
	TCCR1A = 0;
	TCCR1B = 0;

	_delay_ms (100);
	lcdInit();

	return;
}

//----------------------------------------------------------------
float GetResistance (uchar Line1, uchar Line2, float Umin)
{
	SetTestLines (Line1, Line2, true);
	float U1 = GetADCData (Line1);
	float U2 = GetADCData (Line2);
	float Ra = R1 * R2 / (R1 + R2);
	if ((U2 - Umin) <= 0) return 1e6;
	return (U1 - U2) * Ra / (U2 - Umin);
}

//----------------------------------------------------------------
uchar StageOneCheck (uchar *Line, const uchar *PinOut, uchar *GoodLine, uchar *BrokenIndex)
{
	uchar LineCount = 0;
	*BrokenIndex = LINE_UNUSED;
	for (uchar i = 0; i < 8; i++)
	{
		Line [i] = 0;
		SetTestLines (PinOut [i], LINE_UNUSED, true);
		bool bFlag = false;
		for (uchar j = 0; j < 8; j++)
		{				
			float fADCData = GetADCData (PinOut [j]);
			if ((fADCData > fMaxValue) && (i != j)) Line [i] = LINE_SHORTED;
			if ((fADCData > fZero) && (i != j)) bFlag = true;
		}
		if (!bFlag) 
		{
			Line [i] = LINE_BROKEN;
			*BrokenIndex = i;
		}
		if (Line [i] == 0) GoodLine [LineCount++] = i;
	}

	return LineCount;
}

//----------------------------------------------------------------
void StageTwoCheck (uchar *Line, const uchar *PinOut, uchar *GoodLine, uchar LineCount, const float R [3][8], float Umin)
{
	volatile static float fRcalc [8];
	uchar i = 0, j = 0;
	uchar nMinIndex [3] = {0, 0, 0};
	float fMinResistance = 1e6;
	float Rtmp;
	
	// find two lines with minimal resistance
	for (i = 1; i < LineCount; i++)
	{
		for (j = 0; j < i; j++)
		{
			Rtmp = GetResistance (PinOut [GoodLine [i]], PinOut [GoodLine [j]], Umin);
			if (Rtmp < fMinResistance)
			{
				fMinResistance = Rtmp;
				nMinIndex [0] = i;
				nMinIndex [1] = j;
			}

		}		
	}

	// find third line
	fMinResistance = 1e6;
	for (i = 0; i < LineCount; i++)
	{
		if ((i != nMinIndex [0]) && (i != nMinIndex [1]))
		{
			Rtmp = GetResistance (PinOut [GoodLine [nMinIndex [0]]], PinOut [GoodLine [i]], Umin);		
			if (Rtmp < fMinResistance)
			{
				fMinResistance = Rtmp;
				nMinIndex [2] = i;
			}
		}
	}

	// solve equations
	float fR12 = GetResistance (PinOut [GoodLine [nMinIndex [0]]], PinOut [GoodLine [nMinIndex [1]]], Umin);	
	float fR13 = GetResistance (PinOut [GoodLine [nMinIndex [0]]], PinOut [GoodLine [nMinIndex [2]]], Umin);	
	float fR23 = GetResistance (PinOut [GoodLine [nMinIndex [1]]], PinOut [GoodLine [nMinIndex [2]]], Umin);	
	float fR1 = 0.5 * (fR12 + fR13 - fR23);
	float fR2 = fR12 - fR1;
	uchar idxMin;
	
	if (fR1 < fR2)
	{
		idxMin = nMinIndex [0];
		fRcalc [idxMin] = fR1;
	}
	else
	{
		idxMin = nMinIndex [1];
		fRcalc [idxMin] = fR2;
	}

	for (i = 0; i < LineCount; i++)
	{
		if (i != idxMin)
		{
			Rtmp = GetResistance (PinOut [GoodLine [i]], PinOut [GoodLine [idxMin]], Umin);
			fRcalc [i] = Rtmp - fRcalc [idxMin];
		}
	}

	// try to found according resistance in table
	for (i = 0; i <= LineCount; i++)
	{
		for (j = 0; j < 8; j++)
		{
			if ((R [1][j] < fRcalc [i]) && (fRcalc [i] < R [2][j]))
			{
				Line [GoodLine [i]] = j + 1;
				break;
			}
		}
		if (Line [GoodLine [i]] == 0) Line [GoodLine [i]] = LINE_UNKNOWN;
	}
	
	return;
}

//----------------------------------------------------------------
int StageThreeCheck (uchar BrokenIndex, const uchar *PinOut)
{
	SetTestLines (PinOut [BrokenIndex], LINE_UNUSED, true);
	float U1 = GetADCData (PinOut [BrokenIndex]);
	TCNT1H = 0;
	TCNT1L = 0;
	TCCR1B = 1;
	SetTestLines (LINE_UNUSED, LINE_UNUSED, false);
	_delay_ms (1);
	float U2 = GetADCData (PinOut [BrokenIndex]);
	TCCR1B = 0;
	int nTime = ((int) TCNT1L) + (((int) TCNT1H) << 8);
	float fTime = ((float) nTime) * 1000 / F_CPU;
	float L = (-fTime/log (U2 / U1) - 1.71) / 0.032;
	return (int) L;
}

//----------------------------------------------------------------
void EasterEgg ()
{
	static int i = 0;
	static char strMessage1 [] PROGMEM = "                ";
	static char strMessage2 [] PROGMEM = "LAN-тестер v 1.1";
	static char strMessage3 [] PROGMEM = "				  ";
	static char strMessage4 [] PROGMEM = "                ";

	if (++i == 120)
	{
		
		lcdClear ();
		lcdGotoXY (0, 0);
		lcdPutsFromFlash (strMessage1);
		lcdGotoXY (1, 0);
		lcdPutsFromFlash (strMessage2);
		lcdGotoXY (2, 0);
		lcdPutsFromFlash (strMessage3);
		lcdGotoXY (3, 0);
		lcdPutsFromFlash (strMessage4);
		_delay_ms (5000);
		lcdClear ();
	}
	return;
}

//----------------------------------------------------------------
int main()
{                      
	const uchar PinOut [8] = {6, 5, 7, 4, 0, 3, 1, 2};
	const float R [3][8] = {{15, 8.2, 51, 3.0, 5.1, 2.0, 22, 1.0},
							{13, 7.5, 40, 2.5, 4.0, 1.5, 18, 0.7},
							{18, 9.5, 60, 3.8, 6.5, 2.5, 27, 1.5}};
	float Umax, Umin;
	int L = 0;
	uchar Line [8];
	uchar GoodLine [8];
	uchar BrokenIndex;
	uchar Step = 0;
	uchar LineCount = 0;
	uchar i;

	Initialize ();

	while (1)
	{
		switch (Step)
		{
			case 0:				// startup checks
				if (CheckLineVoltage (&Umin, &Umax)) Step = 1;
				break;
	
			case 1:				// try to found unbroken line, check for shortage
				LineCount = StageOneCheck (Line, PinOut, GoodLine, &BrokenIndex);
				if (LineCount < 3)
				{
					for (i = 0; i < 8; i++)
					{
						if (Line [i] == 0) Line [i] = LINE_UNKNOWN;
					}
					Step = 3;
				}
				else
				{
					Step = 2;
				}
				break;

			case 2:			// resistance measure, lines order check
				StageTwoCheck (Line, PinOut, GoodLine, LineCount, R, Umin);
				if (BrokenIndex == LINE_UNUSED) Step = 4; else Step = 3;
				break;

			case 3:			// capacitance measure, if there are broken lines
				L = StageThreeCheck (BrokenIndex, PinOut);
				Step = 4;
				break;

			case 4:		// display refresh
				RefreshDisplay (Line, L, (BrokenIndex != LINE_UNUSED));
				EasterEgg ();

			default:
				Step = 0;
		}
	}

}

Перепиши этот код под стм 32f103 вот код самого стма

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include <stdio.h>  // Для функции snprintf
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */






/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;

I2C_HandleTypeDef hi2c1;

/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
static void MX_I2C1_Init(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */





#define LCD_ADDR (0x27 << 1)


#define PIN_RS    (1 << 0)
#define PIN_EN    (1 << 2)
#define BACKLIGHT (1 << 3)

#define LCD_DELAY_MS 5



void I2C_send(uint8_t data, uint8_t flags)
{
	HAL_StatusTypeDef res;
	 // бесконечный цикл   
        for(;;) {
                // проверяем, готово ли устройство по адресу lcd_addr для связи                                                                                      
	        res = HAL_I2C_IsDeviceReady(&hi2c1, LCD_ADDR, 1, HAL_MAX_DELAY);               
	         // если да, то выходим из бесконечного цикла
                if(res == HAL_OK) break;                                                  
	    }
        // операция И с 1111 0000 приводит к обнулению бит с 0 по 3, остаются биты с 4 по 7
	uint8_t up = data & 0xF0;   
        // то же самое, но data сдвигается на 4 бита влево              	
        uint8_t lo = (data << 4) & 0xF0;          
                                          
	uint8_t data_arr[4];
         // 4-7 биты содержат информацию, биты 0-3 настраивают работу дисплея
	data_arr[0] = up|flags|BACKLIGHT|PIN_EN; 
         // дублирование сигнала, на выводе Е в этот раз 0  
	data_arr[1] = up|flags|BACKLIGHT;         
	data_arr[2] = lo|flags|BACKLIGHT|PIN_EN;
	data_arr[3] = lo|flags|BACKLIGHT;

	HAL_I2C_Master_Transmit(&hi2c1, LCD_ADDR, data_arr, sizeof(data_arr), HAL_MAX_DELAY);
	HAL_Delay(LCD_DELAY_MS);
}




void LCD_SendString(char *str)
{
    // *char по сути является строкой
    // пока строчка не закончится
	while(*str) 
        {                                   
                // передача первого символа строки
		I2C_send((uint8_t)(*str), 1); 
                // сдвиг строки налево на 1 символ              
                str++;                                     
        }
}





















/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_I2C1_Init();
  /* USER CODE BEGIN 2 */
	
	  I2C_send(0b00110000,0);   // 8ми битный интерфейс
  I2C_send(0b00000010,0);   // установка курсора в начале строки
  I2C_send(0b00001100,0);   // нормальный режим работы
  I2C_send(0b00000001,0);   // очистка дисплея

  I2C_send(0b10000000,0);   // переход на 1 строку, тут не обязателен
  LCD_SendString("  Hello Habr");
	HAL_Delay(500);
  I2C_send(0b11000000,0);   // переход на 2 строку
  LCD_SendString(" STM32 + LCD 1602");
	HAL_Delay(500);
  I2C_send(0b10010100,0);   // переход на 3 строку
  LCD_SendString(" +LCD 2004A");
	HAL_Delay(500);
  I2C_send(0b11010100,0);   // переход на 4 строку
  LCD_SendString(" library HAL");
	HAL_Delay(500);
	
	
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(500);
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(500);

uint32_t ADC_value = 0;
float voltage = 0;
const float VREF = 3.3;
const float R1 = 1000;
float resistance = 0;
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_1);
  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
		
  HAL_ADC_Start(&hadc1);
    HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
		ADC_value = HAL_ADC_GetValue(&hadc1);
		
		voltage = ((float)ADC_value) * VREF / 4095.0f;
		// Проверка деления на ноль
    if ((VREF - voltage) > 0.01f)
    {
        // Вычисление сопротивления неизвестного резистора
        resistance = R1 * (voltage / (VREF - voltage));

        // Подготовка строки для отображения
        char buffer[16];
				LCD_SendString(" library HAL");
        snprintf(buffer, sizeof(buffer), "R=%.2f Ohm", resistance);

        // Очистка экрана
        I2C_send(0b00000001, 0); // Очистка дисплея

        // Отображение строки на LCD
        I2C_send(0b10000000, 0); // Перемещение курсора на первую строку
        LCD_SendString(buffer);
    }
		
		
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
HAL_Delay(500);
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
  RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
  {
    Error_Handler();
  }
  PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
  PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV2;
  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief ADC1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_ADC1_Init(void)
{

  /* USER CODE BEGIN ADC1_Init 0 */

  /* USER CODE END ADC1_Init 0 */

  ADC_ChannelConfTypeDef sConfig = {0};

  /* USER CODE BEGIN ADC1_Init 1 */

  /* USER CODE END ADC1_Init 1 */

  /** Common config
  */
  hadc1.Instance = ADC1;
  hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
  hadc1.Init.ContinuousConvMode = DISABLE;
  hadc1.Init.DiscontinuousConvMode = DISABLE;
  hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
  hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
  hadc1.Init.NbrOfConversion = 1;
  if (HAL_ADC_Init(&hadc1) != HAL_OK)
  {
    Error_Handler();
  }

  /** Configure Regular Channel
  */
  sConfig.Channel = ADC_CHANNEL_0;
  sConfig.Rank = ADC_REGULAR_RANK_1;
  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN ADC1_Init 2 */

  /* USER CODE END ADC1_Init 2 */

}

/**
  * @brief I2C1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_I2C1_Init(void)
{

  /* USER CODE BEGIN I2C1_Init 0 */

  /* USER CODE END I2C1_Init 0 */

  /* USER CODE BEGIN I2C1_Init 1 */

  /* USER CODE END I2C1_Init 1 */
  hi2c1.Instance = I2C1;
  hi2c1.Init.ClockSpeed = 100000;
  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();
  }
  /* USER CODE BEGIN I2C1_Init 2 */

  /* USER CODE END I2C1_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  * @param None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOC_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, GPIO_PIN_RESET);

  /*Configure GPIO pin Output Level */
  HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET);

  /*Configure GPIO pin : PC13 */
  GPIO_InitStruct.Pin = GPIO_PIN_13;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

  /*Configure GPIO pins : PB0 PB1 PB2 PB3
                           PB4 PB5 PB8 PB9 */
  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8|GPIO_PIN_9;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */