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
HSMCI.h
Go to the documentation of this file.
1 /*
2  * HSMCI.h
3  *
4  * Created: 9/1/2014 1:31:32 PM
5  * Author: Owais
6  */
7 
8 
9 #ifndef HSMCI_H_
10 #define HSMCI_H_
11 
12 #include "sam.h"
13 
14 //This SD MMC stack supports only the high voltage
15 #define SD_MMC_VOLTAGE_SUPPORT (OCR_VDD_27_28 | OCR_VDD_28_29 | OCR_VDD_29_30 | OCR_VDD_30_31 | OCR_VDD_31_32 | OCR_VDD_32_33)
16 //This SD MMC stack uses the maximum block size authorized (512 bytes)
17 #define SD_MMC_BLOCK_SIZE 512
18 //Definition of HSMCI hardware interface
19 #define PINS_MCI (PIO_PA26 | PIO_PA27 | PIO_PA28 | PIO_PA29 | PIO_PA30 | PIO_PA31)
20 //Dard detect pin - software should check it before call sdInit();
21 #define PIN_CDMCI PIO_PA6
22 
23 #define OK 1
24 #define FAIL 0
25 #define SD_READ_OK 0
26 #define SD_WRITE_OK 0
27 #define SD_READ_FAIL 1
28 #define SD_WRITE_FAIL 1
29 
43 uint32_t hsmci_init(void);
44 
45 void hsmci_reset(void);
46 void hsmci_set_speed(uint32_t speed, uint32_t mck);
47 uint32_t hsmci_wait_busy(void);
48 uint32_t hsmci_send_cmd_execute(uint32_t cmdr, uint32_t cmd, uint32_t arg);
49 
56 uint8_t hsmci_get_bus_width(uint8_t slot);
57 
62 uint32_t hsmci_is_high_speed_capable(void);
63 
72 void hsmci_select_device(uint8_t slot, uint32_t clock, uint8_t bus_width, uint32_t high_speed);
73 
79 void hsmci_deselect_device(uint8_t slot);
80 
84 void hsmci_send_clock(void);
85 
93 uint32_t hsmci_send_cmd(uint32_t cmd, uint32_t arg);
94 
99 uint32_t hsmci_get_response(void);
100 
105 void hsmci_get_response_128(uint8_t* response);
106 
122 uint32_t hsmci_adtc_start(uint32_t cmd, uint32_t arg, uint16_t block_size,
123  uint16_t nb_block, uint32_t access_block);
124 
132 uint32_t hsmci_adtc_stop(uint32_t cmd, uint32_t arg);
133 
140 uint32_t hsmci_read_word(uint32_t* value);
141 
148 uint32_t hsmci_write_word(uint32_t value);
149 
158 uint32_t hsmci_start_read_blocks(void *dest, uint16_t nb_block);
159 
164 uint32_t hsmci_wait_end_of_read_blocks(void);
165 
174 uint32_t hsmci_start_write_blocks(const void *src, uint16_t nb_block);
175 
180 uint32_t hsmci_wait_end_of_write_blocks(void);
181 
182 #endif /* HSMCI_H_ */
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 ...
Definition: HSMCI.c:324
uint32_t hsmci_send_cmd_execute(uint32_t cmdr, uint32_t cmd, uint32_t arg)
Send a command.
Definition: HSMCI.c:105
uint32_t hsmci_wait_end_of_read_blocks(void)
Wait the end of transfer initiated by mci_start_read_blocks()
uint32_t hsmci_write_word(uint32_t value)
Write a word on the line.
Definition: HSMCI.c:447
uint32_t hsmci_is_high_speed_capable(void)
Return the high speed capability of the driver.
Definition: HSMCI.c:221
void hsmci_set_speed(uint32_t speed, uint32_t mck)
Set speed of the HSMCI clock.
Definition: HSMCI.c:46
void hsmci_select_device(uint8_t slot, uint32_t clock, uint8_t bus_width, uint32_t high_speed)
Select a slot and initialize it.
Definition: HSMCI.c:226
void hsmci_reset(void)
Reset the HSMCI interface.
Definition: HSMCI.c:22
uint32_t hsmci_init(void)
Initializes the low level driver.
Definition: HSMCI.c:172
uint8_t hsmci_get_bus_width(uint8_t slot)
Return the maximum bus width of a slot.
Definition: HSMCI.c:211
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...
uint32_t hsmci_adtc_stop(uint32_t cmd, uint32_t arg)
Send a command to stop an ADTC command on the selected slot.
Definition: HSMCI.c:403
void hsmci_deselect_device(uint8_t slot)
Deselect a slot.
Definition: HSMCI.c:271
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 ...
uint32_t hsmci_read_word(uint32_t *value)
Read a word on the line.
Definition: HSMCI.c:408
uint32_t hsmci_get_response(void)
Return the 32 bits response of the last command.
Definition: HSMCI.c:301
uint32_t clock
Definition: SDdrv_f.c:68
void hsmci_get_response_128(uint8_t *response)
Return the 128 bits response of the last command.
Definition: HSMCI.c:306
uint32_t hsmci_wait_end_of_write_blocks(void)
Wait the end of transfer initiated by mci_start_write_blocks()
uint8_t high_speed
Definition: SDdrv_f.c:69
void hsmci_send_clock(void)
Send 74 clock cycles on the line of selected slot Note: It is required after card plug and before car...
Definition: HSMCI.c:277
uint32_t hsmci_wait_busy(void)
Wait the end of busy signal on data line.
Definition: HSMCI.c:79
uint32_t hsmci_send_cmd(uint32_t cmd, uint32_t arg)
Send a command on the selected slot.
Definition: HSMCI.c:289