1

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

静态无效 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);
4

0 回答 0