Skip to main content
mƎALLEm
Technical Moderator
June 2, 2026
Question

This is a thread test 02/06/2026

  • June 2, 2026
  • 4 replies
  • 26 views

This is a thread test

4 replies

mƎALLEm
mƎALLEmAuthor
Technical Moderator
June 2, 2026

This is a Bold text

This is a plain text

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
mƎALLEmAuthor
Technical Moderator
June 2, 2026

Test code insertion:

/**
******************************************************************************
* @file Audio/Audio_playback_and_record/Src/main.c
* @author MCD Application Team
* @brief Audio playback and record main file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/

/* Includes ------------------------------------------------------------------*/
#include "waveplayer.h"
#include "waverecorder.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
USBH_HandleTypeDef hUSB_Host;
AUDIO_ApplicationTypeDef appli_state = APPLICATION_IDLE;
TS_Init_t *hTS;
/* Private function prototypes -----------------------------------------------*/
static void SystemClock_Config(void);
static void Error_Handler(void);
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id);
static void AUDIO_InitApplication(void);
static void MPU_Config(void);
static void CPU_CACHE_Enable(void);

/* Private functions ---------------------------------------------------------*/

/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
uint32_t x_size, y_size;


/* Configure the MPU attributes as Write Through */
MPU_Config();

/* Enable the CPU Cache */
CPU_CACHE_Enable();

/* STM32H7xx HAL library initialization:
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for application or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();

/* Configure the system clock to 400 MHz */
SystemClock_Config();

/* Init Audio Application */
AUDIO_InitApplication();

BSP_LCD_GetXSize(0, &x_size);
BSP_LCD_GetYSize(0, &y_size);
/* Init TS module */
hTS->Width = x_size;
hTS->Height = y_size;
hTS->Orientation = TS_SWAP_NONE;
hTS->Accuracy = 0;
/* Touchscreen initialization */
BSP_TS_Init(0, hTS);

/* Enable the USB voltage level detector */
HAL_PWREx_EnableUSBVoltageDetector();

/* Init Host Library */
if (USBH_Init(&hUSB_Host, USBH_UserProcess, 0) != USBH_OK)
{
/* USB Initialization Error */
Error_Handler();
}

/* Add Supported Class */
USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);

/* Start Host Process */
if (USBH_Start(&hUSB_Host) != USBH_OK)
{
/* USB Initialization Error */
Error_Handler();
}

/* Init storage */
if (AUDIO_StorageInit() != FR_OK)
{
/* FatFs Initialization Error */
Error_Handler();
}

/* Run Application (Blocking mode) */
while (1)
{
/* USB Host Background task */
USBH_Process(&hUSB_Host);

/* AUDIO Menu Process */
AUDIO_MenuProcess();
}
}

/*******************************************************************************
Static Function
*******************************************************************************/

/**
* @brief Audio Application Init.
* @param None
* @retval None
*/
static void AUDIO_InitApplication(void)
{
BSP_LCD_Init(0, LCD_ORIENTATION_LANDSCAPE);
UTIL_LCD_SetFuncDriver(&LCD_Driver);
UTIL_LCD_SetLayer(0);
/* Enable the display */
BSP_LCD_DisplayOn(0);

/* Init the LCD Log module */
UTIL_LCD_TRACE_Init();

UTIL_LCD_TRACE_SetHeader((uint8_t *)"Audio Playback and Record Application");

LCD_UsrTrace("USB Host library started.\n");

/* Start Audio interface */
USBH_UsrLog("Starting Audio Demo");

/* Init Audio interface */
AUDIO_PLAYER_Init();
}

/**
* @brief User Process
* @param phost: Host Handle
* @param id: Host Library user message ID
* @retval None
*/
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{
switch(id)
{
case HOST_USER_SELECT_CONFIGURATION:
break;

case HOST_USER_DISCONNECTION:
appli_state = APPLICATION_DISCONNECT;
break;

case HOST_USER_CLASS_ACTIVE:
appli_state = APPLICATION_READY;
break;

case HOST_USER_CONNECTION:
appli_state = APPLICATION_START;
break;

default:
break;
}
}

/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 400000000 (CPU Clock)
* HCLK(Hz) = 200000000 (AXI and AHBs Clock)
* AHB Prescaler = 2
* D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
* D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
* D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
* D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
* HSE Frequency(Hz) = 25000000
* PLL_M = 5
* PLL_N = 160
* PLL_P = 2
* PLL_Q = 4
* PLL_R = 2
* VDD(V) = 3.3
* Flash Latency(WS) = 4
* @param None
* @retval None
*/
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;

/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}

/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 160;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLQ = 4;

RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
Error_Handler();
}

/* Select PLL as system clock source and configure bus clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
if(ret != HAL_OK)
{
Error_Handler();
}

/*activate CSI clock mondatory for I/O Compensation Cell*/
__HAL_RCC_CSI_ENABLE() ;

/* Enable SYSCFG clock mondatory for I/O Compensation Cell */
__HAL_RCC_SYSCFG_CLK_ENABLE() ;

/* Enables the I/O Compensation Cell */
HAL_EnableCompensationCell();
}

/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void Error_Handler(void)
{
/* LED3 On in error case */
BSP_LED_On(LED3);
while (1)
{
}
}

/**
* @brief Configure the MPU attributes as Write Through for SDRAM.
* @note The Base Address is SDRAM_DEVICE_ADDR.
* The Region Size is 32MB.
* @param None
* @retval None
*/
static void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct;

/* Disable the MPU */
HAL_MPU_Disable();

/* Configure the MPU as Strongly ordered for not defined regions */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x00;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Configure the MPU attributes as WT for SDRAM */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = SDRAM_DEVICE_ADDR;
MPU_InitStruct.Size = MPU_REGION_SIZE_32MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Enable the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

/**
* @brief CPU L1-Cache enable.
* @param None
* @retval None
*/
static void CPU_CACHE_Enable(void)
{
/* Enable I-Cache */
SCB_EnableICache();

/* Enable D-Cache */
SCB_EnableDCache();
}

#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 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) */

/* Infinite loop */
while (1)
{
}
}
#endif

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Technical Moderator
June 2, 2026

it seems we have 2 different line number columns

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
mƎALLEm
mƎALLEmAuthor
Technical Moderator
June 2, 2026
BSP_LCD_GetXSize(0, &x_size);
BSP_LCD_GetYSize(0, &y_size);
hTS->Width = x_size;
hTS->Height = y_size;
hTS->Orientation = TS_SWAP_NONE;
hTS->Accuracy = 0;

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
mƎALLEmAuthor
Technical Moderator
June 2, 2026
/**
******************************************************************************
* @file Audio/Audio_playback_and_record/Src/waveplayer.c
* @author MCD Application Team
* @brief This file provides the Audio Out (playback) interface API
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/

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

/* Private define ------------------------------------------------------------*/
#define TOUCH_NEXT_XMIN 325
#define TOUCH_NEXT_XMAX 365
#define TOUCH_NEXT_YMIN 212
#define TOUCH_NEXT_YMAX 252

#define TOUCH_PREVIOUS_XMIN 250
#define TOUCH_PREVIOUS_XMAX 290
#define TOUCH_PREVIOUS_YMIN 212
#define TOUCH_PREVIOUS_YMAX 252

#define TOUCH_STOP_XMIN 170
#define TOUCH_STOP_XMAX 210
#define TOUCH_STOP_YMIN 212
#define TOUCH_STOP_YMAX 252

#define TOUCH_PAUSE_XMIN 100
#define TOUCH_PAUSE_XMAX 124
#define TOUCH_PAUSE_YMIN 212
#define TOUCH_PAUSE_YMAX 252

#define TOUCH_VOL_MINUS_XMIN 20
#define TOUCH_VOL_MINUS_XMAX 70
#define TOUCH_VOL_MINUS_YMIN 212
#define TOUCH_VOL_MINUS_YMAX 252

#define TOUCH_VOL_PLUS_XMIN 402
#define TOUCH_VOL_PLUS_XMAX 452
#define TOUCH_VOL_PLUS_YMIN 212
#define TOUCH_VOL_PLUS_YMAX 252

/* Private macro -------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Buffer location should aligned to cache line size (32 bytes) */
ALIGN_32BYTES (static AUDIO_OUT_BufferTypeDef BufferCtl);
static int16_t FilePos = 0;
static __IO uint32_t uwVolume = 70;

BSP_AUDIO_Init_t AudioOutInit;
BSP_AUDIO_Init_t AudioInInit;

static Point NextPoints[] = {{TOUCH_NEXT_XMIN, TOUCH_NEXT_YMIN},
{TOUCH_NEXT_XMAX, (TOUCH_NEXT_YMIN+TOUCH_NEXT_YMAX)/2},
{TOUCH_NEXT_XMIN, TOUCH_NEXT_YMAX}};
static Point PreviousPoints[] = {{TOUCH_PREVIOUS_XMIN, (TOUCH_PREVIOUS_YMIN+TOUCH_PREVIOUS_YMAX)/2},
{TOUCH_PREVIOUS_XMAX, TOUCH_PREVIOUS_YMIN},
{TOUCH_PREVIOUS_XMAX, TOUCH_PREVIOUS_YMAX}};

WAVE_FormatTypeDef WaveFormat;
FIL WavFile;
extern FILELIST_FileTypeDef FileList;

/* Private function prototypes -----------------------------------------------*/
static AUDIO_ErrorTypeDef GetFileInfo(uint16_t file_idx, WAVE_FormatTypeDef *info);
static uint8_t PlayerInit(uint32_t AudioFreq);
static void AUDIO_PlaybackDisplayButtons(void);
static void AUDIO_AcquireTouchButtons(void);

/* Private functions ---------------------------------------------------------*/

/**
* @brief Initializes Audio Interface.
* @param None
* @retval Audio error
*/
AUDIO_ErrorTypeDef AUDIO_PLAYER_Init(void)
{
// (AUDIO_OUT_DEVICE_AUTO, uwVolume, AUDIO_FREQUENCY_44K
AudioOutInit.Device = AUDIO_OUT_DEVICE_AUTO;
AudioOutInit.ChannelsNbr = 2;
AudioOutInit.SampleRate = AUDIO_FREQUENCY_44K;
AudioOutInit.BitsPerSample = AUDIO_RESOLUTION_16B;
AudioOutInit.Volume = uwVolume;
if(BSP_AUDIO_OUT_Init(0, &AudioOutInit) == 0)
{
return AUDIO_ERROR_NONE;
}
else
{
return AUDIO_ERROR_IO;
}
}

/**
* @brief Starts Audio streaming.
* @param idx: File index
* @retval Audio error
*/
AUDIO_ErrorTypeDef AUDIO_PLAYER_Start(uint8_t idx)
{
uint32_t bytesread;

f_close(&WavFile);
if(AUDIO_GetWavObjectNumber() > idx)
{
GetFileInfo(idx, &WaveFormat);

/*Adjust the Audio frequency */
PlayerInit(WaveFormat.SampleRate);

BufferCtl.state = BUFFER_OFFSET_NONE;

/* Get Data from USB Flash Disk */
f_lseek(&WavFile, 0);

/* Fill whole buffer at first time */
if(f_read(&WavFile,
&BufferCtl.buff[0],
AUDIO_OUT_BUFFER_SIZE,
(void *)&bytesread) == FR_OK)
{
AudioState = AUDIO_STATE_PLAY;
AUDIO_PlaybackDisplayButtons();
UTIL_LCD_DisplayStringAt(250, LINE(9), (uint8_t *)" [PLAY ]", LEFT_MODE);
{
if(bytesread != 0)
{
/* Clean Data Cache to update the content of the SRAM */
SCB_CleanDCache_by_Addr((uint32_t*)&BufferCtl.buff[0], AUDIO_OUT_BUFFER_SIZE);

BSP_AUDIO_OUT_Play(0,(uint8_t*)&BufferCtl.buff[0], AUDIO_OUT_BUFFER_SIZE);
BufferCtl.fptr = bytesread;
return AUDIO_ERROR_NONE;
}
}
}
}
return AUDIO_ERROR_IO;
}

/**
* @brief Manages Audio process.
* @param None
* @retval Audio error
*/
AUDIO_ErrorTypeDef AUDIO_PLAYER_Process(void)
{
uint32_t bytesread, elapsed_time;
AUDIO_ErrorTypeDef audio_error = AUDIO_ERROR_NONE;
static uint32_t prev_elapsed_time = 0xFFFFFFFF;
uint8_t str[32];

switch(AudioState)
{
case AUDIO_STATE_PLAY:
if(BufferCtl.fptr >= WaveFormat.FileSize)
{
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
AudioState = AUDIO_STATE_NEXT;
}

if(BufferCtl.state == BUFFER_OFFSET_HALF)
{
if(f_read(&WavFile,
&BufferCtl.buff[0],
AUDIO_OUT_BUFFER_SIZE/2,
(void *)&bytesread) != FR_OK)
{
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
return AUDIO_ERROR_IO;
}

/* Clean Data Cache to update the content of the SRAM */
SCB_CleanDCache_by_Addr((uint32_t*)&BufferCtl.buff[0], AUDIO_OUT_BUFFER_SIZE/2);

BufferCtl.state = BUFFER_OFFSET_NONE;
BufferCtl.fptr += bytesread;
}

if(BufferCtl.state == BUFFER_OFFSET_FULL)
{
if(f_read(&WavFile,
&BufferCtl.buff[AUDIO_OUT_BUFFER_SIZE /2],
AUDIO_OUT_BUFFER_SIZE/2,
(void *)&bytesread) != FR_OK)
{
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
return AUDIO_ERROR_IO;
}

/* Clean Data Cache to update the content of the SRAM */
SCB_CleanDCache_by_Addr((uint32_t*)&BufferCtl.buff[AUDIO_OUT_BUFFER_SIZE/2], AUDIO_OUT_BUFFER_SIZE/2);

BufferCtl.state = BUFFER_OFFSET_NONE;
BufferCtl.fptr += bytesread;
}

/* Display elapsed time */
elapsed_time = BufferCtl.fptr / WaveFormat.ByteRate;
if(prev_elapsed_time != elapsed_time)
{
prev_elapsed_time = elapsed_time;
sprintf((char *)str, "[%02d:%02d]", (int)(elapsed_time /60), (int)(elapsed_time%60));
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DisplayStringAt(263, LINE(8), str, LEFT_MODE);
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_WHITE);
}

/* Update audio state machine according to touch acquisition */
AUDIO_AcquireTouchButtons();
break;

case AUDIO_STATE_STOP:
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_RED);
UTIL_LCD_FillRect(TOUCH_STOP_XMIN, TOUCH_STOP_YMIN , /* Stop rectangle */
TOUCH_STOP_XMAX - TOUCH_STOP_XMIN,
TOUCH_STOP_YMAX - TOUCH_STOP_YMIN,UTIL_LCD_COLOR_RED);
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
BSP_AUDIO_OUT_DeInit(0);
AudioState = AUDIO_STATE_IDLE;
audio_error = AUDIO_ERROR_IO;
break;

case AUDIO_STATE_NEXT:
if(++FilePos >= AUDIO_GetWavObjectNumber())
{
FilePos = 0;
}
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
AUDIO_PLAYER_Start(FilePos);
if(uwVolume == 0)
{
BSP_AUDIO_OUT_SetVolume(0,uwVolume);
}
break;

case AUDIO_STATE_PREVIOUS:
if(--FilePos < 0)
{
FilePos = AUDIO_GetWavObjectNumber() - 1;
}
BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
AUDIO_PLAYER_Start(FilePos);
if(uwVolume == 0)
{
BSP_AUDIO_OUT_SetVolume(0,uwVolume);
}
break;

case AUDIO_STATE_PAUSE:
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DisplayStringAt(250, LINE(9), (uint8_t *)" [PAUSE]", LEFT_MODE);
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_RED); /* Display red pause rectangles */
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN, TOUCH_PAUSE_YMIN , 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_RED);
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN + 20, TOUCH_PAUSE_YMIN, 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_RED);
BSP_AUDIO_OUT_Pause(0);
AudioState = AUDIO_STATE_WAIT;
break;

case AUDIO_STATE_RESUME:
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DisplayStringAt(250, LINE(9), (uint8_t *)" [PLAY ]", LEFT_MODE);
/* Display blue cyan pause rectangles */
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN, TOUCH_PAUSE_YMIN , 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN + 20, TOUCH_PAUSE_YMIN, 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_CYAN);
BSP_AUDIO_OUT_Resume(0);
if(uwVolume == 0)
{
BSP_AUDIO_OUT_SetVolume(0,uwVolume);
}
AudioState = AUDIO_STATE_PLAY;
break;

case AUDIO_STATE_VOLUME_UP:
if( uwVolume <= 90)
{
uwVolume += 10;
}
BSP_AUDIO_OUT_SetVolume(0,uwVolume);
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_WHITE);
sprintf((char *)str, "Volume : %lu ", uwVolume);
UTIL_LCD_DisplayStringAtLine(9, str);
AudioState = AUDIO_STATE_PLAY;
break;

case AUDIO_STATE_VOLUME_DOWN:
if( uwVolume >= 10)
{
uwVolume -= 10;
}
BSP_AUDIO_OUT_SetVolume(0,uwVolume);
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_WHITE);
sprintf((char *)str, "Volume : %lu ", uwVolume);
UTIL_LCD_DisplayStringAtLine(9, str);
AudioState = AUDIO_STATE_PLAY;
break;

case AUDIO_STATE_WAIT:
case AUDIO_STATE_IDLE:
case AUDIO_STATE_INIT:
default:
/* Update audio state machine according to touch acquisition */
AUDIO_AcquireTouchButtons();
break;
}
return audio_error;
}

/**
* @brief Stops Audio streaming.
* @param None
* @retval Audio error
*/
AUDIO_ErrorTypeDef AUDIO_PLAYER_Stop(void)
{
AudioState = AUDIO_STATE_STOP;
FilePos = 0;

BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);
f_close(&WavFile);
return AUDIO_ERROR_NONE;
}

/**
* @brief Calculates the remaining file size and new position of the pointer.
* @param None
* @retval None
*/
void BSP_AUDIO_OUT_TransferComplete_CallBack(uint32_t Instance)
{
if(AudioState == AUDIO_STATE_PLAY)
{
BufferCtl.state = BUFFER_OFFSET_FULL;
}
}

/**
* @brief Manages the DMA Half Transfer complete interrupt.
* @param None
* @retval None
*/
void BSP_AUDIO_OUT_HalfTransfer_CallBack(uint32_t Instance)
{
if(AudioState == AUDIO_STATE_PLAY)
{
BufferCtl.state = BUFFER_OFFSET_HALF;
}
}
/*******************************************************************************
Static Functions
*******************************************************************************/

/**
* @brief Gets the file info.
* @param file_idx: File index
* @param info: Pointer to WAV file info
* @retval Audio error
*/
static AUDIO_ErrorTypeDef GetFileInfo(uint16_t file_idx, WAVE_FormatTypeDef *info)
{
uint32_t bytesread;
uint32_t duration;
uint8_t str[FILEMGR_FILE_NAME_SIZE + 30];

if(f_open(&WavFile, (char *)FileList.file[file_idx].name, FA_OPEN_EXISTING | FA_READ) == FR_OK)
{
/* Fill the buffer to Send */
if(f_read(&WavFile, info, sizeof(WaveFormat), (void *)&bytesread) == FR_OK)
{
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_WHITE);
sprintf((char *)str, "Playing file (%d/%d): %s",
file_idx + 1, FileList.ptr,
(char *)FileList.file[file_idx].name);
UTIL_LCD_ClearStringLine(4);
UTIL_LCD_DisplayStringAtLine(4, str);

UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
sprintf((char *)str, "Sample rate : %d Hz", (int)(info->SampleRate));
UTIL_LCD_ClearStringLine(6);
UTIL_LCD_DisplayStringAtLine(6, str);

sprintf((char *)str, "Channels number : %d", info->NbrChannels);
UTIL_LCD_ClearStringLine(7);
UTIL_LCD_DisplayStringAtLine(7, str);

duration = info->FileSize / info->ByteRate;
sprintf((char *)str, "File Size : %d KB [%02d:%02d]", (int)(info->FileSize/1024), (int)(duration/60), (int)(duration%60));
UTIL_LCD_ClearStringLine(8);
UTIL_LCD_DisplayStringAtLine(8, str);
UTIL_LCD_DisplayStringAt(263, LINE(8), (uint8_t *)"[00:00]", LEFT_MODE);

UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_WHITE);
sprintf((char *)str, "Volume : %lu", uwVolume);
UTIL_LCD_ClearStringLine(9);
UTIL_LCD_DisplayStringAtLine(9, str);
return AUDIO_ERROR_NONE;
}
f_close(&WavFile);
}
return AUDIO_ERROR_IO;
}

/**
* @brief Initializes the Wave player.
* @param AudioFreq: Audio sampling frequency
* @retval None
*/
static uint8_t PlayerInit(uint32_t AudioFreq)
{
/* Initialize the Audio codec and all related peripherals (I2S, I2C, IOExpander, IOs...) */
AudioOutInit.Device = AUDIO_OUT_DEVICE_HEADPHONE;
AudioOutInit.ChannelsNbr = 2;
AudioOutInit.SampleRate = AudioFreq;
AudioOutInit.BitsPerSample = AUDIO_RESOLUTION_16B;
AudioOutInit.Volume = uwVolume;
if(BSP_AUDIO_OUT_Init(0, &AudioOutInit)!= 0)
{
return 1;
}
else
{
return 0;
}
}

/**
* @brief Display interface touch screen buttons
* @param None
* @retval None
*/
static void AUDIO_PlaybackDisplayButtons(void)
{
UTIL_LCD_SetFont(&LCD_TRACE_HEADER_FONT);
UTIL_LCD_ClearStringLine(13); /* Clear dedicated zone */
UTIL_LCD_ClearStringLine(14);
UTIL_LCD_ClearStringLine(15);

UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
UTIL_LCD_FillPolygon(PreviousPoints, 3,UTIL_LCD_COLOR_CYAN); /* Previous track icon */
UTIL_LCD_FillRect(TOUCH_PREVIOUS_XMIN, TOUCH_PREVIOUS_YMIN , 10, TOUCH_PREVIOUS_YMAX - TOUCH_PREVIOUS_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_FillPolygon(NextPoints, 3,UTIL_LCD_COLOR_CYAN); /* Next track icon */
UTIL_LCD_FillRect(TOUCH_NEXT_XMAX-9, TOUCH_NEXT_YMIN , 10, TOUCH_NEXT_YMAX - TOUCH_NEXT_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN, TOUCH_PAUSE_YMIN , 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_CYAN); /* Pause rectangles */
UTIL_LCD_FillRect(TOUCH_PAUSE_XMIN + 20, TOUCH_PAUSE_YMIN, 15, TOUCH_PAUSE_YMAX - TOUCH_PAUSE_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_FillRect(TOUCH_STOP_XMIN, TOUCH_STOP_YMIN , /* Stop rectangle */
TOUCH_STOP_XMAX - TOUCH_STOP_XMIN,
TOUCH_STOP_YMAX - TOUCH_STOP_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DrawRect(TOUCH_VOL_MINUS_XMIN, TOUCH_VOL_MINUS_YMIN , /* VOl- rectangle */
TOUCH_VOL_MINUS_XMAX - TOUCH_VOL_MINUS_XMIN,
TOUCH_VOL_MINUS_YMAX - TOUCH_VOL_MINUS_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DisplayStringAt(24, LINE(14), (uint8_t *)"VOl-", LEFT_MODE);
UTIL_LCD_DrawRect(TOUCH_VOL_PLUS_XMIN, TOUCH_VOL_PLUS_YMIN , /* VOl+ rectangle */
TOUCH_VOL_PLUS_XMAX - TOUCH_VOL_PLUS_XMIN,
TOUCH_VOL_PLUS_YMAX - TOUCH_VOL_PLUS_YMIN,UTIL_LCD_COLOR_CYAN);
UTIL_LCD_DisplayStringAt(404, LINE(14), (uint8_t *)"VOl+", LEFT_MODE);

UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_GREEN);
UTIL_LCD_SetFont(&LCD_TRACE_TEXT_FONT);
UTIL_LCD_ClearStringLine(15);
UTIL_LCD_DisplayStringAtLine(15, (uint8_t *)"Use stop button to exit");
UTIL_LCD_SetTextColor(UTIL_LCD_COLOR_CYAN);
}

/**
* @brief Test touch screen state and modify audio state machine according to that
* @param None
* @retval None
*/
static void AUDIO_AcquireTouchButtons(void)
{
static TS_State_t TS_State = {0};
static uint32_t TouchdOn = 0;

BSP_TS_GetState(0,&TS_State);
if(TS_State.TouchDetected == 1) /* If previous touch has not been released, we don't proceed any touch command */
{
TouchdOn++;
TS_State.TouchDetected = 0;
}
if(TouchdOn > 2)
{
TouchdOn = 0;

if ((TS_State.TouchX > TOUCH_PAUSE_XMIN) && (TS_State.TouchX < TOUCH_PAUSE_XMAX) &&
(TS_State.TouchY > TOUCH_PAUSE_YMIN) && (TS_State.TouchY < TOUCH_PAUSE_YMAX))
{
HAL_Delay(50);
TS_State.TouchDetected = 0;
if (AudioState == AUDIO_STATE_PLAY)
{
AudioState = AUDIO_STATE_PAUSE;
}
else
{
AudioState = AUDIO_STATE_PLAY;
}
}
else if ((TS_State.TouchX > TOUCH_NEXT_XMIN) && (TS_State.TouchX < TOUCH_NEXT_XMAX) &&
(TS_State.TouchY > TOUCH_NEXT_YMIN) && (TS_State.TouchY < TOUCH_NEXT_YMAX))
{
AudioState = AUDIO_STATE_NEXT;
}
else if ((TS_State.TouchX > TOUCH_PREVIOUS_XMIN) && (TS_State.TouchX < TOUCH_PREVIOUS_XMAX) &&
(TS_State.TouchY > TOUCH_PREVIOUS_YMIN) && (TS_State.TouchY < TOUCH_PREVIOUS_YMAX))
{
AudioState = AUDIO_STATE_PREVIOUS;
}
else if ((TS_State.TouchX > TOUCH_STOP_XMIN) && (TS_State.TouchX < TOUCH_STOP_XMAX) &&
(TS_State.TouchY > TOUCH_STOP_YMIN) && (TS_State.TouchY < TOUCH_STOP_YMAX))
{
AudioState = AUDIO_STATE_STOP;
}
else if((TS_State.TouchX > TOUCH_VOL_MINUS_XMIN) && (TS_State.TouchX < TOUCH_VOL_MINUS_XMAX) &&
(TS_State.TouchY > TOUCH_VOL_MINUS_YMIN) && (TS_State.TouchY < TOUCH_VOL_MINUS_YMAX))
{
AudioState = AUDIO_STATE_VOLUME_DOWN;
}
else if((TS_State.TouchX > TOUCH_VOL_PLUS_XMIN) && (TS_State.TouchX < TOUCH_VOL_PLUS_XMAX) &&
(TS_State.TouchY > TOUCH_VOL_PLUS_YMIN) && (TS_State.TouchY < TOUCH_VOL_PLUS_YMAX))
{
AudioState = AUDIO_STATE_VOLUME_UP;
}
}
}


 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
mƎALLEmAuthor
Technical Moderator
June 2, 2026
/**
******************************************************************************
* @file Audio/Audio_playback_and_record/Src/main.c
* @author MCD Application Team
* @brief Audio playback and record main file.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/

/* Includes ------------------------------------------------------------------*/
#include "waveplayer.h"
#include "waverecorder.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
USBH_HandleTypeDef hUSB_Host;
AUDIO_ApplicationTypeDef appli_state = APPLICATION_IDLE;
TS_Init_t *hTS;
/* Private function prototypes -----------------------------------------------*/
static void SystemClock_Config(void);
static void Error_Handler(void);
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id);
static void AUDIO_InitApplication(void);
static void MPU_Config(void);
static void CPU_CACHE_Enable(void);

/* Private functions ---------------------------------------------------------*/

/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
uint32_t x_size, y_size;


/* Configure the MPU attributes as Write Through */
MPU_Config();

/* Enable the CPU Cache */
CPU_CACHE_Enable();

/* STM32H7xx HAL library initialization:
- Systick timer is configured by default as source of time base, but user
can eventually implement his proper time base source (a general purpose
timer for application or other time source), keeping in mind that Time base
duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
handled in milliseconds basis.
- Set NVIC Group Priority to 4
- Low Level Initialization
*/
HAL_Init();

/* Configure the system clock to 400 MHz */
SystemClock_Config();

/* Init Audio Application */
AUDIO_InitApplication();

BSP_LCD_GetXSize(0, &x_size);
BSP_LCD_GetYSize(0, &y_size);
/* Init TS module */
hTS->Width = x_size;
hTS->Height = y_size;
hTS->Orientation = TS_SWAP_NONE;
hTS->Accuracy = 0;
/* Touchscreen initialization */
BSP_TS_Init(0, hTS);

/* Enable the USB voltage level detector */
HAL_PWREx_EnableUSBVoltageDetector();

/* Init Host Library */
if (USBH_Init(&hUSB_Host, USBH_UserProcess, 0) != USBH_OK)
{
/* USB Initialization Error */
Error_Handler();
}

/* Add Supported Class */
USBH_RegisterClass(&hUSB_Host, USBH_MSC_CLASS);

/* Start Host Process */
if (USBH_Start(&hUSB_Host) != USBH_OK)
{
/* USB Initialization Error */
Error_Handler();
}

/* Init storage */
if (AUDIO_StorageInit() != FR_OK)
{
/* FatFs Initialization Error */
Error_Handler();
}

/* Run Application (Blocking mode) */
while (1)
{
/* USB Host Background task */
USBH_Process(&hUSB_Host);

/* AUDIO Menu Process */
AUDIO_MenuProcess();
}
}

/*******************************************************************************
Static Function
*******************************************************************************/

/**
* @brief Audio Application Init.
* @param None
* @retval None
*/
static void AUDIO_InitApplication(void)
{
BSP_LCD_Init(0, LCD_ORIENTATION_LANDSCAPE);
UTIL_LCD_SetFuncDriver(&LCD_Driver);
UTIL_LCD_SetLayer(0);
/* Enable the display */
BSP_LCD_DisplayOn(0);

/* Init the LCD Log module */
UTIL_LCD_TRACE_Init();

UTIL_LCD_TRACE_SetHeader((uint8_t *)"Audio Playback and Record Application");

LCD_UsrTrace("USB Host library started.\n");

/* Start Audio interface */
USBH_UsrLog("Starting Audio Demo");

/* Init Audio interface */
AUDIO_PLAYER_Init();
}

/**
* @brief User Process
* @param phost: Host Handle
* @param id: Host Library user message ID
* @retval None
*/
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id)
{
switch(id)
{
case HOST_USER_SELECT_CONFIGURATION:
break;

case HOST_USER_DISCONNECTION:
appli_state = APPLICATION_DISCONNECT;
break;

case HOST_USER_CLASS_ACTIVE:
appli_state = APPLICATION_READY;
break;

case HOST_USER_CONNECTION:
appli_state = APPLICATION_START;
break;

default:
break;
}
}

/**
* @brief System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 400000000 (CPU Clock)
* HCLK(Hz) = 200000000 (AXI and AHBs Clock)
* AHB Prescaler = 2
* D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
* D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
* D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
* D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
* HSE Frequency(Hz) = 25000000
* PLL_M = 5
* PLL_N = 160
* PLL_P = 2
* PLL_Q = 4
* PLL_R = 2
* VDD(V) = 3.3
* Flash Latency(WS) = 4
* @param None
* @retval None
*/
static void SystemClock_Config(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
HAL_StatusTypeDef ret = HAL_OK;

/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

while ((PWR->D3CR & (PWR_D3CR_VOSRDY)) != PWR_D3CR_VOSRDY) {}

/* Enable HSE Oscillator and activate PLL with HSE as source */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_OFF;
RCC_OscInitStruct.CSIState = RCC_CSI_OFF;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

RCC_OscInitStruct.PLL.PLLM = 5;
RCC_OscInitStruct.PLL.PLLN = 160;
RCC_OscInitStruct.PLL.PLLFRACN = 0;
RCC_OscInitStruct.PLL.PLLP = 2;
RCC_OscInitStruct.PLL.PLLR = 2;
RCC_OscInitStruct.PLL.PLLQ = 4;

RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_2;
ret = HAL_RCC_OscConfig(&RCC_OscInitStruct);
if(ret != HAL_OK)
{
Error_Handler();
}

/* Select PLL as system clock source and configure bus clocks dividers */
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_D1PCLK1 | RCC_CLOCKTYPE_PCLK1 | \
RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_D3PCLK1);

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB3CLKDivider = RCC_APB3_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_APB1_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
ret = HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4);
if(ret != HAL_OK)
{
Error_Handler();
}

/*activate CSI clock mondatory for I/O Compensation Cell*/
__HAL_RCC_CSI_ENABLE() ;

/* Enable SYSCFG clock mondatory for I/O Compensation Cell */
__HAL_RCC_SYSCFG_CLK_ENABLE() ;

/* Enables the I/O Compensation Cell */
HAL_EnableCompensationCell();
}

/**
* @brief This function is executed in case of error occurrence.
* @param None
* @retval None
*/
void Error_Handler(void)
{
/* LED3 On in error case */
BSP_LED_On(LED3);
while (1)
{
}
}

/**
* @brief Configure the MPU attributes as Write Through for SDRAM.
* @note The Base Address is SDRAM_DEVICE_ADDR.
* The Region Size is 32MB.
* @param None
* @retval None
*/
static void MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_InitStruct;

/* Disable the MPU */
HAL_MPU_Disable();

/* Configure the MPU as Strongly ordered for not defined regions */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x00;
MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x87;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Configure the MPU attributes as WT for SDRAM */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = SDRAM_DEVICE_ADDR;
MPU_InitStruct.Size = MPU_REGION_SIZE_32MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

/* Enable the MPU */
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

/**
* @brief CPU L1-Cache enable.
* @param None
* @retval None
*/
static void CPU_CACHE_Enable(void)
{
/* Enable I-Cache */
SCB_EnableICache();

/* Enable D-Cache */
SCB_EnableDCache();
}

#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 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) */

/* Infinite loop */
while (1)
{
}
}
#endif

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.