cancel
Showing results for 
Search instead for 
Did you mean: 

user_diskio.c and diskio.c ??

antonius
Senior
Posted on January 22, 2016 at 10:37

Guys,

I tried to use SPI2 and FATFs on STM32CubeMX, but I found two files with the same function, which one should I modify to make it work ?

thanks
4 REPLIES 4
Nesrine M_O
Lead II
Posted on January 25, 2016 at 10:14

Hi h.rick,

I'd highly recommend you to have a look to the 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/user_manual/DM00104712.pdf?s_searchtype=keyword

 User manual

In theâ€� B.3.4 FatFsâ€� paragraph it said “the user shall select the FatFs user-defined mode and update the user_diskio.c driver file generated 

to implement the interface between the middleware and the selected peripheral.�

-Syrine-

antonius
Senior
Posted on January 25, 2016 at 13:08

so I must move all of these to user_diskio.c ?

Thanks for your suggestion

#define CS_LOW() { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10 , 0 ); } /* CS=low */
#define CS_HIGH() { HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10 , 1 ); } /* CS=high */
#define SOCKINS {HAL_GPIO_ReadPin(GPIOB, 11);} /* Card detected. yes:true, no:false, default:true */
#define SOCKWP {HAL_GPIO_ReadPin(GPIOB, 12);} /* Write protected. yes:true, no:false, default:false */
#define FCLK_SLOW() MX_SPI2_Init_Low();
#define FCLK_FAST() MX_SPI2_Init();
/* Definitions for MMC/SDC command */
#define CMD0 (0) /* GO_IDLE_STATE */
#define CMD1 (1) /* SEND_OP_COND (MMC) */
#define ACMD41 (0x80+41) /* SEND_OP_COND (SDC) */
#define CMD8 (8) /* SEND_IF_COND */
#define CMD9 (9) /* SEND_CSD */
#define CMD10 (10) /* SEND_CID */
#define CMD12 (12) /* STOP_TRANSMISSION */
#define ACMD13 (0x80+13) /* SD_STATUS (SDC) */
#define CMD16 (16) /* SET_BLOCKLEN */
#define CMD17 (17) /* READ_SINGLE_BLOCK */
#define CMD18 (18) /* READ_MULTIPLE_BLOCK */
#define CMD23 (23) /* SET_BLOCK_COUNT (MMC) */
#define ACMD23 (0x80+23) /* SET_WR_BLK_ERASE_COUNT (SDC) */
#define CMD24 (24) /* WRITE_BLOCK */
#define CMD25 (25) /* WRITE_MULTIPLE_BLOCK */
#define CMD32 (32) /* ERASE_ER_BLK_START */
#define CMD33 (33) /* ERASE_ER_BLK_END */
#define CMD38 (38) /* ERASE */
#define CMD55 (55) /* APP_CMD */
#define CMD58 (58) /* READ_OCR */
#define CTRL_POWER 5 /* Get/Set power status */
/* MMC card type flags (MMC_GET_TYPE) */
#define CT_MMC 0x01 /* MMC ver 3 */
#define CT_SD1 0x02 /* SD ver 1 */
#define CT_SD2 0x04 /* SD ver 2 */
#define CT_SDC (CT_SD1|CT_SD2) /* SD */
#define CT_BLOCK 0x08 /* Block addressing */

antonius
Senior
Posted on January 25, 2016 at 16:07

How can I connect this function to my user_diskio.c ? Which function should I call from there ? user_disk_initialize() ? thanks

void MX_FATFS_Init(void) 
{
/*## FatFS: Link the USER driver ###########################*/
retUSER = FATFS_LinkDriver(&USER_Driver, USER_Path);
/* USER CODE BEGIN Init */
/* additional user code for init */ 
/* USER CODE END Init */
}

antonius
Senior
Posted on February 01, 2016 at 14:43

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6j2&d=%2Fa%2F0X0000000bu1%2FDCzsZzS9zQHDHTVgCBxuXMe2Eur.znd8AqTWOqxaPSo&asPdf=false