cancel
Showing results for 
Search instead for 
Did you mean: 

Question for STM32 USB Full Speed Device Library V2.2.1

antonius
Senior
Posted on September 06, 2013 at 02:11

Hello guys,

I have a question for :

Question for STM32 USB Full Speed Device Library      V2.2.1

How can I use SD card on Mass_storage demos ?

is it connected via SPI or SDIO ? or I can choose ?

and how can I connect my USB to it ? where can I find the configuration for it ?

I have PA11 and PA12 connected to USB port.

Thanks a lot
23 REPLIES 23
antonius
Senior
Posted on September 13, 2013 at 17:32

Is it possible for me using SPI interface ?

I saw :

/*******************************************************************************

* Function Name  : SPI_Config

* Description    : Initializes the SPI1 and CS pins.

* Input          : None

* Output         : None

* Return         : None

*******************************************************************************/

void SPI_Config(void)

{

  GPIO_InitTypeDef  GPIO_InitStructure;

  SPI_InitTypeDef   SPI_InitStructure;

  /* GPIOA and GPIOC Periph clock enable */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);

  /* SPI1 Periph clock enable */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

  /* Configure SPI1 pins: SCK, MISO and MOSI */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Configure PC12 pin: CS pin */

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

  GPIO_Init(GPIOC, &GPIO_InitStructure);

  /* SPI1 Config */

  SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

  SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

  SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

  SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

  SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

  SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

  SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;

  SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

  SPI_InitStructure.SPI_CRCPolynomial = 7;

  SPI_Init(SPI1, &SPI_InitStructure);

  /* SPI1 enable */

  SPI_Cmd(SPI1, ENABLE);

}

on UM0424\USBLib\Demos\Mass_Storage\Project\RVMDK\.....\msd.c

Posted on September 13, 2013 at 17:43

Is it possible for me using SPI interface ?

There are opportunities to do it many ways, you'll need to figure out what's appropriate for you, or try some existing boards/solutions to see it work. I would recommend implementing and testing the card reading code independently of USB, and then reintegrate the two.

Tackle the problem in small bites so you don't choke.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
antonius
Senior
Posted on September 26, 2013 at 15:48

so try using SPI then connect via UART as my interface ?

Posted on September 26, 2013 at 17:17

Or just write a test app to exercise the SDCard via SPI, you could output diagnostic information via USART, SWV or LEDs as required.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..