#include "stm32c0xx_hal.h"
#include <string.h>
#include "lcd.h"
#include "keypad.h"
#define PASSWORD_LENGTH 4
// LCD Pins
#define RS_Pin GPIO_PIN_0
#define E_Pin GPIO_PIN_1
#define D4_Pin GPIO_PIN_2
#define D5_Pin GPIO_PIN_3
#define D6_Pin GPIO_PIN_4
#define D7_Pin GPIO_PIN_5
#define LCD_Port GPIOB
// Motor control pins (adjust to match your wiring)
#define M1_STEP_Pin GPIO_PIN_2
#define M1_DIR_Pin GPIO_PIN_3
#define M2_STEP_Pin GPIO_PIN_4
#define M2_DIR_Pin GPIO_PIN_5
#define M3_STEP_Pin GPIO_PIN_6
#define M3_DIR_Pin GPIO_PIN_7
#define M4_STEP_Pin GPIO_PIN_8
#define M4_DIR_Pin GPIO_PIN_9
#define Motor_Port GPIOA
//ultersonic sensor + buzzer
#define TRIG_Pin GPIO_PIN_0
#define ECHO_Pin GPIO_PIN_1
#define US_Port GPIOD
#define BUZZER_Pin GPIO_PIN_2
#define BUZZER_Port GPIOD
#define OBSTACLE_THRESHOLD_CM 20
#define OBSTACLE_CONFIRM_COUNT 3
#define MOTOR_EN_Pin GPIO_PIN_8 // ENABLE pin for all motor drivers
#define RED_LED_Pin GPIO_PIN_10
#define RED_LED_Port GPIOA
#define GREEN_LED_Pin GPIO_PIN_11
#define GREEN_LED_Port GPIOA
#define BLUE_LED_Pin GPIO_PIN_12
#define BLUE_LED_Port GPIOA
char Correct_Password[PASSWORD_LENGTH + 1] = "1234";
char Entered_Password[PASSWORD_LENGTH + 1] = {0};
uint8_t password_index = 0;
ADC_HandleTypeDef hadc1;
// Function declarations
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_ADC1_Init(void);
uint32_t read_pot(void);
void rgb_blink_sequence(void);
void run_all_motors_with_pot(uint32_t steps);
void delay_us(uint32_t us);
void delayMicroseconds(uint32_t us);
uint32_t readUltrasonic(void);
uint8_t obstacleDetected(void);
int main(void) {
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_ADC1_Init();
LCD_Init();
LCD_SetCursor(0, 0);
LCD_WriteString("ENTER PASSWORD:");
rgb_blink_sequence();
while (1) {
char key = keypad_get_key();
if (key != '\0') {
if (password_index < PASSWORD_LENGTH) {
LCD_SetCursor(1, password_index);
LCD_WriteChar('*');
Entered_Password[password_index++] = key;
}
if (password_index == PASSWORD_LENGTH) {
Entered_Password[PASSWORD_LENGTH] = '\0';
if (strcmp(Entered_Password, Correct_Password) == 0) {
LCD_Cmd(0x01);
LCD_SetCursor(0, 0);
LCD_WriteString("Access Granted");
LCD_Clear();
HAL_GPIO_WritePin(GPIOA, BLUE_LED_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(Motor_Port, MOTOR_EN_Pin, GPIO_PIN_RESET); // Enable motors
run_all_motors_with_pot(50000);
HAL_GPIO_WritePin(GPIOA, BLUE_LED_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(Motor_Port, MOTOR_EN_Pin, GPIO_PIN_SET); // Disable motors
} else {
LCD_Cmd(0x01);
LCD_SetCursor(0, 0);
LCD_WriteString("Access Denied");
}
HAL_Delay(2000);
LCD_Cmd(0x01);
LCD_SetCursor(0, 0);
LCD_WriteString("ENTER PASSWORD:");
password_index = 0;
memset(Entered_Password, 0, sizeof(Entered_Password));
}
}
}
}
// Potentiometer read
uint32_t read_pot(void) {
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, HAL_MAX_DELAY);
return HAL_ADC_GetValue(&hadc1);
}
// Run motors with pot-controlled speed
void run_all_motors_with_pot(uint32_t max_steps) {
uint16_t ADC_result = 0 ;
// uint32_t total_steps = 0;
char buffer[16]; // For displaying text
LCD_SetCursor(0, 0);
LCD_WriteString("AGV100 [*_*]");
LCD_SetCursor(1, 0);
HAL_ADC_Start(&hadc1);
HAL_ADC_PollForConversion(&hadc1, 100);
ADC_result = HAL_ADC_GetValue(&hadc1);
HAL_ADC_Stop(&hadc1);
//Convert ADC value (0-4095) to percentage speed (0-100)
int speed = (ADC_result * 100) / 4095;
// Display speed
sprintf(buffer, "SPEED: %3d%%", speed);
//sprintf(buffer, "ADC: %4d ", ADC_result);
LCD_SetCursor(1, 0);
LCD_WriteString(buffer);
HAL_Delay(200);
HAL_GPIO_WritePin(Motor_Port, M1_DIR_Pin | M2_DIR_Pin | M3_DIR_Pin | M4_DIR_Pin, GPIO_PIN_SET);
// #define OBSTACLE_THRESHOLD_CM 20
//while (total_steps < max_steps)
while(1)
{
// Read potentiometer and set speed
uint32_t pot_value = read_pot(); // ADC read
uint32_t delay_time = 200 + ((4095 - pot_value) * 3000 / 4095);
// sprintf(buffer, "SPEED: %3d%%", speed);
// Obstacle check
if (obstacleDetected()) {
// Stop motors
HAL_GPIO_WritePin(Motor_Port, M1_STEP_Pin | M2_STEP_Pin | M3_STEP_Pin | M4_STEP_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(BLUE_LED_Port, BLUE_LED_Pin, GPIO_PIN_RESET);
// Alarm while obstacle present
while (obstacleDetected()) {
HAL_GPIO_TogglePin(RED_LED_Port, RED_LED_Pin);
HAL_GPIO_TogglePin(BUZZER_Port, BUZZER_Pin);
HAL_Delay(200);
}
// Clear alarm
HAL_GPIO_WritePin(RED_LED_Port, RED_LED_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(BUZZER_Port, BUZZER_Pin, GPIO_PIN_RESET);
}
else
{
HAL_GPIO_TogglePin(BLUE_LED_Port, BLUE_LED_Pin);
HAL_GPIO_WritePin(RED_LED_Port, RED_LED_Pin, GPIO_PIN_RESET);
// Normal motor stepping
HAL_GPIO_WritePin(Motor_Port, M1_STEP_Pin | M2_STEP_Pin | M3_STEP_Pin | M4_STEP_Pin, GPIO_PIN_SET);
delayMicroseconds(5);
HAL_GPIO_WritePin(Motor_Port, M1_STEP_Pin | M2_STEP_Pin | M3_STEP_Pin | M4_STEP_Pin, GPIO_PIN_RESET);
delayMicroseconds(delay_time);
// total_steps = total_steps;
// if(total_steps % 10000 == 0)
// {
// HAL_GPIO_WritePin(GREEN_LED_Port, GREEN_LED_Pin, GPIO_PIN_RESET);
// HAL_Delay(300);
// HAL_GPIO_WritePin(GREEN_LED_Port, GREEN_LED_Pin, GPIO_PIN_SET);
// }
}
}
}
void delay_us(uint32_t us) {
uint32_t count = (HAL_RCC_GetHCLKFreq() / 1000000) * us / 5;
while (count--) {
__NOP();
}
}
void delayMicroseconds(uint32_t us) {
uint32_t count = (HAL_RCC_GetHCLKFreq() / 1000000) * us / 5;
while (count--) {
__NOP();
}
}
uint32_t readUltrasonic(void) {
uint32_t startTick, stopTick;
HAL_GPIO_WritePin(US_Port, TRIG_Pin, GPIO_PIN_RESET);
delayMicroseconds(2);
HAL_GPIO_WritePin(US_Port, TRIG_Pin, GPIO_PIN_SET);
delayMicroseconds(10);
HAL_GPIO_WritePin(US_Port, TRIG_Pin, GPIO_PIN_RESET);
while (HAL_GPIO_ReadPin(US_Port, ECHO_Pin) == GPIO_PIN_RESET);
startTick = HAL_GetTick();
while (HAL_GPIO_ReadPin(US_Port, ECHO_Pin) == GPIO_PIN_SET);
stopTick = HAL_GetTick();
uint32_t pulseLength_us = (stopTick - startTick) * 1000; // ms → us
return pulseLength_us / 58; // cm
}
uint8_t obstacleDetected(void) {
uint32_t dist = readUltrasonic();
return (dist > 0 && dist < OBSTACLE_THRESHOLD_CM);
}
// Blink RGB sequence
void rgb_blink_sequence() {
for (int i = 0; i < 10; i++) {
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11 | GPIO_PIN_12, GPIO_PIN_RESET);
HAL_Delay(200);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10 | GPIO_PIN_12, GPIO_PIN_RESET);
HAL_Delay(200);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10 | GPIO_PIN_11, GPIO_PIN_RESET);
HAL_Delay(200);
}
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12, GPIO_PIN_RESET);
}
// GPIO Init
static void MX_GPIO_Init(void) {
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
// LCD pins
GPIO_InitStruct.Pin = RS_Pin|E_Pin|D4_Pin|D5_Pin|D6_Pin|D7_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(LCD_Port, &GPIO_InitStruct);
// Keypad Rows
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// Keypad Cols
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// RGB LED pins
GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// Motor pins
GPIO_InitStruct.Pin = M1_STEP_Pin | M1_DIR_Pin | M2_STEP_Pin | M2_DIR_Pin |
M3_STEP_Pin | M3_DIR_Pin | M4_STEP_Pin | M4_DIR_Pin | MOTOR_EN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(Motor_Port, &GPIO_InitStruct);
// Disable motors initially
HAL_GPIO_WritePin(Motor_Port, MOTOR_EN_Pin, GPIO_PIN_SET);
__HAL_RCC_GPIOD_CLK_ENABLE();
// Ultrasonic + buzzer pins
GPIO_InitStruct.Pin = TRIG_Pin ;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(US_Port, &GPIO_InitStruct);
GPIO_InitStruct.Pin = ECHO_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(US_Port, &GPIO_InitStruct);
// Buzzer pin (output)
GPIO_InitStruct.Pin = BUZZER_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(BUZZER_Port, &GPIO_InitStruct);
// Red LED
GPIO_InitStruct.Pin = RED_LED_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
HAL_GPIO_Init(RED_LED_Pin, &GPIO_InitStruct);
}
// ADC Init (for potentiometer)
static void MX_ADC1_Init(void) {
__HAL_RCC_ADC_CLK_ENABLE();
hadc1.Instance = ADC1;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
HAL_ADC_Init(&hadc1);
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = ADC_CHANNEL_0; // adjust based on your potentiometer pin
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLINGTIME_COMMON_1;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
}
void SystemClock_Config(void) {
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSIDiv = RCC_HSI_DIV1;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
}
void Error_Handler(void) {
while (1) {}
}
// #include "stm32c0xx_hal.h"
// #include "lcd.h"
// #include "keypad.h"
// #include <string.h>
// // prototypes
// void SystemClock_Config(void);
// static void MX_GPIO_Init(void);
// ADC_HandleTypeDef hadc1;
// int main(void) {
// HAL_Init();
// SystemClock_Config();
// MX_GPIO_Init();
// LCD_Init();
// LCD_Set_Cursor(0, 0);
// LCD_Write_String("Testing LCD");
// HAL_Delay(3000); // wait 3 seconds
// LCD_Clear();
// while (1) {
// char key = keypad_get_key();
// if (key != '\0') {
// LCD_Clear();
// LCD_Set_Cursor(0, 0);
// LCD_Write_Char(key);
// printf("Key pressed: %c\n", key);
// }
// }
// }
// void SystemClock_Config(void)
// {
// RCC_OscInitTypeDef RCC_OscInitStruct = {0};
// RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
// __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_1);
// /** 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.HSIDiv = RCC_HSI_DIV1;
// RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
// 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_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
// RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
// RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
// RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV1;
// if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
// {
// Error_Handler();
// }
// }
// 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 */
// /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
// */
// hadc1.Instance = ADC1;
// hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
// hadc1.Init.Resolution = ADC_RESOLUTION_12B;
// hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
// hadc1.Init.ScanConvMode = ADC_SCAN_SEQ_FIXED;
// hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
// hadc1.Init.LowPowerAutoWait = DISABLE;
// hadc1.Init.LowPowerAutoPowerOff = DISABLE;
// hadc1.Init.ContinuousConvMode = DISABLE;
// hadc1.Init.NbrOfConversion = 1;
// hadc1.Init.DiscontinuousConvMode = DISABLE;
// hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
// hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
// hadc1.Init.DMAContinuousRequests = DISABLE;
// hadc1.Init.Overrun = ADC_OVR_DATA_PRESERVED;
// hadc1.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_1CYCLE_5;
// hadc1.Init.OversamplingMode = DISABLE;
// hadc1.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_HIGH;
// if (HAL_ADC_Init(&hadc1) != HAL_OK)
// {
// Error_Handler();
// }
// /** Configure Regular Channel
// */
// sConfig.Channel = ADC_CHANNEL_0;
// sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;
// if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
// {
// Error_Handler();
// }
// /* USER CODE BEGIN ADC1_Init 2 */
// /* USER CODE END ADC1_Init 2 */
// }
// /**
// * @brief GPIO Initialization Function
// * @param None
// * @retval None
// */
// static void MX_GPIO_Init(void)
// {
// // __HAL_RCC_GPIOA_CLK_ENABLE();
// // __HAL_RCC_GPIOB_CLK_ENABLE();
// GPIO_InitTypeDef GPIO_InitStruct = {0};
// // Rows: PB6 - PB9 -> Output
// GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7 | 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);
// // Columns: PB10 - PB13 -> Input
// GPIO_InitStruct.Pin = GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
// GPIO_InitStruct.Pull = GPIO_PULLUP; // use PULLUP to detect LOW on press
// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
// // LCD pins (GPIOA) setup goes here (already done if working before)
// // GPIO_InitTypeDef GPIO_InitStruct = {0};
// // Set column pins as input with pull-down
// GPIO_InitStruct.Pin = GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
// GPIO_InitStruct.Pull = GPIO_PULLDOWN;
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// GPIO_InitStruct.Pin = GPIO_PIN_15;
// HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); // PB15 column
// /* GPIO Ports Clock Enable */
// __HAL_RCC_GPIOA_CLK_ENABLE();
// __HAL_RCC_GPIOB_CLK_ENABLE();
// __HAL_RCC_GPIOD_CLK_ENABLE();
// /*Configure GPIO pin Output Level */
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
// |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
// |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
// |GPIO_PIN_15, GPIO_PIN_RESET);
// /*Configure GPIO pin Output Level */
// HAL_GPIO_WritePin(GPIOB, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
// |GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
// |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9, GPIO_PIN_RESET);
// /*Configure GPIO pin Output Level */
// HAL_GPIO_WritePin(GPIOD, GPIO_PIN_3, GPIO_PIN_RESET);
// /*Configure GPIO pins : PA2 PA3 PA4 PA5
// PA6 PA7 PA8 PA9
// PA11 PA12 PA13 PA14
// PA15 */
// GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
// |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
// |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
// |GPIO_PIN_15;
// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// /*Configure GPIO pins : PB0 PB1 PB2 PB10
// PB15 PB3 PB4 PB5
// PB6 PB7 PB8 PB9 */
// GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_10
// |GPIO_PIN_15|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
// |GPIO_PIN_6|GPIO_PIN_7|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);
// /*Configure GPIO pins : PD0 PD1 */
// GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
// GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
// /*Configure GPIO pin : PD3 */
// GPIO_InitStruct.Pin = GPIO_PIN_3;
// GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
// GPIO_InitStruct.Pull = GPIO_NOPULL;
// GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
// HAL_GPIO_Init(GPIOD, &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 *-------------------------------------------------------*/