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
High Speed MultiMedia Card Interface (HSMCI)

Functions

uint32_t hsmci_init (void)
 Initializes the low level driver. More...
 
void hsmci_reset (void)
 Reset the HSMCI interface. More...
 
void hsmci_set_speed (uint32_t speed, uint32_t mck)
 Set speed of the HSMCI clock. More...
 
uint32_t hsmci_wait_busy (void)
 Wait the end of busy signal on data line. More...
 
uint32_t hsmci_send_cmd_execute (uint32_t cmdr, uint32_t cmd, uint32_t arg)
 Send a command. More...
 
uint8_t hsmci_get_bus_width (uint8_t slot)
 Return the maximum bus width of a slot. More...
 
uint32_t hsmci_is_high_speed_capable (void)
 Return the high speed capability of the driver. More...
 
void hsmci_select_device (uint8_t slot, uint32_t clock, uint8_t bus_width, uint32_t high_speed)
 Select a slot and initialize it. More...
 
void hsmci_deselect_device (uint8_t slot)
 Deselect a slot. More...
 
void hsmci_send_clock (void)
 Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install. More...
 
uint32_t hsmci_send_cmd (uint32_t cmd, uint32_t arg)
 Send a command on the selected slot. More...
 
uint32_t hsmci_get_response (void)
 Return the 32 bits response of the last command. More...
 
void hsmci_get_response_128 (uint8_t *response)
 Return the 128 bits response of the last command. More...
 
uint32_t hsmci_adtc_start (uint32_t cmd, uint32_t arg, uint16_t block_size, uint16_t nb_block, uint32_t access_block)
 Send an ADTC command on the selected slot An ADTC (Addressed Data Transfer Commands) command is used for read/write access. More...
 
uint32_t hsmci_adtc_stop (uint32_t cmd, uint32_t arg)
 Send a command to stop an ADTC command on the selected slot. More...
 
uint32_t hsmci_read_word (uint32_t *value)
 Read a word on the line. More...
 
uint32_t hsmci_write_word (uint32_t value)
 Write a word on the line. More...
 
uint32_t hsmci_start_read_blocks (void *dest, uint16_t nb_block)
 Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
uint32_t hsmci_wait_end_of_read_blocks (void)
 Wait the end of transfer initiated by mci_start_read_blocks() More...
 
uint32_t hsmci_start_write_blocks (const void *src, uint16_t nb_block)
 Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer. More...
 
uint32_t hsmci_wait_end_of_write_blocks (void)
 Wait the end of transfer initiated by mci_start_write_blocks() More...
 

Detailed Description

This driver interfaces the HSMCI module. It will add functions for SD/MMC card reading, writing and management.

Function Documentation

uint32_t hsmci_adtc_start ( uint32_t  cmd,
uint32_t  arg,
uint16_t  block_size,
uint16_t  nb_block,
uint32_t  access_block 
)

Send an ADTC command on the selected slot An ADTC (Addressed Data Transfer Commands) command is used for read/write access.

Parameters
cmdCommand definition
argArgument of the command
block_sizeBlock size used for the transfer
nb_blockTotal number of block for this transfer
access_blockif OK, the x_read_blocks() and x_write_blocks() functions must be used after this function. If FAIL, the mci_read_word() and mci_write_word() functions must be used after this function.
Returns
OK if success, otherwise FAIL

Definition at line 324 of file HSMCI.c.

uint32_t hsmci_adtc_stop ( uint32_t  cmd,
uint32_t  arg 
)

Send a command to stop an ADTC command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
OK if success, otherwise FAIL

Definition at line 403 of file HSMCI.c.

void hsmci_deselect_device ( uint8_t  slot)

Deselect a slot.

Parameters
slotSelected slot

Definition at line 271 of file HSMCI.c.

uint8_t hsmci_get_bus_width ( uint8_t  slot)

Return the maximum bus width of a slot.

Parameters
slotSelected slot
Returns
1, 4 or 8 lines.

Definition at line 211 of file HSMCI.c.

uint32_t hsmci_get_response ( void  )

Return the 32 bits response of the last command.

Returns
32 bits response

Definition at line 301 of file HSMCI.c.

void hsmci_get_response_128 ( uint8_t *  response)

Return the 128 bits response of the last command.

Parameters
responsePointer on the array to fill with the 128 bits response

Definition at line 306 of file HSMCI.c.

uint32_t hsmci_init ( void  )

Initializes the low level driver.

This enable the clock required and the hardware interface.

Definition at line 172 of file HSMCI.c.

uint32_t hsmci_is_high_speed_capable ( void  )

Return the high speed capability of the driver.

Returns
OK, if the high speed is supported

Definition at line 221 of file HSMCI.c.

uint32_t hsmci_read_word ( uint32_t *  value)

Read a word on the line.

Parameters
valuePointer on a word to fill
Returns
OK if success, otherwise FAIL

Definition at line 408 of file HSMCI.c.

void hsmci_reset ( void  )

Reset the HSMCI interface.

Definition at line 22 of file HSMCI.c.

void hsmci_select_device ( uint8_t  slot,
uint32_t  clock,
uint8_t  bus_width,
uint32_t  high_speed 
)

Select a slot and initialize it.

Parameters
slotSelected slot
clockMaximum clock to use (Hz)
bus_widthBus width to use (1, 4 or 8)
high_speedOK, to enable high speed mode

Definition at line 226 of file HSMCI.c.

void hsmci_send_clock ( void  )

Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before card install.

Definition at line 277 of file HSMCI.c.

uint32_t hsmci_send_cmd ( uint32_t  cmd,
uint32_t  arg 
)

Send a command on the selected slot.

Parameters
cmdCommand definition
argArgument of the command
Returns
OK if success, otherwise FAIL

Definition at line 289 of file HSMCI.c.

uint32_t hsmci_send_cmd_execute ( uint32_t  cmdr,
uint32_t  cmd,
uint32_t  arg 
)

Send a command.

Parameters
cmdrCMDR register bit to use for this command
cmdCommand definition
argArgument of the command
Returns
OK if success, otherwise FAIL

Definition at line 105 of file HSMCI.c.

void hsmci_set_speed ( uint32_t  speed,
uint32_t  mck 
)

Set speed of the HSMCI clock.

Parameters
speedHSMCI clock speed in Hz.
mckMCK clock speed in Hz.

Definition at line 46 of file HSMCI.c.

uint32_t hsmci_start_read_blocks ( void *  dest,
uint16_t  nb_block 
)

Start a read blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
destPointer on the buffer to fill
nb_blockNumber of block to transfer
Returns
OK if started, otherwise FAIL
uint32_t hsmci_start_write_blocks ( const void *  src,
uint16_t  nb_block 
)

Start a write blocks transfer on the line Note: The driver will use the DMA available to speed up the transfer.

Parameters
srcPointer on the buffer to send
nb_blockNumber of block to transfer
Returns
OK if started, otherwise FAIL
uint32_t hsmci_wait_busy ( void  )

Wait the end of busy signal on data line.

Returns
OK if success, otherwise FAIL

Definition at line 79 of file HSMCI.c.

uint32_t hsmci_wait_end_of_read_blocks ( void  )

Wait the end of transfer initiated by mci_start_read_blocks()

Returns
OK if success, otherwise FAIL
uint32_t hsmci_wait_end_of_write_blocks ( void  )

Wait the end of transfer initiated by mci_start_write_blocks()

Returns
OK if success, otherwise FAIL
uint32_t hsmci_write_word ( uint32_t  value)

Write a word on the line.

Parameters
valueWord to send
Returns
OK if success, otherwise FAIL

Definition at line 447 of file HSMCI.c.