624 lines
16 KiB
C
624 lines
16 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file : main.c
|
|
* @brief : Main program body
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2025 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 "cmsis_os.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
#include "ili9341.h"
|
|
#include "ili9341_touch.h"
|
|
/* 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 ---------------------------------------------------------*/
|
|
SPI_HandleTypeDef hspi1;
|
|
SPI_HandleTypeDef hspi2;
|
|
|
|
/* Definitions for defaultTask */
|
|
osThreadId_t defaultTaskHandle;
|
|
const osThreadAttr_t defaultTask_attributes = { .name = "defaultTask",
|
|
.stack_size = 128 * 4, .priority = (osPriority_t) osPriorityNormal, };
|
|
/* Definitions for draw */
|
|
osThreadId_t drawHandle;
|
|
const osThreadAttr_t draw_attributes = { .name = "draw", .stack_size = 128 * 4,
|
|
.priority = (osPriority_t) osPriorityLow, };
|
|
/* Definitions for presses */
|
|
osMessageQueueId_t pressesHandle;
|
|
const osMessageQueueAttr_t presses_attributes = { .name = "presses" };
|
|
/* USER CODE BEGIN PV */
|
|
|
|
/* USER CODE END PV */
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
void SystemClock_Config(void);
|
|
static void MX_GPIO_Init(void);
|
|
static void MX_SPI1_Init(void);
|
|
static void MX_SPI2_Init(void);
|
|
void StartDefaultTask(void *argument);
|
|
void startdraw(void *argument);
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* Private user code ---------------------------------------------------------*/
|
|
/* USER CODE BEGIN 0 */
|
|
#define FLASH_USER_ADDR ((uint32_t)0x0803F000) // Last 4 KB
|
|
void Flash_Write_HighScore(uint32_t highscore) {
|
|
HAL_FLASH_Unlock();
|
|
|
|
// Erase the sector first
|
|
FLASH_EraseInitTypeDef EraseInitStruct;
|
|
uint32_t PageError = 0;
|
|
|
|
EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
|
|
EraseInitStruct.VoltageRange = FLASH_VOLTAGE_RANGE_3;
|
|
EraseInitStruct.Sector = FLASH_SECTOR_5;
|
|
EraseInitStruct.NbSectors = 1;
|
|
|
|
if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK) {
|
|
// Handle error
|
|
return;
|
|
}
|
|
|
|
// Program the word
|
|
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, FLASH_USER_ADDR, highscore)
|
|
!= HAL_OK) {
|
|
// Handle error
|
|
}
|
|
|
|
HAL_FLASH_Lock();
|
|
}
|
|
uint32_t Flash_Read_HighScore(void) {
|
|
return *(uint32_t*) FLASH_USER_ADDR;
|
|
}
|
|
|
|
struct Snake {
|
|
// Snake head coordinates (x-axis, y-axis)
|
|
int x, y;
|
|
// Food coordinates
|
|
int fruitCordX, fruitCordY;
|
|
// Player's score
|
|
int playerScore;
|
|
// Tail coordinates
|
|
int TailX[100], TailY[100];
|
|
// Tail length
|
|
int TailLen;
|
|
// Movement direction
|
|
enum Direction {
|
|
STOP = 0, LEFT, RIGHT, UP, DOWN
|
|
} Dir;
|
|
|
|
int gamesizewidth; //number of " pixels " in the horizontal
|
|
int gamesizeheight;
|
|
|
|
// Game over flag
|
|
bool isGameOver;
|
|
} snake;
|
|
// Function to initialize game variables
|
|
void GameInit() {
|
|
snake.gamesizeheight = 6;
|
|
snake.gamesizewidth = 8;
|
|
snake.isGameOver = false;
|
|
snake.Dir = STOP;
|
|
snake.x = snake.gamesizewidth / 2;
|
|
snake.y = snake.gamesizeheight / 2;
|
|
snake.fruitCordX = rand() % snake.gamesizewidth;
|
|
snake.fruitCordY = rand() % snake.gamesizeheight;
|
|
snake.playerScore = 0;
|
|
}
|
|
// Function for updating the game state
|
|
void UpdateGame() {
|
|
int prevX = snake.TailX[0];
|
|
int prevY = snake.TailY[0];
|
|
int prev2X, prev2Y;
|
|
snake.TailX[0] = snake.x;
|
|
snake.TailY[0] = snake.y;
|
|
|
|
for (int i = 1; i < snake.TailLen; i++) {
|
|
prev2X = snake.TailX[i];
|
|
prev2Y = snake.TailY[i];
|
|
snake.TailX[i] = prevX;
|
|
snake.TailY[i] = prevY;
|
|
prevX = prev2X;
|
|
prevY = prev2Y;
|
|
}
|
|
|
|
char dir;
|
|
// check the queue non blocking
|
|
osStatus_t status = osMessageQueueGet(pressesHandle, &dir, NULL, 0); // 0 = no wait
|
|
|
|
if (status == osOK) {
|
|
switch (dir) {
|
|
case 'L':
|
|
snake.Dir = LEFT;
|
|
break;
|
|
case 'R':
|
|
snake.Dir = RIGHT;
|
|
break;
|
|
case 'U':
|
|
snake.Dir = UP;
|
|
break;
|
|
case 'D':
|
|
snake.Dir = DOWN;
|
|
break;
|
|
}
|
|
}
|
|
switch (snake.Dir) {
|
|
case LEFT:
|
|
snake.x--;
|
|
break;
|
|
case RIGHT:
|
|
snake.x++;
|
|
break;
|
|
case UP:
|
|
snake.y--;
|
|
break;
|
|
case DOWN:
|
|
snake.y++;
|
|
break;
|
|
}
|
|
|
|
// Checks for snake's collision with the wall (|)
|
|
if (snake.x >= snake.gamesizewidth || snake.x < 0
|
|
|| snake.y >= snake.gamesizeheight || snake.y < 0)
|
|
snake.isGameOver = true;
|
|
|
|
// Checks for collision with the tail (o)
|
|
for (int i = 0; i < snake.TailLen; i++) {
|
|
if (snake.TailX[i] == snake.x && snake.TailY[i] == snake.y)
|
|
snake.isGameOver = true;
|
|
}
|
|
|
|
// Checks for snake's collision with the food (#)
|
|
if (snake.x == snake.fruitCordX && snake.y == snake.fruitCordY) {
|
|
snake.playerScore += 10;
|
|
snake.fruitCordX = rand() % snake.gamesizewidth;
|
|
snake.fruitCordY = rand() % snake.gamesizeheight;
|
|
snake.TailLen++;
|
|
}
|
|
if (snake.isGameOver) {
|
|
if (Flash_Read_HighScore() < snake.playerScore) {
|
|
char str[50];
|
|
sprintf(str, "Highscore Remains: %lu", Flash_Read_HighScore());
|
|
ILI9341_WriteString(320/2-70, 240/2, str, Font_11x18, ILI9341_MAGENTA, ILI9341_WHITE);
|
|
} else {
|
|
char str[50];
|
|
sprintf(str, "New Highscore: %lu", snake.playerScore);
|
|
ILI9341_WriteString(320/2-70, 240/2, str, Font_11x18, ILI9341_MAGENTA, ILI9341_WHITE);
|
|
Flash_Write_HighScore(snake.playerScore);
|
|
}
|
|
|
|
}
|
|
}
|
|
// Function to handle user UserInput
|
|
void UserInput() {
|
|
// Checks if a key is pressed or not
|
|
|
|
//case 'a':
|
|
// snake.Dir = LEFT;
|
|
uint16_t x, y;
|
|
|
|
if (ILI9341_TouchGetCoordinates(&x, &y)) { // Only act if touch detected
|
|
char dir;
|
|
if (x < 107) {
|
|
dir = 'L'; // Left
|
|
} else if (x > 213) {
|
|
dir = 'R'; // Right
|
|
} else if (y > 120) {
|
|
dir = 'U'; // Up
|
|
} else {
|
|
dir = 'D'; // Down
|
|
}
|
|
|
|
// Send the direction to the queue
|
|
|
|
osStatus_t status = osMessageQueuePut(pressesHandle, &dir, 0, 0);
|
|
if (status != osOK) {
|
|
// Optional: Handle error
|
|
}
|
|
}
|
|
|
|
}
|
|
// Function for creating the game board & rendering
|
|
void GameRender() {
|
|
|
|
// Creating top walls
|
|
// Creating side walls
|
|
//ILI9341_FillRectangle(j, i, ILI9341_WIDTH/snake.gamesizewidth, ILI9341_HEIGHT/snake.gamesizeheight, ILI9341_YELLOW);
|
|
ILI9341_FillScreen(ILI9341_WHITE);
|
|
for (int x = 0; x < snake.gamesizewidth; x++) {
|
|
for (int y = 0; y <= snake.gamesizeheight; y++) {
|
|
|
|
// Creating snake's head with 'O'
|
|
// [0,0]
|
|
// (gamewidth-1)/gamewidth*320
|
|
// (gameheight-0)/gameheigth*240
|
|
|
|
//[1,1]
|
|
//(gamewidth-2)/gamewidht*320
|
|
//(gameheight-1)/gameheight*240
|
|
|
|
//[x,y]
|
|
//(gamewidth-x-1)/gamewidth*320
|
|
//(gameheight-y)/gameheight*240
|
|
|
|
if (x == snake.x && y == snake.y)
|
|
ILI9341_FillRectangle((x * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
(y * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
ILI9341_WIDTH / snake.gamesizewidth,
|
|
ILI9341_HEIGHT / snake.gamesizeheight, ILI9341_BLACK);
|
|
//cout << "O";
|
|
// Creating the sanke's food with '#'
|
|
else if (x == snake.fruitCordY && y == snake.fruitCordX)
|
|
ILI9341_FillRectangle((x * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
(y * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
ILI9341_WIDTH / snake.gamesizewidth,
|
|
ILI9341_HEIGHT / snake.gamesizeheight, ILI9341_RED);
|
|
|
|
//cout << "#";
|
|
// Creating snake's head with 'O'
|
|
else {
|
|
//bool prTail = false;
|
|
for (int k = 0; k < snake.TailLen; k++) {
|
|
if (snake.TailX[k] == x && snake.TailY[k] == y) {
|
|
ILI9341_FillRectangle(
|
|
(x * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
(y * ILI9341_WIDTH) / ILI9341_WIDTH,
|
|
ILI9341_WIDTH / snake.gamesizewidth,
|
|
ILI9341_HEIGHT / snake.gamesizeheight,
|
|
ILI9341_GREEN);
|
|
//prTail = true;
|
|
}
|
|
}
|
|
//if (!prTail)
|
|
//cout << " ";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* 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_SPI1_Init();
|
|
MX_SPI2_Init();
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/* Init scheduler */
|
|
osKernelInitialize();
|
|
|
|
/* USER CODE BEGIN RTOS_MUTEX */
|
|
/* add mutexes, ... */
|
|
/* USER CODE END RTOS_MUTEX */
|
|
|
|
/* USER CODE BEGIN RTOS_SEMAPHORES */
|
|
/* add semaphores, ... */
|
|
/* USER CODE END RTOS_SEMAPHORES */
|
|
|
|
/* USER CODE BEGIN RTOS_TIMERS */
|
|
/* start timers, add new ones, ... */
|
|
/* USER CODE END RTOS_TIMERS */
|
|
|
|
/* Create the queue(s) */
|
|
/* creation of presses */
|
|
pressesHandle = osMessageQueueNew(16, sizeof(char), &presses_attributes);
|
|
|
|
/* USER CODE BEGIN RTOS_QUEUES */
|
|
/* add queues, ... */
|
|
/* USER CODE END RTOS_QUEUES */
|
|
|
|
/* Create the thread(s) */
|
|
/* creation of defaultTask */
|
|
defaultTaskHandle = osThreadNew(StartDefaultTask, NULL,
|
|
&defaultTask_attributes);
|
|
|
|
/* creation of draw */
|
|
drawHandle = osThreadNew(startdraw, NULL, &draw_attributes);
|
|
|
|
/* USER CODE BEGIN RTOS_THREADS */
|
|
/* add threads, ... */
|
|
/* USER CODE END RTOS_THREADS */
|
|
|
|
/* USER CODE BEGIN RTOS_EVENTS */
|
|
/* add events, ... */
|
|
/* USER CODE END RTOS_EVENTS */
|
|
|
|
/* Start scheduler */
|
|
osKernelStart();
|
|
|
|
/* We should never get here as control is now taken by the scheduler */
|
|
|
|
/* Infinite loop */
|
|
/* USER CODE BEGIN WHILE */
|
|
uint16_t a, b;
|
|
ILI9341_TouchGetCoordinates(&a, &b);
|
|
GameInit();
|
|
while (1) {
|
|
|
|
/* USER CODE END WHILE */
|
|
|
|
/* 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 };
|
|
|
|
/** Configure the main internal regulator output voltage
|
|
*/
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
|
|
|
|
/** 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();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief SPI1 Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_SPI1_Init(void) {
|
|
|
|
/* USER CODE BEGIN SPI1_Init 0 */
|
|
|
|
/* USER CODE END SPI1_Init 0 */
|
|
|
|
/* USER CODE BEGIN SPI1_Init 1 */
|
|
|
|
/* USER CODE END SPI1_Init 1 */
|
|
/* SPI1 parameter configuration*/
|
|
hspi1.Instance = SPI1;
|
|
hspi1.Init.Mode = SPI_MODE_MASTER;
|
|
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
|
|
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
|
|
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
|
|
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
|
|
hspi1.Init.NSS = SPI_NSS_SOFT;
|
|
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2;
|
|
hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
|
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
|
|
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
|
hspi1.Init.CRCPolynomial = 10;
|
|
if (HAL_SPI_Init(&hspi1) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN SPI1_Init 2 */
|
|
|
|
/* USER CODE END SPI1_Init 2 */
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief SPI2 Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_SPI2_Init(void) {
|
|
|
|
/* USER CODE BEGIN SPI2_Init 0 */
|
|
|
|
/* USER CODE END SPI2_Init 0 */
|
|
|
|
/* USER CODE BEGIN SPI2_Init 1 */
|
|
|
|
/* USER CODE END SPI2_Init 1 */
|
|
/* SPI2 parameter configuration*/
|
|
hspi2.Instance = SPI2;
|
|
hspi2.Init.Mode = SPI_MODE_MASTER;
|
|
hspi2.Init.Direction = SPI_DIRECTION_2LINES;
|
|
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
|
|
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
|
|
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
|
|
hspi2.Init.NSS = SPI_NSS_SOFT;
|
|
hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
|
|
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
|
|
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
|
|
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
|
|
hspi2.Init.CRCPolynomial = 10;
|
|
if (HAL_SPI_Init(&hspi2) != HAL_OK) {
|
|
Error_Handler();
|
|
}
|
|
/* USER CODE BEGIN SPI2_Init 2 */
|
|
|
|
/* USER CODE END SPI2_Init 2 */
|
|
|
|
}
|
|
|
|
/**
|
|
* @brief GPIO Initialization Function
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
static void MX_GPIO_Init(void) {
|
|
/* USER CODE BEGIN MX_GPIO_Init_1 */
|
|
|
|
/* USER CODE END MX_GPIO_Init_1 */
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
|
|
|
/* USER CODE END MX_GPIO_Init_2 */
|
|
}
|
|
|
|
/* USER CODE BEGIN 4 */
|
|
|
|
/* USER CODE END 4 */
|
|
|
|
/* USER CODE BEGIN Header_StartDefaultTask */
|
|
/**
|
|
* @brief Function implementing the defaultTask thread.
|
|
* @param argument: Not used
|
|
* @retval None
|
|
*/
|
|
/* USER CODE END Header_StartDefaultTask */
|
|
void StartDefaultTask(void *argument) {
|
|
/* USER CODE BEGIN 5 */
|
|
/* Infinite loop */
|
|
for (;;) {
|
|
osDelay(1);
|
|
}
|
|
/* USER CODE END 5 */
|
|
}
|
|
|
|
/* USER CODE BEGIN Header_startdraw */
|
|
/**
|
|
* @brief Function implementing the draw thread.
|
|
* @param argument: Not used
|
|
* @retval None
|
|
*/
|
|
/* USER CODE END Header_startdraw */
|
|
void startdraw(void *argument) {
|
|
/* USER CODE BEGIN startdraw */
|
|
/* Infinite loop */
|
|
for (;;) {
|
|
osDelay(100);
|
|
UpdateGame();
|
|
GameRender();
|
|
}
|
|
/* USER CODE END startdraw */
|
|
}
|
|
|
|
/**
|
|
* @brief Period elapsed callback in non blocking mode
|
|
* @note This function is called when TIM2 interrupt took place, inside
|
|
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
|
|
* a global variable "uwTick" used as application time base.
|
|
* @param htim : TIM handle
|
|
* @retval None
|
|
*/
|
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
|
|
/* USER CODE BEGIN Callback 0 */
|
|
|
|
/* USER CODE END Callback 0 */
|
|
if (htim->Instance == TIM2) {
|
|
HAL_IncTick();
|
|
}
|
|
/* USER CODE BEGIN Callback 1 */
|
|
|
|
/* USER CODE END Callback 1 */
|
|
}
|
|
|
|
/**
|
|
* @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 */
|