Updated HAL Firmware Package
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
@@ -33,7 +33,7 @@
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "bsp_driver_sd.h"
|
||||
|
||||
/* Extern variables ---------------------------------------------------------*/
|
||||
/* Extern variables ---------------------------------------------------------*/
|
||||
|
||||
extern SD_HandleTypeDef hsd;
|
||||
|
||||
@@ -110,7 +110,7 @@ __weak uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t Nu
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeWriteBlocksSection */
|
||||
@@ -128,12 +128,12 @@ __weak uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t
|
||||
{
|
||||
uint8_t sd_state = MSD_OK;
|
||||
|
||||
if (HAL_SD_WriteBlocks(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
if (HAL_SD_WriteBlocks(&hsd, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
|
||||
return sd_state;
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeReadDMABlocksSection */
|
||||
@@ -143,20 +143,20 @@ __weak uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t
|
||||
* @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
|
||||
* @param NumOfBlocks: Number of SD blocks to read
|
||||
* @retval SD status
|
||||
*/
|
||||
__weak 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;
|
||||
|
||||
return sd_state;
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN BeforeWriteDMABlocksSection */
|
||||
@@ -166,27 +166,27 @@ __weak uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_
|
||||
* @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
|
||||
* @param NumOfBlocks: Number of SD blocks to write
|
||||
* @retval SD status
|
||||
*/
|
||||
__weak 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;
|
||||
|
||||
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.
|
||||
* @brief Erases the specified memory area of the given SD card.
|
||||
* @param StartAddr: Start byte address
|
||||
* @param EndAddr: End byte address
|
||||
* @retval SD status
|
||||
@@ -195,7 +195,7 @@ __weak 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)
|
||||
if (HAL_SD_Erase(&hsd, StartAddr, EndAddr) != HAL_OK)
|
||||
{
|
||||
sd_state = MSD_ERROR;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ __weak uint8_t BSP_SD_GetCardState(void)
|
||||
/**
|
||||
* @brief Get SD information about specific SD card.
|
||||
* @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
|
||||
* @retval None
|
||||
* @retval None
|
||||
*/
|
||||
__weak void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
|
||||
{
|
||||
@@ -302,7 +302,7 @@ __weak uint8_t BSP_SD_IsDetected(void)
|
||||
{
|
||||
__IO uint8_t status = SD_PRESENT;
|
||||
|
||||
if (BSP_PlatformIsDetected() == 0x0)
|
||||
if (BSP_PlatformIsDetected() == 0x0)
|
||||
{
|
||||
status = SD_NOT_PRESENT;
|
||||
}
|
||||
|
||||
10
Src/fatfs.c
10
Src/fatfs.c
@@ -5,7 +5,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
@@ -25,9 +25,9 @@ FIL SDFile; /* File object for SD */
|
||||
|
||||
/* USER CODE BEGIN Variables */
|
||||
|
||||
/* USER CODE END Variables */
|
||||
/* USER CODE END Variables */
|
||||
|
||||
void MX_FATFS_Init(void)
|
||||
void MX_FATFS_Init(void)
|
||||
{
|
||||
/*## FatFS: Link the SD driver ###########################*/
|
||||
retSD = FATFS_LinkDriver(&SD_Driver, SDPath);
|
||||
@@ -38,7 +38,7 @@ void MX_FATFS_Init(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets Time from RTC
|
||||
* @brief Gets Time from RTC
|
||||
* @param None
|
||||
* @retval Time in DWORD
|
||||
*/
|
||||
@@ -46,7 +46,7 @@ DWORD get_fattime(void)
|
||||
{
|
||||
/* USER CODE BEGIN get_fattime */
|
||||
return 0;
|
||||
/* USER CODE END get_fattime */
|
||||
/* USER CODE END get_fattime */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN Application */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
|
||||
* <h2><center>© Copyright (c) 2021 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under Ultimate Liberty license
|
||||
@@ -26,6 +26,6 @@ uint8_t BSP_PlatformIsDetected(void) {
|
||||
}
|
||||
/* USER CODE BEGIN 1 */
|
||||
/* user code can be inserted here */
|
||||
/* USER CODE END 1 */
|
||||
/* USER CODE END 1 */
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
34
Src/main.c
34
Src/main.c
@@ -17,7 +17,6 @@
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
#include "fatfs.h"
|
||||
@@ -278,12 +277,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;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
@@ -296,7 +296,7 @@ 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;
|
||||
@@ -439,7 +439,7 @@ static void MX_GPIO_Init(void)
|
||||
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4|GPIO_PIN_5, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
@@ -477,17 +477,17 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PA0 PA1 PA8 PA14
|
||||
/*Configure GPIO pins : PA0 PA1 PA8 PA14
|
||||
PA15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_14
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_8|GPIO_PIN_14
|
||||
|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PA4 PA5 PA6 PA9
|
||||
/*Configure GPIO pins : PA4 PA5 PA6 PA9
|
||||
PA10 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_9
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_9
|
||||
|GPIO_PIN_10;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
@@ -500,9 +500,9 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB11 PB12 PB13 PB14
|
||||
/*Configure GPIO pins : PB11 PB12 PB13 PB14
|
||||
PB15 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
||||
|GPIO_PIN_15;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
@@ -528,17 +528,17 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PD0 PD1 PD3 PD4
|
||||
/*Configure GPIO pins : PD0 PD1 PD3 PD4
|
||||
PD5 PD6 PD7 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_3|GPIO_PIN_4
|
||||
|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
||||
|
||||
/*Configure GPIO pins : PB3 PB4 PB5 PB8
|
||||
/*Configure GPIO pins : PB3 PB4 PB5 PB8
|
||||
PB9 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_8
|
||||
|GPIO_PIN_9;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
@@ -570,7 +570,7 @@ 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) */
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Note: code generation based on sd_diskio_template_bspv1.c v2.1.4
|
||||
/* Note: code generation based on sd_diskio_template_bspv1.c v2.1.4
|
||||
as "Use dma template" is disabled. */
|
||||
|
||||
/* USER CODE BEGIN firstSection */
|
||||
@@ -45,7 +45,7 @@
|
||||
/*
|
||||
* 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
|
||||
* 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 */
|
||||
@@ -107,7 +107,7 @@ static DSTATUS SD_CheckStatus(BYTE lun)
|
||||
*/
|
||||
DSTATUS SD_initialize(BYTE lun)
|
||||
{
|
||||
Stat = STA_NOINIT;
|
||||
Stat = STA_NOINIT;
|
||||
|
||||
#if !defined(DISABLE_SD_INIT)
|
||||
|
||||
@@ -144,7 +144,7 @@ DSTATUS SD_status(BYTE lun)
|
||||
* @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;
|
||||
@@ -175,7 +175,7 @@ DRESULT SD_read(BYTE lun, BYTE *buff, DWORD sector, UINT count)
|
||||
* @retval DRESULT: Operation result
|
||||
*/
|
||||
#if _USE_WRITE == 1
|
||||
|
||||
|
||||
DRESULT SD_write(BYTE lun, const BYTE *buff, DWORD sector, UINT count)
|
||||
{
|
||||
DRESULT res = RES_ERROR;
|
||||
@@ -253,7 +253,7 @@ DRESULT SD_ioctl(BYTE lun, BYTE cmd, void *buff)
|
||||
/* can be used to modify previous code / undefine following code / add new code */
|
||||
/* USER CODE END afterIoctlSection */
|
||||
|
||||
/* USER CODE BEGIN lastSection */
|
||||
/* USER CODE BEGIN lastSection */
|
||||
/* can be used to modify / undefine previous code or add new code */
|
||||
/* USER CODE END lastSection */
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
||||
/* USER CODE BEGIN I2C1_MspInit 0 */
|
||||
|
||||
/* USER CODE END I2C1_MspInit 0 */
|
||||
|
||||
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
/**I2C1 GPIO Configuration
|
||||
/**I2C1 GPIO Configuration
|
||||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
@@ -128,12 +128,14 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
||||
/* USER CODE END I2C1_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_I2C1_CLK_DISABLE();
|
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
|
||||
/**I2C1 GPIO Configuration
|
||||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6);
|
||||
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_7);
|
||||
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||
|
||||
@@ -158,18 +160,18 @@ void HAL_SD_MspInit(SD_HandleTypeDef* hsd)
|
||||
/* USER CODE END SDIO_MspInit 0 */
|
||||
/* Peripheral 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;
|
||||
@@ -206,16 +208,16 @@ void HAL_SD_MspDeInit(SD_HandleTypeDef* hsd)
|
||||
/* 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);
|
||||
@@ -243,11 +245,11 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
/* USER CODE END USART2_MspInit 0 */
|
||||
/* Peripheral clock enable */
|
||||
__HAL_RCC_USART2_CLK_ENABLE();
|
||||
|
||||
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
/**USART2 GPIO Configuration
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
@@ -281,10 +283,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
||||
/* USER CODE END USART2_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_USART2_CLK_DISABLE();
|
||||
|
||||
/**USART2 GPIO Configuration
|
||||
|
||||
/**USART2 GPIO Configuration
|
||||
PA2 ------> USART2_TX
|
||||
PA3 ------> USART2_RX
|
||||
PA3 ------> USART2_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2|GPIO_PIN_3);
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ extern UART_HandleTypeDef huart2;
|
||||
/* 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.
|
||||
|
||||
@@ -67,7 +67,7 @@ void MX_USB_DEVICE_Init(void)
|
||||
/* USER CODE BEGIN USB_DEVICE_Init_PreTreatment */
|
||||
|
||||
/* USER CODE END USB_DEVICE_Init_PreTreatment */
|
||||
|
||||
|
||||
/* Init Device Library, add supported class and start the library. */
|
||||
if (USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS) != USBD_OK)
|
||||
{
|
||||
|
||||
104
Src/usbd_conf.c
104
Src/usbd_conf.c
@@ -73,11 +73,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;
|
||||
@@ -107,10 +107,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);
|
||||
|
||||
@@ -191,7 +191,7 @@ static void PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
|
||||
#else
|
||||
void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
|
||||
#endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
|
||||
{
|
||||
{
|
||||
USBD_SpeedTypeDef speed = USBD_SPEED_FULL;
|
||||
|
||||
if ( hpcd->Init.speed == PCD_SPEED_HIGH)
|
||||
@@ -330,7 +330,7 @@ USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
|
||||
/* Link the driver to the stack. */
|
||||
hpcd_USB_OTG_FS.pData = pdev;
|
||||
pdev->pData = &hpcd_USB_OTG_FS;
|
||||
|
||||
|
||||
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;
|
||||
@@ -381,12 +381,12 @@ USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
|
||||
hal_status = HAL_PCD_DeInit(pdev->pData);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Starts the low level portion of the device driver.
|
||||
* @brief Starts the low level portion of the device driver.
|
||||
* @param pdev: Device handle
|
||||
* @retval USBD status
|
||||
*/
|
||||
@@ -394,11 +394,11 @@ USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_Start(pdev->pData);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
@@ -413,9 +413,9 @@ USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
hal_status = HAL_PCD_Stop(pdev->pData);
|
||||
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uin
|
||||
hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
@@ -449,12 +449,12 @@ USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -467,12 +467,12 @@ USBD_StatusTypeDef USBD_LL_FlushEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -485,12 +485,12 @@ USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -503,12 +503,12 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -520,14 +520,14 @@ USBD_StatusTypeDef USBD_LL_ClearStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_add
|
||||
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
|
||||
{
|
||||
PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef*) pdev->pData;
|
||||
|
||||
|
||||
if((ep_addr & 0x80) == 0x80)
|
||||
{
|
||||
return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
|
||||
return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
|
||||
}
|
||||
else
|
||||
{
|
||||
return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
|
||||
return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,12 +541,12 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a
|
||||
{
|
||||
HAL_StatusTypeDef hal_status = HAL_OK;
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
|
||||
hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
|
||||
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -554,7 +554,7 @@ USBD_StatusTypeDef USBD_LL_SetUSBAddress(USBD_HandleTypeDef *pdev, uint8_t dev_a
|
||||
* @param pdev: Device handle
|
||||
* @param ep_addr: Endpoint number
|
||||
* @param pbuf: Pointer to data to be sent
|
||||
* @param size: Data size
|
||||
* @param size: Data size
|
||||
* @retval USBD status
|
||||
*/
|
||||
USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint32_t size)
|
||||
@@ -563,10 +563,10 @@ USBD_StatusTypeDef USBD_LL_Transmit(USBD_HandleTypeDef *pdev, uint8_t ep_addr, u
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -583,10 +583,10 @@ USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_a
|
||||
USBD_StatusTypeDef usb_status = USBD_OK;
|
||||
|
||||
hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
|
||||
usb_status = USBD_Get_USB_Status(hal_status);
|
||||
|
||||
return usb_status;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,19 +97,18 @@
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
|
||||
* @brief Private functions declaration.
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
static void Get_SerialNum(void);
|
||||
static void IntToUnicode(uint32_t value, uint8_t * pbuf, uint8_t len);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
/** @defgroup USBD_DESC_Private_FunctionPrototypes USBD_DESC_Private_FunctionPrototypes
|
||||
* @brief Private functions declaration for FS.
|
||||
@@ -235,7 +234,7 @@ __ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
|
||||
__ALIGN_BEGIN uint8_t USBD_StrDesc[USBD_MAX_STR_DESC_SIZ] __ALIGN_END;
|
||||
|
||||
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
|
||||
#pragma data_alignment=4
|
||||
#pragma data_alignment=4
|
||||
#endif
|
||||
__ALIGN_BEGIN uint8_t USBD_StringSerial[USB_SIZ_STRING_SERIAL] __ALIGN_END = {
|
||||
USB_SIZ_STRING_SERIAL,
|
||||
@@ -383,8 +382,8 @@ uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
|
||||
#endif /* (USBD_LPM_ENABLED == 1) */
|
||||
|
||||
/**
|
||||
* @brief Create the serial number string descriptor
|
||||
* @param None
|
||||
* @brief Create the serial number string descriptor
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
static void Get_SerialNum(void)
|
||||
@@ -405,9 +404,9 @@ static void Get_SerialNum(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert Hex 32Bits value into char
|
||||
* @brief Convert Hex 32Bits value into char
|
||||
* @param value: value to convert
|
||||
* @param pbuf: pointer to the buffer
|
||||
* @param pbuf: pointer to the buffer
|
||||
* @param len: buffer length
|
||||
* @retval None
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user