MT2523 API Reference  LinkIt SDK v4
hal_sd.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __HAL_SD_H__
36 #define __HAL_SD_H__
37 
38 #include "hal_platform.h"
39 
40 #ifdef HAL_SD_MODULE_ENABLED
41 
642 #ifdef HAL_SD_CARD_DETECTION
643 
709 #endif
710 
717 #ifdef __cplusplus
718 extern "C" {
719 #endif
720 
726 typedef enum {
731 
732 
734 typedef enum {
738 
739 
741 typedef enum {
742  HAL_SD_TYPE_SD_CARD = 0,
748  HAL_SD_TYPE_UNKNOWN_CARD = 0xff,
750 
751 #ifdef HAL_SD_CARD_DETECTION
752 
755 typedef enum {
759 #endif
760 
771 typedef struct {
773  uint32_t clock;
775 
780 #ifdef HAL_SD_CARD_DETECTION
781 
792 typedef void (*hal_sd_callback_t)(hal_sd_card_event_t event, void *user_data);
796 #endif
797 
808 
809 
817 
818 #ifdef HAL_SD_CARD_DETECTION
819 
828 #endif
829 
838 
839 
848 hal_sd_status_t hal_sd_set_clock(hal_sd_port_t sd_port, uint32_t clock);
849 
850 
857 hal_sd_status_t hal_sd_get_clock(hal_sd_port_t sd_port, uint32_t *clock);
858 
859 
866 hal_sd_status_t hal_sd_get_capacity(hal_sd_port_t sd_port, uint64_t *capacity);
867 
868 
876 hal_sd_status_t hal_sd_get_erase_sector_size(hal_sd_port_t sd_port, uint32_t *erase_sector_size);
877 
878 
888 hal_sd_status_t hal_sd_erase_sectors(hal_sd_port_t sd_port, uint32_t start_sector, uint32_t sector_number);
889 
890 
902 hal_sd_status_t hal_sd_read_blocks(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number);
903 
904 
916 hal_sd_status_t hal_sd_write_blocks(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number);
917 
929 hal_sd_status_t hal_sd_read_blocks_dma(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number);
930 
931 
943 hal_sd_status_t hal_sd_write_blocks_dma(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number);
944 
945 
953 hal_sd_status_t hal_sd_get_csd(hal_sd_port_t sd_port, uint32_t *csd);
954 
955 
963 hal_sd_status_t hal_sd_get_cid(hal_sd_port_t sd_port, uint32_t *cid);
964 
965 
974 
975 
983 hal_sd_status_t hal_sd_get_ocr(hal_sd_port_t sd_port, uint32_t *ocr);
984 
985 
993 hal_sd_status_t hal_sd_get_card_status(hal_sd_port_t sd_port, uint32_t *card_status);
994 
995 
996 #ifdef __cplusplus
997 }
998 #endif
999 
1004 #endif /*HAL_SD_MODULE_ENABLED*/
1005 #endif /* __HAL_SD_H__ */
1006 
1007 
The SD/eMMC bus is busy error occurred.
Definition: hal_sd.h:727
hal_sd_status_t hal_sd_get_clock(hal_sd_port_t sd_port, uint32_t *clock)
This function gets the output clock of the MSDC.
hal_sd_port_t
This enum defines the SD/eMMC port.
Definition: hal_platform.h:1007
hal_sd_card_event_t
This enum defines the card detection result event.
Definition: hal_sd.h:755
hal_sd_status_t hal_sd_get_card_status(hal_sd_port_t sd_port, uint32_t *card_status)
This function gets the card status of the SD/eMMC card.
hal_sd_status_t hal_sd_init(hal_sd_port_t sd_port, hal_sd_config_t *sd_config)
This function initializes the MSDC and SD/eMMC card.
hal_sd_status_t hal_sd_set_clock(hal_sd_port_t sd_port, uint32_t clock)
This function sets the output clock of the MSDC.
The SD/eMMC read/write data with 4 bit bus width.
Definition: hal_sd.h:736
hal_sd_status_t hal_sd_get_capacity(hal_sd_port_t sd_port, uint64_t *capacity)
This function gets the card capacity of the SD/eMMC card.
hal_sd_status_t hal_sd_write_blocks(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number)
This function writes data to the SD/eMMC card in the MCU mode.
The SD/eMMC read/write data with 1 bit bus width.
Definition: hal_sd.h:735
hal_sd_status_t hal_sd_get_csd(hal_sd_port_t sd_port, uint32_t *csd)
This function gets the CSD register value of the SD/eMMC card.
hal_sd_status_t hal_sd_register_card_detection_callback(hal_sd_port_t sd_port, hal_sd_callback_t sd_callback, void *user_data)
This function registers a callback function to detect a card.
hal_sd_bus_width_t bus_width
The SD/eMMC read/write bus width.
Definition: hal_sd.h:772
An SD card is removed.
Definition: hal_sd.h:757
void(* hal_sd_callback_t)(hal_sd_card_event_t event, void *user_data)
This defines the callback function prototype.
Definition: hal_sd.h:792
hal_sd_card_type_t
This enum define the SD/eMMC card type.
Definition: hal_sd.h:741
hal_sd_status_t
This enum defines the SD/eMMC API's return type.
Definition: hal_sd.h:726
hal_sd_status_t hal_sd_erase_sectors(hal_sd_port_t sd_port, uint32_t start_sector, uint32_t sector_number)
This function erases the card sectors of the SD/eMMC card.
MMC card.
Definition: hal_sd.h:744
hal_sd_status_t hal_sd_write_blocks_dma(hal_sd_port_t sd_port, const uint32_t *write_data, uint32_t start_address, uint32_t block_number)
This function writes data to the SD/eMMC card in the DMA mode.
hal_sd_status_t hal_sd_deinit(hal_sd_port_t sd_port)
This function deinitializes the MSDC and the SD/eMMC settings.
uint32_t clock
The MSDC I/O bus clock, the unit is kHz.
Definition: hal_sd.h:773
SD 2.0 card and capacity less than 2GB.
Definition: hal_sd.h:745
hal_sd_bus_width_t
This enum defines the SD/eMMC bus width types.
Definition: hal_sd.h:734
hal_sd_status_t hal_sd_set_bus_width(hal_sd_port_t sd_port, hal_sd_bus_width_t bus_width)
This function sets a bus width for MSDC and the SD/eMMC card.
No error occurred during the function call.
Definition: hal_sd.h:729
This structure define the SD/eMMC initialize parameter.
Definition: hal_sd.h:771
hal_sd_status_t hal_sd_read_blocks(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number)
This function reads data from the SD/eMMC card in the MCU mode.
hal_sd_status_t hal_sd_get_cid(hal_sd_port_t sd_port, uint32_t *cid)
This function gets the CID register value of the SD/eMMC card.
An error occurred and the operation failed.
Definition: hal_sd.h:728
hal_sd_status_t hal_sd_get_ocr(hal_sd_port_t sd_port, uint32_t *ocr)
This function gets the OCR register value of the SD/eMMC card.
hal_sd_status_t hal_sd_get_erase_sector_size(hal_sd_port_t sd_port, uint32_t *erase_sector_size)
This function gets the sector size of the SD/eMMC card, mainly for erase purpose. ...
An SD card is inserted.
Definition: hal_sd.h:756
SD 2.0 card and capacity larger than 2GB.
Definition: hal_sd.h:746
hal_sd_status_t hal_sd_get_card_type(hal_sd_port_t sd_port, hal_sd_card_type_t *card_type)
This function gets the card type of the SD/eMMC card.
hal_sd_status_t hal_sd_read_blocks_dma(hal_sd_port_t sd_port, uint32_t *read_buffer, uint32_t start_address, uint32_t block_number)
This function reads data from the SD/eMMC card in the DMA mode.
EMMC 4.2 and above card.
Definition: hal_sd.h:747
SD card.
Definition: hal_sd.h:743