2016-01-22 01:37 AM
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 ? thanks2016-01-25 01:14 AM
Hi h.rick,
I'd highly recommend you to have a look to the User manualIn 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-2016-01-25 04:08 AM
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 */
2016-01-25 07:07 AM
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 */
}
2016-02-01 05:43 AM