SAM4S-EK_FreeRTOS+FAT-SL  1.0
An example project to test the functionality of FreeRTOS+FAT-SL using SD card as data storage medium
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
SDdrv_f.c File Reference
#include "api_mdriver.h"
#include "psp_string.h"
#include "HSMCI.h"
#include "sd_mmc_protocol.h"

Go to the source code of this file.

Functions

uint32_t sd_cmd8 (uint8_t *v2)
 
uint32_t sd_mci_op_cond (uint8_t v2)
 Ask to all cards to send their operations conditions (MCI only). More...
 
void sd_decode_csd (void)
 Decodes SD CSD register. More...
 
uint32_t sd_acmd51 (void)
 ACMD51 - Read the SD Configuration Register. More...
 
uint32_t sd_acmd6 (void)
 ACMD6 - Define the data bus width to 4 bits bus. More...
 
uint32_t sd_cm6_set_high_speed (void)
 CMD6 for SD - Switch card in high speed mode. More...
 
uint32_t sd_mmc_cmd13 (void)
 CMD13 - Addressed card sends its status register. This function waits the clear of the busy flag. More...
 
uint32_t sd_mmc_start_read_block (F_DRIVER *driver, void *dest, uint16_t nb_block)
 
uint32_t sd_mmc_start_write_block (F_DRIVER *driver, void *src, uint16_t nb_block)
 
F_DRIVERsd_init (unsigned long driver_param)
 

Variables

uint16_t rca = 0
 
uint8_t csd [CSD_REG_BSIZE]
 
const uint32_t sd_mmc_trans_units [7] = { 10, 100, 1000, 10000, 0, 0, 0 }
 
const uint32_t sd_trans_multipliers [16] = { 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 }
 
uint32_t capacity
 
uint32_t clock
 
uint8_t high_speed
 

Function Documentation

uint32_t sd_acmd51 ( void  )

ACMD51 - Read the SD Configuration Register.

Note
SD Card Configuration Register (SCR) provides information on the SD Memory Card's special features that were configured into the given card. The size of SCR register is 64 bits.
Returns
OK if success, otherwise FAIL

Definition at line 211 of file SDdrv_f.c.

uint32_t sd_acmd6 ( void  )

ACMD6 - Define the data bus width to 4 bits bus.

Returns
OK if success, otherwise FAIL

Definition at line 273 of file SDdrv_f.c.

uint32_t sd_cm6_set_high_speed ( void  )

CMD6 for SD - Switch card in high speed mode.

Note
CMD6 for SD is valid under the "trans" state.
high_speed is updated.
clock is updated.
Returns
OK if success, otherwise FAIL

Definition at line 305 of file SDdrv_f.c.

uint32_t sd_cmd8 ( uint8_t *  v2)

Definition at line 71 of file SDdrv_f.c.

void sd_decode_csd ( void  )

Decodes SD CSD register.

Definition at line 162 of file SDdrv_f.c.

F_DRIVER* sd_init ( unsigned long  driver_param)

Definition at line 613 of file SDdrv_f.c.

uint32_t sd_mci_op_cond ( uint8_t  v2)

Ask to all cards to send their operations conditions (MCI only).

  • ACMD41 sends operation condition command.
  • ACMD41 reads OCR
Parameters
v2Shall be 1 if it is a SD card V2
Returns
OK if success, otherwise FAIL

Definition at line 108 of file SDdrv_f.c.

uint32_t sd_mmc_cmd13 ( void  )

CMD13 - Addressed card sends its status register. This function waits the clear of the busy flag.

Returns
true if success, otherwise false

Definition at line 364 of file SDdrv_f.c.

uint32_t sd_mmc_start_read_block ( F_DRIVER driver,
void *  dest,
uint16_t  nb_block 
)

Definition at line 398 of file SDdrv_f.c.

uint32_t sd_mmc_start_write_block ( F_DRIVER driver,
void *  src,
uint16_t  nb_block 
)

Definition at line 478 of file SDdrv_f.c.

Variable Documentation

uint32_t capacity

Definition at line 66 of file SDdrv_f.c.

uint32_t clock

Definition at line 68 of file SDdrv_f.c.

uint8_t csd[CSD_REG_BSIZE]

Definition at line 60 of file SDdrv_f.c.

uint8_t high_speed

Definition at line 69 of file SDdrv_f.c.

uint16_t rca = 0

Definition at line 58 of file SDdrv_f.c.

const uint32_t sd_mmc_trans_units[7] = { 10, 100, 1000, 10000, 0, 0, 0 }

Definition at line 62 of file SDdrv_f.c.

const uint32_t sd_trans_multipliers[16] = { 0, 10, 12, 13, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 70, 80 }

Definition at line 64 of file SDdrv_f.c.