STSW-STLKT01: Drivers/BSP/SensorTile/SensorTile_sd.c Source File

STSW-STLKT01

STSW-STLKT01
SensorTile_sd.c
Go to the documentation of this file.
1 
39 /* File Info : -----------------------------------------------------------------
40  User NOTES
41 This file implements a high level communication layer for read and write
42 from/to this memory.
43 
44 1. How To use this driver:
45 --------------------------
46  - This driver is used to drive the micro SD external card mounted on SensorTile Cradle
47  evaluation board.
48  - This driver does not need a specific component driver for the micro SD device
49  to be included with.
50 
51 ------------------------------------------------------------------------------*/
52 
53 /* Includes ------------------------------------------------------------------*/
54 #include "SensorTile_sd.h"
55 
69 /* Private typedef -----------------------------------------------------------*/
70 
79 /* Private define ------------------------------------------------------------*/
80 
84 #define SD_DUMMY_BYTE 0xFF
85 #define SD_NO_RESPONSE_EXPECTED 0x80
86 
90 /* Private macro -------------------------------------------------------------*/
91 
100 /* Private variables ---------------------------------------------------------*/
101 
106 enum {
107  TRANSFER_WAIT,
108  TRANSFER_COMPLETE,
109  TRANSFER_ERROR
110 };
111 
112 __IO uint8_t SdStatus = SD_PRESENT;
113 __IO uint8_t SD_CardType = STD_CAPACITY_SD_CARD_V1_1;
114 
115 /* transfer state */
116 __IO uint32_t wTransferState = TRANSFER_WAIT;
117 
118 
123 /* Private function prototypes -----------------------------------------------*/
124 static uint8_t SD_GetCIDRegister(SD_CID* Cid);
125 static uint8_t SD_GetCSDRegister(SD_CSD* Csd);
126 static SD_Info SD_GetDataResponse(void);
127 static uint8_t SD_GoIdleState(void);
128 static uint8_t SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response);
129 static uint8_t SD_SendCmd_wResp(uint8_t Cmd, uint32_t Arg, uint8_t Crc);
130 
138 /* Private functions ---------------------------------------------------------*/
139 
151 uint8_t BSP_SD_Init(void)
152 {
153  /* Configure SPI in Low Speed mode for initialization */
154  SD_IO_Init_LS();
155 
156  if(SD_GoIdleState() == MSD_ERROR)
157  {
158  SdStatus = SD_NOT_PRESENT;
159  return MSD_ERROR;
160  }
161  else
162  {
163  SdStatus = SD_PRESENT;
164 
165  if(SD_CardType != HIGH_CAPACITY_SD_CARD)
166  {
167  /* SD Card type not supported. Please use SDHC Card */
168  return MSD_ERROR;
169  }
170 
171  /* Configure SPI in High Speed mode for normal usage */
172  SD_IO_Init();
173  return MSD_OK;
174  }
175 }
176 
185 uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo)
186 {
187  uint8_t status = MSD_ERROR;
188 
189  SD_GetCSDRegister(&(pCardInfo->Csd));
190  status = SD_GetCIDRegister(&(pCardInfo->Cid));
191  pCardInfo->CardCapacity = (pCardInfo->Csd.DeviceSize + 1) ;
192  pCardInfo->CardCapacity *= (1 << (pCardInfo->Csd.DeviceSizeMul + 2));
193  pCardInfo->CardBlockSize = 1 << (pCardInfo->Csd.RdBlockLen);
194  pCardInfo->CardCapacity *= pCardInfo->CardBlockSize;
195 
196  /* Returns the reponse */
197  return status;
198 }
199 
208 uint8_t BSP_SD_ReadBlocks(uint32_t* p32Data, uint64_t Sector, uint16_t BlockSize, uint32_t NumberOfBlocks)
209 {
210  uint32_t counter = 0, offset = 0;
211  uint8_t rvalue = MSD_ERROR;
212  uint8_t *pData = (uint8_t *)p32Data;
213 
214  /* Send CMD16 (SD_CMD_SET_BLOCKLEN) to set the size of the block and
215  Check if the SD acknowledged the set block length command: R1 response (0x00: no errors) */
216  if (SD_IO_WriteCmd(SD_CMD_SET_BLOCKLEN, BlockSize, 0xFF, SD_RESPONSE_NO_ERROR) != HAL_OK)
217  {
218  return MSD_ERROR;
219  }
220 
221  if(SD_CardType != HIGH_CAPACITY_SD_CARD)
222  {
223  Sector *= 512;
224  }
225 
226  /* Data transfer */
227  while (NumberOfBlocks--)
228  {
229  /* Send dummy byte: 8 Clock pulses of delay */
231 
232  /* Send CMD17 (SD_CMD_READ_SINGLE_BLOCK) to read one block */
233  /* Check if the SD acknowledged the read block command: R1 response (0x00: no errors) */
234  if (SD_IO_WriteCmd(SD_CMD_READ_SINGLE_BLOCK, Sector + offset, 0xFF, SD_RESPONSE_NO_ERROR) != HAL_OK)
235  {
236  return MSD_ERROR;
237  }
238 
239  /* Now look for the data token to signify the start of the data */
241  {
242  /* Read the SD block data : read NumByteToRead data */
243  for (counter = 0; counter < BlockSize; counter++)
244  {
245  /* Read the pointed data */
246  *pData = SD_IO_ReadByte();
247  /* Point to the next location where the byte read will be saved */
248  pData++;
249  }
250 
251  /* Set next write address */
252  if(SD_CardType != HIGH_CAPACITY_SD_CARD)
253  {
254  offset += BlockSize;
255  }
256  else
257  {
258  offset += 1;
259  }
260  /* get CRC bytes (not really needed by us, but required by SD) */
261  SD_IO_ReadByte();
262  SD_IO_ReadByte();
263  /* Set response value to success */
264  rvalue = MSD_OK;
265  }
266  else
267  {
268  /* Set response value to failure */
269  rvalue = MSD_ERROR;
270  }
271  }
272 
273  /* Send dummy byte: 8 Clock pulses of delay */
275  /* Returns the reponse */
276  return rvalue;
277 }
278 
287 uint8_t BSP_SD_WriteBlocks(uint32_t* p32Data, uint64_t Sector, uint16_t BlockSize, uint32_t NumberOfBlocks)
288 {
289  uint32_t offset = 0;
290  uint8_t rvalue = MSD_ERROR;
291  uint8_t *pData = (uint8_t *)p32Data;
292 
293  SENSORTILE_SD_CS_HIGH();
294 
295  if(SD_CardType != HIGH_CAPACITY_SD_CARD)
296  {
297  Sector *= BlockSize;
298  }
299 
300  /* Data transfer */
301  while (NumberOfBlocks--)
302  {
303 
304  /* Send CMD24 (SD_CMD_WRITE_SINGLE_BLOCK) to write blocks and
305  Check if the SD acknowledged the write block command: R1 response (0x00: no errors) */
306  if (SD_IO_WriteCmd(SD_CMD_WRITE_SINGLE_BLOCK, Sector + offset, 0xFF, SD_RESPONSE_NO_ERROR) != HAL_OK)
307  {
308  return MSD_ERROR;
309  }
310 
311  /* Send dummy byte */
312  SD_IO_WriteByte(SD_DUMMY_BYTE);
313  //SD_IO_WriteByte(SD_DUMMY_BYTE);
314 
315  /* Send the data token to signify the start of the data */
316  SD_IO_WriteByte(SD_START_DATA_SINGLE_BLOCK_WRITE);
317 
318  SD_IO_WriteDMA((uint8_t*)pData, BlockSize);
319 
320  while (wTransferState == TRANSFER_WAIT)
321  {
322  }
323  wTransferState = TRANSFER_WAIT;
324 
325  /* Set next write address */
326  if(SD_CardType != HIGH_CAPACITY_SD_CARD)
327  {
328  offset += BlockSize;
329  }
330  else
331  {
332  offset += 1;
333  }
334 
335  /* Put CRC bytes (not really needed by us, but required by SD) */
336  SD_IO_ReadByte();
337  SD_IO_ReadByte();
338 
339  /* Read data response */
341  {
342  /* Set response value to success */
343  rvalue = MSD_OK;
344  }
345  else
346  {
347  /* Set response value to failure */
348  rvalue = MSD_ERROR;
349  }
350 
351  }
352  /* Send dummy byte: 8 Clock pulses of delay */
354 
355 
356  /* Returns the reponse */
357  return rvalue;
358 }
359 
360 
368 void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
369 {
370  /* Transfer in transmission/reception process is complete */
371  wTransferState = TRANSFER_COMPLETE;
372 }
373 
382 {
383  uint32_t counter = 0;
384  uint8_t rvalue = MSD_ERROR;
385  uint8_t CSD_Tab[16];
386 
387  /* Send CMD9 (CSD register) or CMD10(CSD register) and Wait for response in the R1 format (0x00 is no errors) */
388  if (SD_IO_WriteCmd(SD_CMD_SEND_CSD, 0, 0xFF, SD_RESPONSE_NO_ERROR) == HAL_OK)
389  {
391  {
392  for (counter = 0; counter < 16; counter++)
393  {
394  /* Store CSD register value on CSD_Tab */
395  CSD_Tab[counter] = SD_IO_ReadByte();
396  }
397 
398  /* Get CRC bytes (not really needed by us, but required by SD) */
399  SD_IO_WriteByte(SD_DUMMY_BYTE);
400  SD_IO_WriteByte(SD_DUMMY_BYTE);
401 
402  /* Set response value to success */
403  rvalue = MSD_OK;
404  }
405  }
406  /* Send dummy byte: 8 Clock pulses of delay */
408 
409  if(rvalue == SD_RESPONSE_NO_ERROR)
410  {
411  /* Byte 0 */
412  Csd->CSDStruct = (CSD_Tab[0] & 0xC0) >> 6;
413  Csd->SysSpecVersion = (CSD_Tab[0] & 0x3C) >> 2;
414  Csd->Reserved1 = CSD_Tab[0] & 0x03;
415 
416  /* Byte 1 */
417  Csd->TAAC = CSD_Tab[1];
418 
419  /* Byte 2 */
420  Csd->NSAC = CSD_Tab[2];
421 
422  /* Byte 3 */
423  Csd->MaxBusClkFrec = CSD_Tab[3];
424 
425  /* Byte 4 */
426  Csd->CardComdClasses = CSD_Tab[4] << 4;
427 
428  /* Byte 5 */
429  Csd->CardComdClasses |= (CSD_Tab[5] & 0xF0) >> 4;
430  Csd->RdBlockLen = CSD_Tab[5] & 0x0F;
431 
432  /* Byte 6 */
433  Csd->PartBlockRead = (CSD_Tab[6] & 0x80) >> 7;
434  Csd->WrBlockMisalign = (CSD_Tab[6] & 0x40) >> 6;
435  Csd->RdBlockMisalign = (CSD_Tab[6] & 0x20) >> 5;
436  Csd->DSRImpl = (CSD_Tab[6] & 0x10) >> 4;
437  Csd->Reserved2 = 0;
439  Csd->DeviceSize = (CSD_Tab[6] & 0x03) << 10;
440 
441  /* Byte 7 */
442  Csd->DeviceSize |= (CSD_Tab[7]) << 2;
443 
444  /* Byte 8 */
445  Csd->DeviceSize |= (CSD_Tab[8] & 0xC0) >> 6;
446 
447  Csd->MaxRdCurrentVDDMin = (CSD_Tab[8] & 0x38) >> 3;
448  Csd->MaxRdCurrentVDDMax = (CSD_Tab[8] & 0x07);
449 
450  /* Byte 9 */
451  Csd->MaxWrCurrentVDDMin = (CSD_Tab[9] & 0xE0) >> 5;
452  Csd->MaxWrCurrentVDDMax = (CSD_Tab[9] & 0x1C) >> 2;
453  Csd->DeviceSizeMul = (CSD_Tab[9] & 0x03) << 1;
454  /* Byte 10 */
455  Csd->DeviceSizeMul |= (CSD_Tab[10] & 0x80) >> 7;
456 
457  Csd->EraseGrSize = (CSD_Tab[10] & 0x40) >> 6;
458  Csd->EraseGrMul = (CSD_Tab[10] & 0x3F) << 1;
459 
460  /* Byte 11 */
461  Csd->EraseGrMul |= (CSD_Tab[11] & 0x80) >> 7;
462  Csd->WrProtectGrSize = (CSD_Tab[11] & 0x7F);
463 
464  /* Byte 12 */
465  Csd->WrProtectGrEnable = (CSD_Tab[12] & 0x80) >> 7;
466  Csd->ManDeflECC = (CSD_Tab[12] & 0x60) >> 5;
467  Csd->WrSpeedFact = (CSD_Tab[12] & 0x1C) >> 2;
468  Csd->MaxWrBlockLen = (CSD_Tab[12] & 0x03) << 2;
469 
470  /* Byte 13 */
471  Csd->MaxWrBlockLen |= (CSD_Tab[13] & 0xC0) >> 6;
472  Csd->WriteBlockPaPartial = (CSD_Tab[13] & 0x20) >> 5;
473  Csd->Reserved3 = 0;
474  Csd->ContentProtectAppli = (CSD_Tab[13] & 0x01);
475 
476  /* Byte 14 */
477  Csd->FileFormatGrouop = (CSD_Tab[14] & 0x80) >> 7;
478  Csd->CopyFlag = (CSD_Tab[14] & 0x40) >> 6;
479  Csd->PermWrProtect = (CSD_Tab[14] & 0x20) >> 5;
480  Csd->TempWrProtect = (CSD_Tab[14] & 0x10) >> 4;
481  Csd->FileFormat = (CSD_Tab[14] & 0x0C) >> 2;
482  Csd->ECC = (CSD_Tab[14] & 0x03);
483 
484  /* Byte 15 */
485  Csd->CSD_CRC = (CSD_Tab[15] & 0xFE) >> 1;
486  Csd->Reserved4 = 1;
487  }
488  /* Return the reponse */
489  return rvalue;
490 }
491 
499 static uint8_t SD_GetCIDRegister(SD_CID* Cid)
500 {
501  uint32_t counter = 0;
502  uint8_t rvalue = MSD_ERROR;
503  uint8_t CID_Tab[16];
504 
505  /* Send CMD10 (CID register) and Wait for response in the R1 format (0x00 is no errors) */
506  if (SD_IO_WriteCmd(SD_CMD_SEND_CID, 0, 0xFF, SD_RESPONSE_NO_ERROR) == HAL_OK)
507  {
509  {
510  /* Store CID register value on CID_Tab */
511  for (counter = 0; counter < 16; counter++)
512  {
513  CID_Tab[counter] = SD_IO_ReadByte();
514  }
515 
516  /* Get CRC bytes (not really needed by us, but required by SD) */
517  SD_IO_WriteByte(SD_DUMMY_BYTE);
518  SD_IO_WriteByte(SD_DUMMY_BYTE);
519 
520  /* Set response value to success */
521  rvalue = MSD_OK;
522  }
523  }
524 
525  /* Send dummy byte: 8 Clock pulses of delay */
527 
528  if(rvalue == MSD_OK)
529  {
530  /* Byte 0 */
531  Cid->ManufacturerID = CID_Tab[0];
532 
533  /* Byte 1 */
534  Cid->OEM_AppliID = CID_Tab[1] << 8;
535 
536  /* Byte 2 */
537  Cid->OEM_AppliID |= CID_Tab[2];
538 
539  /* Byte 3 */
540  Cid->ProdName1 = CID_Tab[3] << 24;
541 
542  /* Byte 4 */
543  Cid->ProdName1 |= CID_Tab[4] << 16;
544 
545  /* Byte 5 */
546  Cid->ProdName1 |= CID_Tab[5] << 8;
547 
548  /* Byte 6 */
549  Cid->ProdName1 |= CID_Tab[6];
550 
551  /* Byte 7 */
552  Cid->ProdName2 = CID_Tab[7];
553 
554  /* Byte 8 */
555  Cid->ProdRev = CID_Tab[8];
556 
557  /* Byte 9 */
558  Cid->ProdSN = CID_Tab[9] << 24;
559 
560  /* Byte 10 */
561  Cid->ProdSN |= CID_Tab[10] << 16;
562 
563  /* Byte 11 */
564  Cid->ProdSN |= CID_Tab[11] << 8;
565 
566  /* Byte 12 */
567  Cid->ProdSN |= CID_Tab[12];
568 
569  /* Byte 13 */
570  Cid->Reserved1 |= (CID_Tab[13] & 0xF0) >> 4;
571  Cid->ManufactDate = (CID_Tab[13] & 0x0F) << 8;
572 
573  /* Byte 14 */
574  Cid->ManufactDate |= CID_Tab[14];
575 
576  /* Byte 15 */
577  Cid->CID_CRC = (CID_Tab[15] & 0xFE) >> 1;
578  Cid->Reserved2 = 1;
579  }
580  /* Return the reponse */
581  return rvalue;
582 }
583 
592 static uint8_t SD_SendCmd_wResp(uint8_t Cmd, uint32_t Arg, uint8_t Crc)
593 {
594  return SD_IO_WriteCmd_wResp(Cmd, Arg, Crc);
595 }
596 
605 static uint8_t SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
606 {
607  uint8_t status = MSD_ERROR;
608 
609  if(SD_IO_WriteCmd(Cmd, Arg, Crc, Response) == HAL_OK)
610  {
611  status = MSD_OK;
612  }
613 
614  /* Send Dummy Byte */
616 
617  return status;
618 }
619 
630 {
631  SD_Info response, rvalue= SD_DATA_OTHER_ERROR;
632 
633  while (rvalue != SD_DATA_OK)
634  {
635 
636  /* Read response */
637  response = (SD_Info)SD_IO_ReadByte();
638  /* Mask unused bits */
639  response &= 0x1F;
640  switch (response)
641  {
642  case SD_DATA_OK:
643  {
644  rvalue = SD_DATA_OK;
645  break;
646  }
647  case 0x00:
648  {
649  rvalue = SD_DATA_OK;
650  response = SD_DATA_OK;
651  break;
652  }
653  case SD_DATA_CRC_ERROR:
654  return SD_DATA_CRC_ERROR;
655  case SD_DATA_WRITE_ERROR:
656  return SD_DATA_WRITE_ERROR;
657  default:
658  {
659  rvalue = SD_DATA_OTHER_ERROR;
660  break;
661  }
662  }
663 
664  }
665 
666  /* Wait null data */
667  while (SD_IO_ReadByte() == 0);
668  /* Return response */
669  return response;
670 
671 }
672 
678 uint8_t BSP_SD_GetStatus(void)
679 {
680  return MSD_OK;
681 }
682 
688 static uint8_t SD_GoIdleState(void)
689 {
690  uint8_t n, resp[4];
691 
692  /* Send CMD0 (SD_CMD_GO_IDLE_STATE) to put SD in SPI mode and
693  Wait for In Idle State Response (R1 Format) equal to 0x01 */
694  if (SD_SendCmd(SD_CMD_GO_IDLE_STATE, 0, 0x95, SD_IN_IDLE_STATE) != MSD_OK)
695  {
696  /* No Idle State Response: return an error */
697  return MSD_ERROR;
698  }
699 
700  /* Send CMD8 */
701  if(SD_SendCmd_wResp(SD_CMD_HS_SEND_EXT_CSD, 0x000001AA, 0x87) == 1) /* SDv2? */
702  {
703  for (n = 0; n < 4; n++)
704  {
705  resp[n] = SD_IO_ReadByte(); /* Get 32 bit return value of R7 resp */
706  }
708 
709  if (resp[2] == 0x01 && resp[3] == 0xAA) /* the card supports vcc of 2.7-3.6V? */
710  {
711  do /* Wait for end of initialization with ACMD41(HCS) */
712  {
713  HAL_Delay(100);
714  if(SD_SendCmd(SD_CMD_APP_CMD, 0, 0xFF, 1) != MSD_OK) /* CMD55 because following command id SD Card Specific */
715  {
716  return MSD_ERROR;
717  }
718  } while(SD_SendCmd(SD_CMD_SD_APP_OP_COND, 1UL << 30, 0xFF, SD_RESPONSE_NO_ERROR) != MSD_OK); /* ACMD41 */
719 
720  HAL_Delay(10);
721 
722  /* Read OCR register with CMD58 and check CCS flag (bit 30) */
723  resp[0] = SD_SendCmd_wResp(SD_CMD_SDMMC_READ_OCR, 0, 0xFF);
724  if(resp[0] == 0)
725  {
726  for (n = 0; n < 4; n++)
727  {
728  resp[n] = SD_IO_ReadByte(); /* Get 32 bit return value of R7 resp */
729  }
730  if(resp[0]&0x40)
731  {
732  SD_CardType = HIGH_CAPACITY_SD_CARD; /* Card id SDv2 and High Capacity */
733  }
734  else
735  {
736  SD_CardType = STD_CAPACITY_SD_CARD_V2_0; /* Card id SDv2 */
737  }
738  }
740  }
741  }
742  else /* Not SDv2 card */
743  {
744  SD_CardType = STD_CAPACITY_SD_CARD_V1_1;
745  }
746 
748  return MSD_OK;
749 }
756 uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
757 {
758  uint8_t rvalue = MSD_ERROR;
759 
760  /* Send CMD32 (Erase group start) and check if the SD acknowledged the erase command: R1 response (0x00: no errors) */
762  {
763  /* Send CMD33 (Erase group end) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */
765  {
766  /* Send CMD38 (Erase) and Check if the SD acknowledged the erase command: R1 response (0x00: no errors) */
768  {
769  /* Verify that SD card is ready to use after the specific command ERASE */
771  rvalue = MSD_OK;
772  }
773  }
774  }
775 
776  /* Return the reponse */
777  return rvalue;
778 }
795 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
static uint8_t SD_GetCSDRegister(SD_CSD *Csd)
Read the CSD card register. Reading the contents of the CSD register in SPI mode is a simple read-blo...
uint8_t SD_IO_ReadByte(void)
Reads a byte from the SD.
Definition: SensorTile.c:1253
static uint8_t SD_GoIdleState(void)
Put SD in Idle state.
uint8_t BSP_SD_ReadBlocks(uint32_t *p32Data, uint64_t Sector, uint16_t BlockSize, uint32_t NumberOfBlocks)
Reads block(s) from a specified address in an SD card, in polling mode.
#define STD_CAPACITY_SD_CARD_V1_1
Supported SD Memory Cards.
#define SD_CMD_WRITE_SINGLE_BLOCK
#define SD_CMD_SD_APP_OP_COND
void SD_IO_WriteByte(uint8_t Data)
Writes a byte on the SD.
Definition: SensorTile.c:1224
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi)
TxRx Transfer completed callback.
This file contains definitions for SensorTile_sd.c driver.
SD reponses and error flags.
Definition: SensorTile_sd.h:77
#define SD_CMD_HS_SEND_EXT_CSD
#define SD_CMD_APP_CMD
#define SD_CMD_SD_ERASE_GRP_END
#define MSD_OK
SD status structure definition.
Definition: SensorTile_sd.h:69
static uint8_t SD_GetCIDRegister(SD_CID *Cid)
Read the CID card register. Reading the contents of the CID register in SPI mode is a simple read-blo...
#define SD_CMD_GO_IDLE_STATE
SD Commands Index.
SD Card information.
Data response error.
Definition: SensorTile_sd.h:90
uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
Erases the specified memory area of the given SD card.
uint8_t BSP_SD_WriteBlocks(uint32_t *p32Data, uint64_t Sector, uint16_t BlockSize, uint32_t NumberOfBlocks)
Writes block(s) to a specified address in an SD card, in polling mode.
#define SD_CMD_SET_BLOCKLEN
#define SD_START_DATA_SINGLE_BLOCK_READ
Start Data tokens: Tokens (necessary because at nop/idle (and CS active) only 0xff is on the data/com...
uint8_t SD_IO_WriteCmd_wResp(uint8_t Cmd, uint32_t Arg, uint8_t Crc)
Sends 5 bytes command to the SD card and get response.
Definition: SensorTile.c:1273
HAL_StatusTypeDef SD_IO_WriteCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
Sends 5 bytes command to the SD card and get response.
Definition: SensorTile.c:1312
uint8_t BSP_SD_GetStatus(void)
Returns the SD status.
Card Specific Data: CSD Register.
Definition: SensorTile_sd.h:99
void SD_IO_WriteDummy(void)
Sends dummy byte with CS High.
Definition: SensorTile.c:1374
uint8_t BSP_SD_GetCardInfo(SD_CardInfo *pCardInfo)
Returns information about specific card.
#define SD_CMD_SEND_CID
Card Identification Data: CID Register.
#define SD_CMD_ERASE
static SD_Info SD_GetDataResponse(void)
Get SD card data response.
void SD_IO_Init(void)
Initializes the SD Card and put it into StandBy State (Ready for data transfer).
Definition: SensorTile.c:1140
#define SD_PRESENT
SD detection on its memory slot.
#define SD_CMD_SEND_CSD
#define SD_CMD_SD_ERASE_GRP_START
static uint8_t SD_SendCmd(uint8_t Cmd, uint32_t Arg, uint8_t Crc, uint8_t Response)
Send 5 bytes command to the SD card and get response.
void SD_IO_Init_LS(void)
Initializes the SD Card and put it into StandBy State (Ready for data transfer). Low baundrate...
Definition: SensorTile.c:1167
static uint8_t SD_SendCmd_wResp(uint8_t Cmd, uint32_t Arg, uint8_t Crc)
Send 5 bytes command to the SD card and get response.
#define SD_CMD_SDMMC_READ_OCR
uint8_t BSP_SD_Init(void)
Initialize the SD card.
HAL_StatusTypeDef SD_IO_WaitResponse(uint8_t Response)
Waits response from the SD card.
Definition: SensorTile.c:1347
#define SD_CMD_READ_SINGLE_BLOCK
SD_Info
Definition: SensorTile_sd.h:72
void SD_IO_WriteDMA(uint8_t *pData, uint16_t Size)
Writes a block by DMA on the SD.
Definition: SensorTile.c:1237
Generated by   doxygen 1.8.13