#include "stm32c0xx_hal.h"
#include <string.h>
#define A GPIO_PIN_8
#define B GPIO_PIN_9
#define C GPIO_PIN_7
#define D GPIO_PIN_6
#define E GPIO_PIN_5
#define F GPIO_PIN_3
#define G GPIO_PIN_1
#define PORTA GPIOA
#define ROW1_PIN GPIO_PIN_7
#define ROW1_PORT GPIOB
#define ROW2_PIN GPIO_PIN_6
#define ROW2_PORT GPIOB
#define ROW3_PIN GPIO_PIN_10
#define ROW3_PORT GPIOA
#define ROW4_PIN GPIO_PIN_3
#define ROW4_PORT GPIOB
#define COL1_PIN GPIO_PIN_10
#define COL1_PORT GPIOB
#define COL2_PIN GPIO_PIN_4
#define COL2_PORT GPIOB
#define COL3_PIN GPIO_PIN_5
#define COL3_PORT GPIOB
#define COL4_PIN GPIO_PIN_15
#define COL4_PORT GPIOA
/* 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 ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
/* USER CODE BEGIN PFP */
void disp0(void);
void disp1(void);
void disp2(void);
void disp3(void);
void disp4(void);
void disp5(void);
void disp6(void);
void disp7(void);
void disp8(void);
void disp9(void);
void dispA(void);
void dispB(void);
void dispC(void);
void dispD(void);
void dispE(void);
void dispF(void);
uint8_t Scan_Keypad(void);
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* 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();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
uint8_t key = Scan_Keypad();
if (key == 1) {
disp1();
printf("1\n");
HAL_Delay(600); // Print "1" when key 1 is pressed
} else if (key == 4) {
disp4();
printf("4\n"); HAL_Delay(600); // Print "4" when key 2 is pressed
} else if (key == 7) {
disp7();
printf("7\n"); HAL_Delay(600); // Print "7" when key 3 is pressed
}
else if (key == '*') {
dispE();
printf("\n"); HAL_Delay(600); // Print "" when key * is pressed
}
if (key == 2) {
disp2();
printf("2\n"); HAL_Delay(600); // Print "2" when key 2 is pressed
} else if (key == 5) {
disp5();
printf("5\n"); HAL_Delay(600); // Print "5" when key 5 is pressed
} else if (key == 8) {
disp8();
printf("8\n"); HAL_Delay(600);// Print "8" when key 8 is pressed
}
else if (key == 0) {
disp0();
printf("0\n"); HAL_Delay(600); // Print "0" when key 0 is pressed
}
if (key == 3) {
disp3();
printf("3\n"); HAL_Delay(600);// Print "1" when key 3 is pressed
} else if (key == 6) {
disp6();
printf("6\n"); HAL_Delay(600);// Print "4" when key 6 is pressed
} else if (key == 9) {
disp9();
printf("9\n"); HAL_Delay(600);// Print "7" when key 9 is pressed
}
else if (key == '#') {
dispF();
printf("#\n"); HAL_Delay(600);// Print "*" when key # is pressed
}
if (key == 'A') {
dispA();
printf("A\n"); HAL_Delay(600);// Print "1" when key A is pressed
} else if (key == 'B') {
dispB();
printf("B\n"); HAL_Delay(600);// Print "4" when key B is pressed
} else if (key == 'C') {
dispC();
printf("C\n"); HAL_Delay(600);// Print "7" when key C is pressed
}
else if (key == 'D') {
dispD();
printf("D\n"); HAL_Delay(600); // Print "*" when key D is pressed
}
}
}
void disp0() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_RESET);
}
void disp1() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_RESET);
}
void disp2() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp3() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp4() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp5() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp6() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp7() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_RESET);
}
void disp8() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void disp9() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void dispA() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void dispB() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void dispC() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_RESET);
}
void dispD() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void dispE() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
void dispF() {
HAL_GPIO_WritePin(PORTA, A, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, B, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, C, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, D, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PORTA, E, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, F, GPIO_PIN_SET);
HAL_GPIO_WritePin(PORTA, G, GPIO_PIN_SET);
}
uint8_t Scan_Keypad(void) {
// Set all columns high
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_SET);
// Scan the first column (for key 1, 4, 7, *.)
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_RESET); // Set COL1 low
// Check the rows
if (HAL_GPIO_ReadPin(ROW1_PORT, ROW1_PIN) == GPIO_PIN_RESET) {
return 1; // Key "1" is pressed (Row 1, Col 1)
} else if (HAL_GPIO_ReadPin(ROW2_PORT, ROW2_PIN) == GPIO_PIN_RESET) {
return 4; // Key "4" is pressed (Row 2, Col 1)
} else if (HAL_GPIO_ReadPin(ROW3_PORT, ROW3_PIN) == GPIO_PIN_RESET) {
return 7; // Key "7" is pressed (Row 3, Col 1)
}
else if (HAL_GPIO_ReadPin(ROW4_PORT, ROW4_PIN) == GPIO_PIN_RESET) {
return '*'; // Key "" is pressed (Row 4, Col 1)
}
// Set the column back high before scanning next column
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_SET);
// Set all columns high
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_SET);
// Scan the first column (for key 2 , 5 ,8 ,0)
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_RESET); // Set COL2 low
// Check the rows
if (HAL_GPIO_ReadPin(ROW1_PORT, ROW1_PIN) == GPIO_PIN_RESET) {
return 2; // Key "2" is pressed (Row 1, Col 2)
} else if (HAL_GPIO_ReadPin(ROW2_PORT, ROW2_PIN) == GPIO_PIN_RESET) {
return 5; // Key "5" is pressed (Row 2, Col 2)
} else if (HAL_GPIO_ReadPin(ROW3_PORT, ROW3_PIN) == GPIO_PIN_RESET) {
return 8; // Key "8" is pressed (Row 3, Col 2)
}
else if (HAL_GPIO_ReadPin(ROW4_PORT, ROW4_PIN) == GPIO_PIN_RESET) {
return 0; // Key "0" is pressed (Row 4, Col 2)
}
// Set the column back high before scanning next column
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_SET);
// Set all columns high
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_SET);
// Scan the first column (for key 3, 6, 9, #.)
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_RESET); // Set COL3low
// Check the rows
if (HAL_GPIO_ReadPin(ROW1_PORT, ROW1_PIN) == GPIO_PIN_RESET) {
return 3; // Key "3" is pressed (Row 1, Col 3)
} else if (HAL_GPIO_ReadPin(ROW2_PORT, ROW2_PIN) == GPIO_PIN_RESET) {
return 6; // Key "6" is pressed (Row 2, Col 3)
} else if (HAL_GPIO_ReadPin(ROW3_PORT, ROW3_PIN) == GPIO_PIN_RESET) {
return 9; // Key "9" is pressed (Row 3, Col 3)
}
else if (HAL_GPIO_ReadPin(ROW4_PORT, ROW4_PIN) == GPIO_PIN_RESET) {
return '#'; // Key "#" is pressed (Row 4, Col 3)
}
// Set the column back high before scanning next column
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_SET);
// Set all columns high
HAL_GPIO_WritePin(COL1_PORT, COL1_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL2_PORT, COL2_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL3_PORT, COL3_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_SET);
// Scan the first column (for key A, B, C, D.)
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_RESET); // Set COL4 low
// Check the rows
if (HAL_GPIO_ReadPin(ROW1_PORT, ROW1_PIN) == GPIO_PIN_RESET) {
return 'A'; // Key "A" is pressed (Row 1, Col 4)
} else if (HAL_GPIO_ReadPin(ROW2_PORT, ROW2_PIN) == GPIO_PIN_RESET) {
return 'B'; // Key "B" is pressed (Row 2, Col 4)
} else if (HAL_GPIO_ReadPin(ROW3_PORT, ROW3_PIN) == GPIO_PIN_RESET) {
return 'C'; // Key "C" is pressed (Row 3, Col 4)
}
else if (HAL_GPIO_ReadPin(ROW4_PORT, ROW4_PIN) == GPIO_PIN_RESET) {
return 'D'; // Key "D" is pressed (Row 4, Col 4)
}
// Set the column back high before scanning next column
HAL_GPIO_WritePin(COL4_PORT, COL4_PIN, GPIO_PIN_SET);
// You can extend this for other keys by scanning other columns and rows
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {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.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();
}
}
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10|GPIO_PIN_4|GPIO_PIN_5, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_15, GPIO_PIN_RESET);
GPIO_InitStruct.Pin = A | B | C | D | E | F | G;
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 : PB10 PB4 PB5 */
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_4|GPIO_PIN_5;
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 pin : PA10 */
GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pin : PA15 */
GPIO_InitStruct.Pin = 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 : PB3 PB6 PB7 */
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_6|GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
}
/* 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 */