使用Hal驱动程序在STM32f103上传输SD卡通信序列

时间:2016-04-20 07:43:33

标签: sd-card spi hal

我正在编写SD卡低级驱动程序,在带有STM32f103rb处理器的Olimex MOD-MP3-X板上实现Chan的FATFS系统。我对这个话题很陌生,我不是母语为英语的人,但我希望我能指出我的问题。 首先,我想编写一个函数来通过SPI发送cmd命令。 所以我得到了这个Prototype用于函数用法:

static void sd_cmd(uint8_t cmd, uint32_t arg);

//I already found the HAL-command to transmit the data:

HAL_SPI_Transmit_IT(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size);

//But I don't know exactly how put the Argument and the cmd into the data buffer.

//I already tried by creating an array, but this didn't work:

uint8_t buffer[5];
uint8_t buffer[0]= 0x40 | cmd;
uint8_t buffer[1]= arg >> 24;
uint8_t buffer[2]= arg >> 16;
uint8_t buffer[3]= arg >> 8;
uint8_t buffer[4]= arg;

...

HAL_SPI_Transmit_IT(&hspi2, &buffer, 5);

0 个答案:

没有答案