Migrated (version bump, tool && libs)
This commit is contained in:
parent
bc01b1f0e8
commit
033122ffb3
156 changed files with 155620 additions and 138408 deletions
|
@ -1,342 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file bsp_driver_sd.c for F4 (based on stm324x9i_eval_sd.c)
|
||||
* @brief This file includes a generic uSD card driver.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifdef OLD_API
|
||||
/* kept to avoid issue when migrating old projects. */
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
#else
|
||||
/* USER CODE BEGIN FirstSection */
|
||||
/* can be used to modify / undefine following code or add new definitions */
|
||||
/* USER CODE END FirstSection */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "bsp_driver_sd.h"
|
||||
|
||||
/* Extern variables ---------------------------------------------------------*/
|
||||
|
||||
extern SD_HandleTypeDef hsd;
|
||||
|
||||
/* USER CODE BEGIN BeforeInitSection */
|
||||
/* can be used to modify / undefine following code or add code */
|
||||
/* USER CODE END BeforeInitSection */
|
||||
/**
|
||||
* @brief Initializes the SD card device.
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_Init(void)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
/* Check if the SD card is plugged in the slot */
|
||||
if (BSP_SD_IsDetected() != SD_PRESENT)
|
||||
{
|
||||
return MSD_ERROR;
|
||||
}
|
||||
/* HAL SD initialization */
|
||||
sd_state = HAL_SD_Init(&hsd);
|
||||
/* Configure SD Bus width (4 bits mode selected) */
|
||||
if (sd_state == MSD_OK)
|
||||
{
|
||||
/* Enable wide operation */
|
||||
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
/* USER CODE BEGIN AfterInitSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END AfterInitSection */
|
||||
|
||||
/**
|
||||
* @brief Configures Interrupt mode for SD detection pin.
|
||||
* @retval Returns 0 in success otherwise 1.
|
||||
*/
|
||||
uint8_t BSP_SD_ITConfig(void)
|
||||
{
|
||||
/* TBI: add user code here depending on the hardware configuration used */
|
||||
|
||||
return (uint8_t)0;
|
||||
}
|
||||
|
||||
/** @brief SD detect IT treatment
|
||||
*/
|
||||
void BSP_SD_DetectIT(void)
|
||||
{
|
||||
/* TBI: add user code here depending on the hardware configuration used */
|
||||
}
|
||||
|
||||
/** @brief SD detect IT detection callback
|
||||
*/
|
||||
__weak void BSP_SD_DetectCallback(void)
|
||||
{
|
||||
/* NOTE: This function Should not be modified, when the callback is needed,
|
||||
the BSP_SD_DetectCallback could be implemented in the user file
|
||||
*/
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeReadBlocksSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeReadBlocksSection */
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in polling mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param ReadAddr: Address from where data is to be read
|
||||
* @param NumOfBlocks: Number of SD blocks to read
|
||||
* @param Timeout: Timeout for read operation
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
if (HAL_SD_ReadBlocks(&hsd, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeWriteBlocksSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeWriteBlocksSection */
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in polling mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param WriteAddr: Address from where data is to be written
|
||||
* @param NumOfBlocks: Number of SD blocks to write
|
||||
* @param Timeout: Timeout for write operation
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
if (HAL_SD_WriteBlocks(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeReadDMABlocksSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeReadDMABlocksSection */
|
||||
/**
|
||||
* @brief Reads block(s) from a specified address in an SD card, in DMA mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param ReadAddr: Address from where data is to be read
|
||||
* @param NumOfBlocks: Number of SD blocks to read
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
/* Read block(s) in DMA transfer mode */
|
||||
if (HAL_SD_ReadBlocks_DMA(&hsd, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeWriteDMABlocksSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeWriteDMABlocksSection */
|
||||
/**
|
||||
* @brief Writes block(s) to a specified address in an SD card, in DMA mode.
|
||||
* @param pData: Pointer to the buffer that will contain the data to transmit
|
||||
* @param WriteAddr: Address from where data is to be written
|
||||
* @param NumOfBlocks: Number of SD blocks to write
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
/* Write block(s) in DMA transfer mode */
|
||||
if (HAL_SD_WriteBlocks_DMA(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeEraseSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeEraseSection */
|
||||
/**
|
||||
* @brief Erases the specified memory area of the given SD card.
|
||||
* @param StartAddr: Start byte address
|
||||
* @param EndAddr: End byte address
|
||||
* @retval SD status
|
||||
*/
|
||||
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
if (HAL_SD_Erase(&hsd, StartAddr, EndAddr) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeHandlersSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeHandlersSection */
|
||||
/**
|
||||
* @brief Handles SD card interrupt request.
|
||||
*/
|
||||
void BSP_SD_IRQHandler(void)
|
||||
{
|
||||
HAL_SD_IRQHandler(&hsd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles SD DMA Tx transfer interrupt request.
|
||||
*/
|
||||
void BSP_SD_DMA_Tx_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(hsd.hdmatx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handles SD DMA Rx transfer interrupt request.
|
||||
*/
|
||||
void BSP_SD_DMA_Rx_IRQHandler(void)
|
||||
{
|
||||
HAL_DMA_IRQHandler(hsd.hdmarx);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the current SD card data status.
|
||||
* @param None
|
||||
* @retval Data transfer state.
|
||||
* This value can be one of the following values:
|
||||
* @arg SD_TRANSFER_OK: No data transfer is acting
|
||||
* @arg SD_TRANSFER_BUSY: Data transfer is acting
|
||||
*/
|
||||
uint8_t BSP_SD_GetCardState(void)
|
||||
{
|
||||
return ((HAL_SD_GetCardState(&hsd) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get SD information about specific SD card.
|
||||
* @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
|
||||
* @retval None
|
||||
*/
|
||||
void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
|
||||
{
|
||||
/* Get SD card Information */
|
||||
HAL_SD_GetCardInfo(&hsd, CardInfo);
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeCallBacksSection */
|
||||
/* can be used to modify previous code / undefine following code / add code */
|
||||
/* USER CODE END BeforeCallBacksSection */
|
||||
/**
|
||||
* @brief SD Abort callbacks
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_AbortCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tx Transfer completed callback
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_WriteCpltCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Rx Transfer completed callback
|
||||
* @param hsd: SD handle
|
||||
* @retval None
|
||||
*/
|
||||
void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
|
||||
{
|
||||
BSP_SD_ReadCpltCallback();
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN CallBacksSection_C */
|
||||
/**
|
||||
* @brief BSP SD Abort callback
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_AbortCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Tx Transfer completed callback
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_WriteCpltCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief BSP Rx Transfer completed callback
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_ReadCpltCallback(void)
|
||||
{
|
||||
|
||||
}
|
||||
/* USER CODE END CallBacksSection_C */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Detects if SD card is correctly plugged in the memory slot or not.
|
||||
* @param None
|
||||
* @retval Returns if SD is detected or not
|
||||
*/
|
||||
uint8_t BSP_SD_IsDetected(void)
|
||||
{
|
||||
__IO uint8_t status = SD_PRESENT;
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
/* user code can be inserted here */
|
||||
/* USER CODE END 1 */
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN AdditionalCode */
|
||||
/* user code can be inserted here */
|
||||
/* USER CODE END AdditionalCode */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
33
Src/crc.c
33
Src/crc.c
|
@ -1,22 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : CRC.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the CRC instances.
|
||||
* @file crc.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the CRC instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "crc.h"
|
||||
|
||||
|
@ -28,13 +28,22 @@
|
|||
void MX_CRC_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN CRC_Init 0 */
|
||||
|
||||
/* USER CODE END CRC_Init 0 */
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_CRC);
|
||||
|
||||
/* USER CODE BEGIN CRC_Init 1 */
|
||||
|
||||
/* USER CODE END CRC_Init 1 */
|
||||
/* USER CODE BEGIN CRC_Init 2 */
|
||||
|
||||
/* USER CODE END CRC_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
32
Src/dma.c
32
Src/dma.c
|
@ -1,21 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : dma.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of all the requested memory to memory DMA transfers.
|
||||
* @file dma.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of all the requested memory to memory DMA transfers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "dma.h"
|
||||
|
@ -32,10 +33,10 @@
|
|||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/**
|
||||
/**
|
||||
* Enable DMA controller clock
|
||||
*/
|
||||
void MX_DMA_Init(void)
|
||||
void MX_DMA_Init(void)
|
||||
{
|
||||
|
||||
/* Init with LL driver */
|
||||
|
@ -163,12 +164,3 @@ void MX_DMA_Init(void)
|
|||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
56
Src/fatfs.c
56
Src/fatfs.c
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* @file fatfs.c
|
||||
* @brief Code for fatfs applications
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "fatfs.h"
|
||||
|
||||
uint8_t retSD; /* Return value for SD */
|
||||
char SDPath[4]; /* SD logical drive path */
|
||||
FATFS SDFatFS; /* File system object for SD logical drive */
|
||||
FIL SDFile; /* File object for SD */
|
||||
|
||||
/* USER CODE BEGIN Variables */
|
||||
|
||||
/* USER CODE END Variables */
|
||||
|
||||
void MX_FATFS_Init(void)
|
||||
{
|
||||
/*## FatFS: Link the SD driver ###########################*/
|
||||
retSD = FATFS_LinkDriver(&SD_Driver, SDPath);
|
||||
|
||||
/* USER CODE BEGIN Init */
|
||||
/* additional user code for init */
|
||||
/* USER CODE END Init */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets Time from RTC
|
||||
* @param None
|
||||
* @retval Time in DWORD
|
||||
*/
|
||||
DWORD get_fattime(void)
|
||||
{
|
||||
/* USER CODE BEGIN get_fattime */
|
||||
return 0;
|
||||
/* USER CODE END get_fattime */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Application */
|
||||
|
||||
/* USER CODE END Application */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
50
Src/fsmc.c
50
Src/fsmc.c
|
@ -1,3 +1,4 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : FSMC.c
|
||||
|
@ -6,16 +7,16 @@
|
|||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "fsmc.h"
|
||||
|
@ -29,8 +30,16 @@ SRAM_HandleTypeDef hsram1;
|
|||
/* FSMC initialization function */
|
||||
void MX_FSMC_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN FSMC_Init 0 */
|
||||
|
||||
/* USER CODE END FSMC_Init 0 */
|
||||
|
||||
FSMC_NORSRAM_TimingTypeDef Timing = {0};
|
||||
|
||||
/* USER CODE BEGIN FSMC_Init 1 */
|
||||
|
||||
/* USER CODE END FSMC_Init 1 */
|
||||
|
||||
/** Perform the SRAM1 memory initialization sequence
|
||||
*/
|
||||
hsram1.Instance = FSMC_NORSRAM_DEVICE;
|
||||
|
@ -65,6 +74,9 @@ void MX_FSMC_Init(void)
|
|||
Error_Handler( );
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN FSMC_Init 2 */
|
||||
|
||||
/* USER CODE END FSMC_Init 2 */
|
||||
}
|
||||
|
||||
static uint32_t FSMC_Initialized = 0;
|
||||
|
@ -81,8 +93,8 @@ static void HAL_FSMC_MspInit(void){
|
|||
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_FSMC_CLK_ENABLE();
|
||||
|
||||
/** FSMC GPIO Configuration
|
||||
|
||||
/** FSMC GPIO Configuration
|
||||
PE7 ------> FSMC_D4
|
||||
PE8 ------> FSMC_D5
|
||||
PE9 ------> FSMC_D6
|
||||
|
@ -105,8 +117,8 @@ static void HAL_FSMC_MspInit(void){
|
|||
PD7 ------> FSMC_NE1
|
||||
*/
|
||||
/* GPIO_InitStruct */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
|
@ -116,8 +128,8 @@ static void HAL_FSMC_MspInit(void){
|
|||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||
|
||||
/* GPIO_InitStruct */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_13
|
||||
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_13
|
||||
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
|
@ -153,8 +165,8 @@ static void HAL_FSMC_MspDeInit(void){
|
|||
FSMC_DeInitialized = 1;
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_FSMC_CLK_DISABLE();
|
||||
|
||||
/** FSMC GPIO Configuration
|
||||
|
||||
/** FSMC GPIO Configuration
|
||||
PE7 ------> FSMC_D4
|
||||
PE8 ------> FSMC_D5
|
||||
PE9 ------> FSMC_D6
|
||||
|
@ -177,12 +189,12 @@ static void HAL_FSMC_MspDeInit(void){
|
|||
PD7 ------> FSMC_NE1
|
||||
*/
|
||||
|
||||
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10
|
||||
|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_13
|
||||
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|
||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_13
|
||||
|GPIO_PIN_14|GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1
|
||||
|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7);
|
||||
|
||||
/* USER CODE BEGIN FSMC_MspDeInit 1 */
|
||||
|
@ -206,5 +218,3 @@ void HAL_SRAM_MspDeInit(SRAM_HandleTypeDef* sramHandle){
|
|||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
28
Src/gpio.c
28
Src/gpio.c
|
@ -1,24 +1,26 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : gpio.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of all used GPIO pins.
|
||||
* @file gpio.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of all used GPIO pins.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "gpio.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
@ -30,9 +32,9 @@
|
|||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/** Configure pins as
|
||||
* Analog
|
||||
* Input
|
||||
/** Configure pins as
|
||||
* Analog
|
||||
* Input
|
||||
* Output
|
||||
* EVENT_OUT
|
||||
* EXTI
|
||||
|
@ -100,5 +102,3 @@ void MX_GPIO_Init(void)
|
|||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
21
Src/main.c
21
Src/main.c
|
@ -17,18 +17,12 @@
|
|||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "crc.h"
|
||||
#include "dma.h"
|
||||
#include "fatfs.h"
|
||||
#include "sdio.h"
|
||||
#include "spi.h"
|
||||
#include "usart.h"
|
||||
#include "usb_otg.h"
|
||||
#include "gpio.h"
|
||||
#include "fsmc.h"
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
@ -74,10 +68,10 @@ void SystemClock_Config(void);
|
|||
*/
|
||||
int main(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
/* MCU Configuration--------------------------------------------------------*/
|
||||
|
||||
|
@ -128,11 +122,13 @@ void SystemClock_Config(void)
|
|||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/** Configure the main internal regulator output voltage
|
||||
/** Configure the main internal regulator output voltage
|
||||
*/
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
|
||||
/** Initializes the CPU, AHB and APB busses clocks
|
||||
|
||||
/** Initializes the RCC Oscillators according to the specified parameters
|
||||
* in the RCC_OscInitTypeDef structure.
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
|
@ -146,7 +142,8 @@ void SystemClock_Config(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/** Initializes the CPU, AHB and APB busses clocks
|
||||
|
||||
/** Initializes the CPU, AHB and APB buses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
|
@ -186,12 +183,10 @@ void Error_Handler(void)
|
|||
* @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,
|
||||
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
/* USER CODE END 6 */
|
||||
}
|
||||
#endif /* USE_FULL_ASSERT */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
259
Src/sd_diskio.c
259
Src/sd_diskio.c
|
@ -1,259 +0,0 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file sd_diskio.c
|
||||
* @brief SD Disk I/O driver
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Note: code generation based on sd_diskio_template.c v2.1.1 as "Use dma template" is disabled. */
|
||||
|
||||
/* USER CODE BEGIN firstSection */
|
||||
/* can be used to modify / undefine following code or add new definitions */
|
||||
/* USER CODE END firstSection*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
#include "ff_gen_drv.h"
|
||||
#include "sd_diskio.h"
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* use the default SD timout as defined in the platform BSP driver*/
|
||||
#if defined(SDMMC_DATATIMEOUT)
|
||||
#define SD_TIMEOUT SDMMC_DATATIMEOUT
|
||||
#elif defined(SD_DATATIMEOUT)
|
||||
#define SD_TIMEOUT SD_DATATIMEOUT
|
||||
#else
|
||||
#define SD_TIMEOUT 30 * 1000
|
||||
#endif
|
||||
|
||||
#define SD_DEFAULT_BLOCK_SIZE 512
|
||||
|
||||
/*
|
||||
* Depending on the use case, the SD card initialization could be done at the
|
||||
* application level: if it is the case define the flag below to disable
|
||||
* the BSP_SD_Init() call in the SD_Initialize() and add a call to
|
||||
* BSP_SD_Init() elsewhere in the application.
|
||||
*/
|
||||
/* USER CODE BEGIN disableSDInit */
|
||||
/* #define DISABLE_SD_INIT */
|
||||
/* USER CODE END disableSDInit */
|
||||
|
||||
/* Disk status */
|
||||
static volatile DSTATUS Stat = STA_NOINIT;
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
static DSTATUS SD_CheckStatus(BYTE lun);
|
||||
DSTATUS SD_initialize (BYTE);
|
||||
DSTATUS SD_status (BYTE);
|
||||
DRESULT SD_read (BYTE, BYTE*, DWORD, UINT);
|
||||
#if _USE_WRITE == 1
|
||||
DRESULT SD_write (BYTE, const BYTE*, DWORD, UINT);
|
||||
#endif /* _USE_WRITE == 1 */
|
||||
#if _USE_IOCTL == 1
|
||||
DRESULT SD_ioctl (BYTE, BYTE, void*);
|
||||
#endif /* _USE_IOCTL == 1 */
|
||||
|
||||
const Diskio_drvTypeDef SD_Driver =
|
||||
{
|
||||
SD_initialize,
|
||||
SD_status,
|
||||
SD_read,
|
||||
#if _USE_WRITE == 1
|
||||
SD_write,
|
||||
#endif /* _USE_WRITE == 1 */
|
||||
|
||||
#if _USE_IOCTL == 1
|
||||
SD_ioctl,
|
||||
#endif /* _USE_IOCTL == 1 */
|
||||
};
|
||||
|
||||
/* USER CODE BEGIN beforeFunctionSection */
|
||||
/* can be used to modify / undefine following code or add new code */
|
||||
/* USER CODE END beforeFunctionSection */
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
static DSTATUS SD_CheckStatus(BYTE lun)
|
||||
{
|
||||
Stat = STA_NOINIT;
|
||||
|
||||
if(BSP_SD_GetCardState() == MSD_OK)
|
||||
{
|
||||
Stat &= ~STA_NOINIT;
|
||||
}
|
||||
|
||||
return Stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Initializes a Drive
|
||||
* @param lun : not used
|
||||
* @retval DSTATUS: Operation status
|
||||
*/
|
||||
DSTATUS SD_initialize(BYTE lun)
|
||||
{
|
||||
Stat = STA_NOINIT;
|
||||
|
||||
#if !defined(DISABLE_SD_INIT)
|
||||
|
||||
if(BSP_SD_Init() == MSD_OK)
|
||||
{
|
||||
Stat = SD_CheckStatus(lun);
|
||||
}
|
||||
|
||||
#else
|
||||
Stat = SD_CheckStatus(lun);
|
||||
#endif
|
||||
return Stat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets Disk Status
|
||||
* @param lun : not used
|
||||
* @retval DSTATUS: Operation status
|
||||
*/
|
||||
DSTATUS SD_status(BYTE lun)
|
||||
{
|
||||
return SD_CheckStatus(lun);
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN beforeReadSection */
|
||||
/* can be used to modify previous code / undefine following code / add new code */
|
||||
/* USER CODE END beforeReadSection */
|
||||
/**
|
||||
* @brief Reads Sector(s)
|
||||
* @param lun : not used
|
||||
* @param *buff: Data buffer to store read data
|
||||
* @param sector: Sector address (LBA)
|
||||
* @param count: Number of sectors to read (1..128)
|
||||
* @retval DRESULT: Operation result
|
||||
*/
|
||||
|
||||
DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
|
||||
{
|
||||
DRESULT res = RES_ERROR;
|
||||
|
||||
if(BSP_SD_ReadBlocks((uint32_t*)buff,
|
||||
(uint32_t) (sector),
|
||||
count, SD_TIMEOUT) == MSD_OK)
|
||||
{
|
||||
/* wait until the read operation is finished */
|
||||
while(BSP_SD_GetCardState()!= MSD_OK)
|
||||
{
|
||||
}
|
||||
res = RES_OK;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN beforeWriteSection */
|
||||
/* can be used to modify previous code / undefine following code / add new code */
|
||||
/* USER CODE END beforeWriteSection */
|
||||
/**
|
||||
* @brief Writes Sector(s)
|
||||
* @param lun : not used
|
||||
* @param *buff: Data to be written
|
||||
* @param sector: Sector address (LBA)
|
||||
* @param count: Number of sectors to write (1..128)
|
||||
* @retval DRESULT: Operation result
|
||||
*/
|
||||
#if _USE_WRITE == 1
|
||||
|
||||
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
|
||||
{
|
||||
DRESULT res = RES_ERROR;
|
||||
|
||||
if(BSP_SD_WriteBlocks((uint32_t*)buff,
|
||||
(uint32_t)(sector),
|
||||
count, SD_TIMEOUT) == MSD_OK)
|
||||
{
|
||||
/* wait until the Write operation is finished */
|
||||
while(BSP_SD_GetCardState() != MSD_OK)
|
||||
{
|
||||
}
|
||||
res = RES_OK;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif /* _USE_WRITE == 1 */
|
||||
|
||||
/* USER CODE BEGIN beforeIoctlSection */
|
||||
/* can be used to modify previous code / undefine following code / add new code */
|
||||
/* USER CODE END beforeIoctlSection */
|
||||
/**
|
||||
* @brief I/O control operation
|
||||
* @param lun : not used
|
||||
* @param cmd: Control code
|
||||
* @param *buff: Buffer to send/receive control data
|
||||
* @retval DRESULT: Operation result
|
||||
*/
|
||||
#if _USE_IOCTL == 1
|
||||
DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
|
||||
{
|
||||
DRESULT res = RES_ERROR;
|
||||
BSP_SD_CardInfo CardInfo;
|
||||
|
||||
if (Stat & STA_NOINIT) return RES_NOTRDY;
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
/* Make sure that no pending write process */
|
||||
case CTRL_SYNC :
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
/* Get number of sectors on the disk (DWORD) */
|
||||
case GET_SECTOR_COUNT :
|
||||
BSP_SD_GetCardInfo(&CardInfo);
|
||||
*(DWORD*)buff = CardInfo.LogBlockNbr;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
/* Get R/W sector size (WORD) */
|
||||
case GET_SECTOR_SIZE :
|
||||
BSP_SD_GetCardInfo(&CardInfo);
|
||||
*(WORD*)buff = CardInfo.LogBlockSize;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
/* Get erase block size in unit of sector (DWORD) */
|
||||
case GET_BLOCK_SIZE :
|
||||
BSP_SD_GetCardInfo(&CardInfo);
|
||||
*(DWORD*)buff = CardInfo.LogBlockSize / SD_DEFAULT_BLOCK_SIZE;
|
||||
res = RES_OK;
|
||||
break;
|
||||
|
||||
default:
|
||||
res = RES_PARERR;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
#endif /* _USE_IOCTL == 1 */
|
||||
|
||||
/* USER CODE BEGIN afterIoctlSection */
|
||||
/* can be used to modify previous code / undefine following code / add new code */
|
||||
/* USER CODE END afterIoctlSection */
|
||||
|
||||
/* USER CODE BEGIN lastSection */
|
||||
/* can be used to modify / undefine previous code or add new code */
|
||||
/* USER CODE END lastSection */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
60
Src/sdio.c
60
Src/sdio.c
|
@ -1,22 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : SDIO.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the SDIO instances.
|
||||
* @file sdio.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the SDIO instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "sdio.h"
|
||||
|
||||
|
@ -31,13 +31,31 @@ SD_HandleTypeDef hsd;
|
|||
void MX_SDIO_SD_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SDIO_Init 0 */
|
||||
|
||||
/* USER CODE END SDIO_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN SDIO_Init 1 */
|
||||
|
||||
/* USER CODE END SDIO_Init 1 */
|
||||
hsd.Instance = SDIO;
|
||||
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING;
|
||||
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE;
|
||||
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE;
|
||||
hsd.Init.BusWide = SDIO_BUS_WIDE_1B;
|
||||
hsd.Init.BusWide = SDIO_BUS_WIDE_4B;
|
||||
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||
hsd.Init.ClockDiv = 0;
|
||||
if (HAL_SD_Init(&hsd) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
if (HAL_SD_ConfigWideBusOperation(&hsd, SDIO_BUS_WIDE_4B) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN SDIO_Init 2 */
|
||||
|
||||
/* USER CODE END SDIO_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
|
@ -52,18 +70,18 @@ void HAL_SD_MspInit(SD_HandleTypeDef* sdHandle)
|
|||
/* USER CODE END SDIO_MspInit 0 */
|
||||
/* SDIO clock enable */
|
||||
__HAL_RCC_SDIO_CLK_ENABLE();
|
||||
|
||||
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
/**SDIO GPIO Configuration
|
||||
/**SDIO GPIO Configuration
|
||||
PC8 ------> SDIO_D0
|
||||
PC9 ------> SDIO_D1
|
||||
PC10 ------> SDIO_D2
|
||||
PC11 ------> SDIO_D3
|
||||
PC12 ------> SDIO_CK
|
||||
PD2 ------> SDIO_CMD
|
||||
PD2 ------> SDIO_CMD
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
|
@ -94,16 +112,16 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* sdHandle)
|
|||
/* USER CODE END SDIO_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_SDIO_CLK_DISABLE();
|
||||
|
||||
/**SDIO GPIO Configuration
|
||||
|
||||
/**SDIO GPIO Configuration
|
||||
PC8 ------> SDIO_D0
|
||||
PC9 ------> SDIO_D1
|
||||
PC10 ------> SDIO_D2
|
||||
PC11 ------> SDIO_D3
|
||||
PC12 ------> SDIO_CK
|
||||
PD2 ------> SDIO_CMD
|
||||
PD2 ------> SDIO_CMD
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
HAL_GPIO_DeInit(GPIOC, GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
|
||||
|GPIO_PIN_12);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOD, GPIO_PIN_2);
|
||||
|
@ -112,10 +130,8 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* sdHandle)
|
|||
|
||||
/* USER CODE END SDIO_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
39
Src/spi.c
39
Src/spi.c
|
@ -1,22 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : SPI.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the SPI instances.
|
||||
* @file spi.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the SPI instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "spi.h"
|
||||
|
||||
|
@ -27,18 +27,23 @@
|
|||
/* SPI2 init function */
|
||||
void MX_SPI2_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 0 */
|
||||
|
||||
/* USER CODE END SPI2_Init 0 */
|
||||
|
||||
LL_SPI_InitTypeDef SPI_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_SPI2);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
||||
/**SPI2 GPIO Configuration
|
||||
/**SPI2 GPIO Configuration
|
||||
PB13 ------> SPI2_SCK
|
||||
PB14 ------> SPI2_MISO
|
||||
PB15 ------> SPI2_MOSI
|
||||
PB15 ------> SPI2_MOSI
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_13|LL_GPIO_PIN_14|LL_GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
|
@ -52,6 +57,9 @@ void MX_SPI2_Init(void)
|
|||
NVIC_SetPriority(SPI2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0));
|
||||
NVIC_EnableIRQ(SPI2_IRQn);
|
||||
|
||||
/* USER CODE BEGIN SPI2_Init 1 */
|
||||
|
||||
/* USER CODE END SPI2_Init 1 */
|
||||
SPI_InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
|
||||
SPI_InitStruct.Mode = LL_SPI_MODE_MASTER;
|
||||
SPI_InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
|
||||
|
@ -64,11 +72,12 @@ void MX_SPI2_Init(void)
|
|||
SPI_InitStruct.CRCPoly = 10;
|
||||
LL_SPI_Init(SPI2, &SPI_InitStruct);
|
||||
LL_SPI_SetStandard(SPI2, LL_SPI_PROTOCOL_MOTOROLA);
|
||||
/* USER CODE BEGIN SPI2_Init 2 */
|
||||
|
||||
/* USER CODE END SPI2_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
*/
|
||||
void HAL_MspInit(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN MspInit 0 */
|
||||
|
||||
/* USER CODE END MspInit 0 */
|
||||
|
@ -80,5 +81,3 @@ void HAL_MspInit(void)
|
|||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
|
@ -92,7 +92,7 @@ extern "C" {
|
|||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
|
@ -239,7 +239,6 @@ void DMA1_Stream1_IRQHandler(void)
|
|||
HandleUsartRxDmaIrq(&g_uartStatuses[USART3_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA1_Stream1_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream1_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream1_IRQn 1 */
|
||||
|
@ -253,7 +252,6 @@ void DMA1_Stream2_IRQHandler(void)
|
|||
/* USER CODE BEGIN DMA1_Stream2_IRQn 0 */
|
||||
// console rx
|
||||
/* USER CODE END DMA1_Stream2_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream2_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream2_IRQn 1 */
|
||||
|
@ -271,7 +269,6 @@ void DMA1_Stream3_IRQHandler(void)
|
|||
HandleUsartTxDmaIrq(&g_uartStatuses[USART3_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA1_Stream3_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream3_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream3_IRQn 1 */
|
||||
|
@ -289,7 +286,6 @@ void DMA1_Stream4_IRQHandler(void)
|
|||
HandleConsoleTxDmaIrq(&g_ConsoleTxDmaInfo, UART4);
|
||||
#endif
|
||||
/* USER CODE END DMA1_Stream4_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream4_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream4_IRQn 1 */
|
||||
|
@ -307,7 +303,6 @@ void DMA1_Stream5_IRQHandler(void)
|
|||
HandleUsartRxDmaIrq(&g_uartStatuses[USART2_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA1_Stream5_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream5_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream5_IRQn 1 */
|
||||
|
@ -325,7 +320,6 @@ void DMA1_Stream6_IRQHandler(void)
|
|||
HandleUsartTxDmaIrq(&g_uartStatuses[USART2_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA1_Stream6_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA1_Stream6_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA1_Stream6_IRQn 1 */
|
||||
|
@ -424,7 +418,6 @@ void DMA2_Stream1_IRQHandler(void)
|
|||
HandleUsartRxDmaIrq(&g_uartStatuses[USART6_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream1_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream1_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream1_IRQn 1 */
|
||||
|
@ -442,7 +435,6 @@ void DMA2_Stream2_IRQHandler(void)
|
|||
HandleUsartRxDmaIrq(&g_uartStatuses[USART1_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream2_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream2_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream2_IRQn 1 */
|
||||
|
@ -460,7 +452,6 @@ void DMA2_Stream3_IRQHandler(void)
|
|||
Mcd_HandleDmaIrq();
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream3_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream3_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream3_IRQn 1 */
|
||||
|
@ -478,7 +469,6 @@ void DMA2_Stream4_IRQHandler(void)
|
|||
HandleCrcDmaIrq(&g_crcStatus);
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream4_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream4_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream4_IRQn 1 */
|
||||
|
@ -496,7 +486,6 @@ void DMA2_Stream6_IRQHandler(void)
|
|||
HandleUsartTxDmaIrq(&g_uartStatuses[USART6_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream6_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream6_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream6_IRQn 1 */
|
||||
|
@ -514,7 +503,6 @@ void DMA2_Stream7_IRQHandler(void)
|
|||
HandleUsartTxDmaIrq(&g_uartStatuses[USART1_OFFSET]);
|
||||
#endif
|
||||
/* USER CODE END DMA2_Stream7_IRQn 0 */
|
||||
|
||||
/* USER CODE BEGIN DMA2_Stream7_IRQn 1 */
|
||||
|
||||
/* USER CODE END DMA2_Stream7_IRQn 1 */
|
||||
|
@ -542,4 +530,3 @@ void USART6_IRQHandler(void)
|
|||
}
|
||||
#endif // __cplusplus
|
||||
/* USER CODE END 1 */
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
37
Src/sys.c
37
Src/sys.c
|
@ -1,37 +0,0 @@
|
|||
/**
|
||||
******************************************************************************
|
||||
* File Name : SYS.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the SYS instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "sys.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/* SYS init function */
|
||||
void MX_SYS_Init(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
127
Src/usart.c
127
Src/usart.c
|
@ -1,22 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : USART.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the USART instances.
|
||||
* @file usart.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the USART instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "usart.h"
|
||||
|
||||
|
@ -27,28 +27,33 @@
|
|||
/* UART4 init function */
|
||||
void MX_UART4_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN UART4_Init 0 */
|
||||
|
||||
/* USER CODE END UART4_Init 0 */
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_UART4);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
|
||||
/**UART4 GPIO Configuration
|
||||
/**UART4 GPIO Configuration
|
||||
PA0-WKUP ------> UART4_TX
|
||||
PA1 ------> UART4_RX
|
||||
PA1 ------> UART4_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_0|LL_GPIO_PIN_1;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_8;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* UART4 DMA Init */
|
||||
|
||||
|
||||
/* UART4_RX Init */
|
||||
LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_2, LL_DMA_CHANNEL_4);
|
||||
|
||||
|
@ -91,6 +96,9 @@ void MX_UART4_Init(void)
|
|||
NVIC_SetPriority(UART4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),1, 0));
|
||||
NVIC_EnableIRQ(UART4_IRQn);
|
||||
|
||||
/* USER CODE BEGIN UART4_Init 1 */
|
||||
|
||||
/* USER CODE END UART4_Init 1 */
|
||||
USART_InitStruct.BaudRate = 115200;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
|
@ -101,34 +109,42 @@ void MX_UART4_Init(void)
|
|||
LL_USART_Init(UART4, &USART_InitStruct);
|
||||
LL_USART_ConfigAsyncMode(UART4);
|
||||
LL_USART_Enable(UART4);
|
||||
/* USER CODE BEGIN UART4_Init 2 */
|
||||
|
||||
/* USER CODE END UART4_Init 2 */
|
||||
|
||||
}
|
||||
/* USART1 init function */
|
||||
|
||||
void MX_USART1_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART1_Init 0 */
|
||||
|
||||
/* USER CODE END USART1_Init 0 */
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
|
||||
/**USART1 GPIO Configuration
|
||||
/**USART1 GPIO Configuration
|
||||
PA9 ------> USART1_TX
|
||||
PA10 ------> USART1_RX
|
||||
PA10 ------> USART1_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_9|LL_GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USART1 DMA Init */
|
||||
|
||||
|
||||
/* USART1_RX Init */
|
||||
LL_DMA_SetChannelSelection(DMA2, LL_DMA_STREAM_2, LL_DMA_CHANNEL_4);
|
||||
|
||||
|
@ -171,6 +187,9 @@ void MX_USART1_UART_Init(void)
|
|||
NVIC_SetPriority(USART1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),1, 0));
|
||||
NVIC_EnableIRQ(USART1_IRQn);
|
||||
|
||||
/* USER CODE BEGIN USART1_Init 1 */
|
||||
|
||||
/* USER CODE END USART1_Init 1 */
|
||||
USART_InitStruct.BaudRate = 5250000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
|
@ -181,34 +200,42 @@ void MX_USART1_UART_Init(void)
|
|||
LL_USART_Init(USART1, &USART_InitStruct);
|
||||
LL_USART_ConfigAsyncMode(USART1);
|
||||
LL_USART_Enable(USART1);
|
||||
/* USER CODE BEGIN USART1_Init 2 */
|
||||
|
||||
/* USER CODE END USART1_Init 2 */
|
||||
|
||||
}
|
||||
/* USART2 init function */
|
||||
|
||||
void MX_USART2_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART2_Init 0 */
|
||||
|
||||
/* USER CODE END USART2_Init 0 */
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA);
|
||||
/**USART2 GPIO Configuration
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_2|LL_GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/* USART2 DMA Init */
|
||||
|
||||
|
||||
/* USART2_RX Init */
|
||||
LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_5, LL_DMA_CHANNEL_4);
|
||||
|
||||
|
@ -251,6 +278,9 @@ void MX_USART2_UART_Init(void)
|
|||
NVIC_SetPriority(USART2_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),1, 0));
|
||||
NVIC_EnableIRQ(USART2_IRQn);
|
||||
|
||||
/* USER CODE BEGIN USART2_Init 1 */
|
||||
|
||||
/* USER CODE END USART2_Init 1 */
|
||||
USART_InitStruct.BaudRate = 5250000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
|
@ -261,34 +291,42 @@ void MX_USART2_UART_Init(void)
|
|||
LL_USART_Init(USART2, &USART_InitStruct);
|
||||
LL_USART_ConfigAsyncMode(USART2);
|
||||
LL_USART_Enable(USART2);
|
||||
/* USER CODE BEGIN USART2_Init 2 */
|
||||
|
||||
/* USER CODE END USART2_Init 2 */
|
||||
|
||||
}
|
||||
/* USART3 init function */
|
||||
|
||||
void MX_USART3_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART3_Init 0 */
|
||||
|
||||
/* USER CODE END USART3_Init 0 */
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOB);
|
||||
/**USART3 GPIO Configuration
|
||||
/**USART3 GPIO Configuration
|
||||
PB10 ------> USART3_TX
|
||||
PB11 ------> USART3_RX
|
||||
PB11 ------> USART3_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_10|LL_GPIO_PIN_11;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_7;
|
||||
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
||||
|
||||
/* USART3 DMA Init */
|
||||
|
||||
|
||||
/* USART3_RX Init */
|
||||
LL_DMA_SetChannelSelection(DMA1, LL_DMA_STREAM_1, LL_DMA_CHANNEL_4);
|
||||
|
||||
|
@ -331,6 +369,9 @@ void MX_USART3_UART_Init(void)
|
|||
NVIC_SetPriority(USART3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),1, 0));
|
||||
NVIC_EnableIRQ(USART3_IRQn);
|
||||
|
||||
/* USER CODE BEGIN USART3_Init 1 */
|
||||
|
||||
/* USER CODE END USART3_Init 1 */
|
||||
USART_InitStruct.BaudRate = 5250000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
|
@ -341,34 +382,42 @@ void MX_USART3_UART_Init(void)
|
|||
LL_USART_Init(USART3, &USART_InitStruct);
|
||||
LL_USART_ConfigAsyncMode(USART3);
|
||||
LL_USART_Enable(USART3);
|
||||
/* USER CODE BEGIN USART3_Init 2 */
|
||||
|
||||
/* USER CODE END USART3_Init 2 */
|
||||
|
||||
}
|
||||
/* USART6 init function */
|
||||
|
||||
void MX_USART6_UART_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USART6_Init 0 */
|
||||
|
||||
/* USER CODE END USART6_Init 0 */
|
||||
|
||||
LL_USART_InitTypeDef USART_InitStruct = {0};
|
||||
|
||||
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||
|
||||
/* Peripheral clock enable */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART6);
|
||||
|
||||
|
||||
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOC);
|
||||
/**USART6 GPIO Configuration
|
||||
/**USART6 GPIO Configuration
|
||||
PC6 ------> USART6_TX
|
||||
PC7 ------> USART6_RX
|
||||
PC7 ------> USART6_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = LL_GPIO_PIN_6|LL_GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
|
||||
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_UP;
|
||||
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
|
||||
GPIO_InitStruct.Alternate = LL_GPIO_AF_8;
|
||||
LL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/* USART6 DMA Init */
|
||||
|
||||
|
||||
/* USART6_RX Init */
|
||||
LL_DMA_SetChannelSelection(DMA2, LL_DMA_STREAM_1, LL_DMA_CHANNEL_5);
|
||||
|
||||
|
@ -411,6 +460,9 @@ void MX_USART6_UART_Init(void)
|
|||
NVIC_SetPriority(USART6_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),1, 0));
|
||||
NVIC_EnableIRQ(USART6_IRQn);
|
||||
|
||||
/* USER CODE BEGIN USART6_Init 1 */
|
||||
|
||||
/* USER CODE END USART6_Init 1 */
|
||||
USART_InitStruct.BaudRate = 5250000;
|
||||
USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B;
|
||||
USART_InitStruct.StopBits = LL_USART_STOPBITS_1;
|
||||
|
@ -421,11 +473,12 @@ void MX_USART6_UART_Init(void)
|
|||
LL_USART_Init(USART6, &USART_InitStruct);
|
||||
LL_USART_ConfigAsyncMode(USART6);
|
||||
LL_USART_Enable(USART6);
|
||||
/* USER CODE BEGIN USART6_Init 2 */
|
||||
|
||||
/* USER CODE END USART6_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* File Name : USB_OTG.c
|
||||
* Description : This file provides code for the configuration
|
||||
* of the USB_OTG instances.
|
||||
* @file usb_otg.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the USB_OTG instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
* Copyright (c) 2025 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
* SLA0044, the "License"; You may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at:
|
||||
* www.st.com/SLA0044
|
||||
* 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 "usb_otg.h"
|
||||
|
||||
|
@ -31,6 +31,13 @@ PCD_HandleTypeDef hpcd_USB_OTG_FS;
|
|||
void MX_USB_OTG_FS_PCD_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 1 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 1 */
|
||||
hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
|
||||
hpcd_USB_OTG_FS.Init.dev_endpoints = 4;
|
||||
hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
|
||||
|
@ -45,6 +52,9 @@ void MX_USB_OTG_FS_PCD_Init(void)
|
|||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN USB_OTG_FS_Init 2 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
|
@ -57,11 +67,11 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* pcdHandle)
|
|||
/* USER CODE BEGIN USB_OTG_FS_MspInit 0 */
|
||||
|
||||
/* USER CODE END USB_OTG_FS_MspInit 0 */
|
||||
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
PA11 ------> USB_OTG_FS_DM
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
|
@ -88,10 +98,10 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
|
|||
/* USER CODE END USB_OTG_FS_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USB_OTG_FS_CLK_DISABLE();
|
||||
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
|
||||
/**USB_OTG_FS GPIO Configuration
|
||||
PA11 ------> USB_OTG_FS_DM
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
PA12 ------> USB_OTG_FS_DP
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_11|GPIO_PIN_12);
|
||||
|
||||
|
@ -99,10 +109,8 @@ void HAL_PCD_MspDeInit(PCD_HandleTypeDef* pcdHandle)
|
|||
|
||||
/* USER CODE END USB_OTG_FS_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue