Skip to main content
Alec Davis
Associate III
January 20, 2021
Question

fatfs_platform.c needs a section /* USER CODE BEGIN Includes */ and /* USER CODE END Includes */ so we can call our user defined functions in BSP_PlatformIsDetected(), otherwise when the code is regenerated the manually inserted includes are lost.

  • January 20, 2021
  • 3 replies
  • 1213 views

Editing C:\ST\STM32CubeIDE_1.0.2\STM32CubeIDE\plugins\com.st.stm32cube.common.mx_6.1.1.202012091304\db\templates\fatfs_platform_c.ftl

#include "fatfs_platform.h"
/* USER CODE BEGIN Includes */
 
/* USER CODE END Includes */
 
uint8_t	BSP_PlatformIsDetected(void) {

Above "USER CODE BEGIN Includes and END" section fixes it ... until new firmware package is available.

This topic has been closed for replies.

3 replies

Houssem CHAABANI
Visitor II
January 20, 2021

Hi @Community member​ ,

could you share your .ioc file ?

Alec Davis
Associate III
January 20, 2021

Can't share .ioc as it's a production version, but prepared to share the customized BSP_PlatformIsDetected() function.

The issue is we have 2 generations of board, using 1 common code set, and 1 .ioc file and 1 bin file

The difference between the boards is the SD Card detect pin moved.

The 'MK2' SD card detect pin is defined as SD_DETECT in the .ioc file and the MK1_SD_DETECT defined in an include file.

uint8_t	BSP_PlatformIsDetected(void) {
 uint8_t status = SD_PRESENT;
 /* Check SD card detect pin */
 if(HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) != GPIO_PIN_RESET)
 {
 status = SD_NOT_PRESENT;
 }
 /* USER CODE BEGIN 1 */
 
 /* user code can be inserted here */
	
	if ( board.has_ade7953 == 0 ) {
	
	 if(HAL_GPIO_ReadPin(MK1_SD_DETECT_GPIO_PORT, MK1_SD_DETECT_PIN) != GPIO_PIN_RESET)
 	{
	 status = SD_NOT_PRESENT;
 	} else {
	 status = SD_PRESENT;
		}
 
		printf( "MK1_SD_DETECT: ");
 
	} else {
	
		printf( "MK2_SD_DETECT: ");
 
	}
	
	if ( status == SD_PRESENT ) {
		printf( "Present\r\n");
	} else {
		printf( "Not present\r\n");
	}
	
 /* USER CODE END 1 */
 return status;
}

Alec Davis 2021
Associate III
January 21, 2021

@Houssem CHAABANIHopefully my last reply is enough to explain why we need the USER CODE BEGIN/END includes.

Note: Nick change, My old email provider closed down, so having to us a new login.

I wish this forum allowed changing email address in "My Profile".