Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
sdif.h
00001 /****************************************************************************** 00002 * DISCLAIMER 00003 * 00004 * This software is supplied by Renesas Electronics Corporation and is only 00005 * intended for use with Renesas products. No other uses are authorized. 00006 * 00007 * This software is owned by Renesas Electronics Corporation and is protected under 00008 * all applicable laws, including copyright laws. 00009 * 00010 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES 00011 * REGARDING THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, 00012 * INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00013 * PARTICULAR PURPOSE AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY 00014 * DISCLAIMED. 00015 * 00016 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00017 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00018 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES 00019 * FOR ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS 00020 * AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00021 * 00022 * Renesas reserves the right, without notice, to make changes to this 00023 * software and to discontinue the availability of this software. 00024 * By using this software, you agree to the additional terms and 00025 * conditions found by accessing the following link: 00026 * http://www.renesas.com/disclaimer 00027 ******************************************************************************** 00028 * Copyright (C) 2013 Renesas Electronics Corporation. All rights reserved. 00029 **************************** Technical reference data ************************** 00030 * System Name : SD Driver Sample Program 00031 * File Name : sdif.h 00032 * Abstract : SD Memory card driver configration 00033 * Version : 4.00.00 00034 * Device : Aragon 00035 * Tool-Chain : DS-5 Ver 5.13 00036 * ARM Complier 00037 * OS : None 00038 * H/W Platform: 00039 * Description : 00040 ******************************************************************************** 00041 * History : 2013.07.12 Ver.4.00.00 00042 *******************************************************************************/ 00043 #ifndef _SDDRV_H_ 00044 #define _SDDRV_H_ 00045 00046 #ifdef __cplusplus 00047 extern "C" { 00048 #endif /* __cplusplus */ 00049 00050 /* ==== define ==== */ 00051 /* ---- SD Driver work buffer ---- */ 00052 #define SD_SIZE_OF_INIT 800 00053 00054 /* ---- error code ---- */ 00055 #define SD_OK_LOCKED_CARD 1 /* OK but card is locked status */ 00056 #define SD_OK 0 /* OK */ 00057 #define SD_ERR -1 /* general error */ 00058 #define SD_ERR_WP -2 /* write protect error */ 00059 #define SD_ERR_RO -3 /* read only error */ 00060 #define SD_ERR_RES_TOE -4 /* response time out error */ 00061 #define SD_ERR_CARD_TOE -5 /* card time out error */ 00062 #define SD_ERR_END_BIT -6 /* end bit error */ 00063 #define SD_ERR_CRC -7 /* CRC error */ 00064 #define SD_ERR_CARD_RES -8 /* card response error */ 00065 #define SD_ERR_HOST_TOE -9 /* host time out error */ 00066 #define SD_ERR_CARD_ERASE -10 /* card erase error */ 00067 #define SD_ERR_CARD_LOCK -11 /* card lock error */ 00068 #define SD_ERR_CARD_UNLOCK -12 /* card unlock error */ 00069 #define SD_ERR_HOST_CRC -13 /* host CRC error */ 00070 #define SD_ERR_CARD_ECC -14 /* card internal ECC error */ 00071 #define SD_ERR_CARD_CC -15 /* card internal error */ 00072 #define SD_ERR_CARD_ERROR -16 /* unknown card error */ 00073 #define SD_ERR_CARD_TYPE -17 /* non support card type */ 00074 #define SD_ERR_NO_CARD -18 /* no card */ 00075 #define SD_ERR_ILL_READ -19 /* illegal buffer read */ 00076 #define SD_ERR_ILL_WRITE -20 /* illegal buffer write */ 00077 #define SD_ERR_AKE_SEQ -21 /* the sequence of authentication process */ 00078 #define SD_ERR_OVERWRITE -22 /* CID/CSD overwrite error */ 00079 /* 23-29 */ 00080 #define SD_ERR_CPU_IF -30 /* target CPU interface function error */ 00081 #define SD_ERR_STOP -31 /* user stop */ 00082 /* 32-49 */ 00083 #define SD_ERR_CSD_VER -50 /* CSD register version error */ 00084 #define SD_ERR_SCR_VER -51 /* SCR register version error */ 00085 #define SD_ERR_FILE_FORMAT -52 /* CSD register file format error */ 00086 #define SD_ERR_NOTSUP_CMD -53 /* not supported command */ 00087 /* 54-59 */ 00088 #define SD_ERR_ILL_FUNC -60 /* invalid function request error */ 00089 #define SD_ERR_IO_VERIFY -61 /* direct write verify error */ 00090 #define SD_ERR_IO_CAPAB -62 /* IO capability error */ 00091 /* 63-69 */ 00092 #define SD_ERR_IFCOND_VER -70 /* Interface condition version error */ 00093 #define SD_ERR_IFCOND_VOLT -71 /* Interface condition voltage error */ 00094 #define SD_ERR_IFCOND_ECHO -72 /* Interface condition echo back pattern error */ 00095 /* 73-79 */ 00096 #define SD_ERR_OUT_OF_RANGE -80 /* the argument was out of range */ 00097 #define SD_ERR_ADDRESS_ERROR -81 /* misassigned address */ 00098 #define SD_ERR_BLOCK_LEN_ERROR -82 /* transfered block length is not allowed */ 00099 #define SD_ERR_ILLEGAL_COMMAND -83 /* Command not legal */ 00100 #define SD_ERR_RESERVED_ERROR18 -84 /* Reserved bit 18 Error */ 00101 #define SD_ERR_RESERVED_ERROR17 -85 /* Reserved bit 17 Error */ 00102 #define SD_ERR_CMD_ERROR -86 /* SD_INFO2 bit 0 CMD error */ 00103 #define SD_ERR_CBSY_ERROR -87 /* SD_INFO2 bit 14 CMD Type Reg Busy error */ 00104 #define SD_ERR_NO_RESP_ERROR -88 /* SD_INFO1 bit 0 No Response error */ 00105 /* 89 */ 00106 /* 90-95 */ 00107 #define SD_ERR_ERROR -96 /* SDIO ERROR */ 00108 #define SD_ERR_FUNCTION_NUMBER -97 /* SDIO FUNCTION NUMBER ERROR */ 00109 #define SD_ERR_COM_CRC_ERROR -98 /* SDIO CRC ERROR */ 00110 #define SD_ERR_INTERNAL -99 /* driver software internal error */ 00111 00112 /* ---- driver mode ---- */ 00113 #define SD_MODE_POLL 0x0000ul /* status check mode is software polling */ 00114 #define SD_MODE_HWINT 0x0001ul /* status check mode is hardware interrupt */ 00115 #define SD_MODE_SW 0x0000ul /* data transfer mode is software */ 00116 #define SD_MODE_DMA 0x0002ul /* data transfer mode is DMA */ 00117 #define SD_MODE_DMA_64 0x0004ul /* data transfer mode is DMA with 64 byte burst mode */ 00118 00119 /* ---- support mode ---- */ 00120 #define SD_MODE_MEM 0x0000ul /* memory cards only are supported */ 00121 #define SD_MODE_IO 0x0010ul /* memory and io cards are supported */ 00122 #define SD_MODE_COMBO 0x0030ul /* memory ,io and combo cards are supported */ 00123 #define SD_MODE_DS 0x0000ul /* only default speed mode is supported */ 00124 #define SD_MODE_HS 0x0040ul /* high speed mode is also supported */ 00125 #define SD_MODE_VER1X 0x0000ul /* ver1.1 host */ 00126 #define SD_MODE_VER2X 0x0080ul /* ver2.x host (high capacity and dual voltage) */ 00127 #define SD_MODE_1BIT 0x0100ul /* SD Mode 1bit only is supported */ 00128 #define SD_MODE_4BIT 0x0000ul /* SD Mode 1bit and 4bit is supported */ 00129 00130 /* ---- media voltage ---- */ 00131 #define SD_VOLT_1_7 0x00000010ul /* low voltage card minimum */ 00132 #define SD_VOLT_1_8 0x00000020ul 00133 #define SD_VOLT_1_9 0x00000040ul 00134 #define SD_VOLT_2_0 0x00000080ul 00135 #define SD_VOLT_2_1 0x00000100ul /* basic communication minimum */ 00136 #define SD_VOLT_2_2 0x00000200ul 00137 #define SD_VOLT_2_3 0x00000400ul 00138 #define SD_VOLT_2_4 0x00000800ul 00139 #define SD_VOLT_2_5 0x00001000ul 00140 #define SD_VOLT_2_6 0x00002000ul 00141 #define SD_VOLT_2_7 0x00004000ul 00142 #define SD_VOLT_2_8 0x00008000ul /* memory access minimum */ 00143 #define SD_VOLT_2_9 0x00010000ul 00144 #define SD_VOLT_3_0 0x00020000ul 00145 #define SD_VOLT_3_1 0x00040000ul 00146 #define SD_VOLT_3_2 0x00080000ul 00147 #define SD_VOLT_3_3 0x00100000ul 00148 #define SD_VOLT_3_4 0x00200000ul 00149 #define SD_VOLT_3_5 0x00400000ul 00150 #define SD_VOLT_3_6 0x00800000ul 00151 00152 /* ---- memory card write mode ---- */ 00153 #define SD_WRITE_WITH_PREERASE 0x0000u /* pre-erease write */ 00154 #define SD_WRITE_OVERWRITE 0x0001u /* overwrite */ 00155 00156 /* ---- io register write mode ---- */ 00157 #define SD_IO_SIMPLE_WRITE 0x0000u /* just write */ 00158 #define SD_IO_VERIFY_WRITE 0x0001u /* read after write */ 00159 00160 /* ---- io operation code ---- */ 00161 #define SD_IO_FIXED_ADDR 0x0000u /* R/W fixed address */ 00162 #define SD_IO_INCREMENT_ADDR 0x0001u /* R/W increment address */ 00163 #define SD_IO_FORCE_BYTE 0x0010u /* byte access only */ 00164 00165 /* ---- media type ---- */ 00166 #define SD_MEDIA_UNKNOWN 0x0000u /* unknown media */ 00167 #define SD_MEDIA_MMC 0x0010u /* MMC card */ 00168 #define SD_MEDIA_SD 0x0020u /* SD Memory card */ 00169 #define SD_MEDIA_IO 0x0001u /* SD IO card */ 00170 #define SD_MEDIA_MEM 0x0030u /* Memory card */ 00171 #define SD_MEDIA_COMBO 0x0021u /* SD COMBO card */ 00172 #define SD_MEDIA_EMBEDDED 0x8000u /* embedded media */ 00173 00174 /* ---- write protect info --- */ 00175 #define SD_WP_OFF 0x0000u /* card is not write protect */ 00176 #define SD_WP_HW 0x0001u /* card is H/W write protect */ 00177 #define SD_WP_TEMP 0x0002u /* card is TEMP_WRITE_PROTECT */ 00178 #define SD_WP_PERM 0x0004u /* card is PERM_WRITE_PROTECT */ 00179 #define SD_WP_ROM 0x0010u /* card is SD-ROM */ 00180 00181 /* ---- SD clock div ---- */ /* IMCLK is host controller clock */ 00182 #define SD_DIV_512 0x0080u /* SDCLOCK = IMCLK/512 */ 00183 #define SD_DIV_256 0x0040u /* SDCLOCK = IMCLK/256 */ 00184 #define SD_DIV_128 0x0020u /* SDCLOCK = IMCLK/128 */ 00185 #define SD_DIV_64 0x0010u /* SDCLOCK = IMCLK/64 */ 00186 #define SD_DIV_32 0x0008u /* SDCLOCK = IMCLK/32 */ 00187 #define SD_DIV_16 0x0004u /* SDCLOCK = IMCLK/16 */ 00188 #define SD_DIV_8 0x0002u /* SDCLOCK = IMCLK/8 */ 00189 #define SD_DIV_4 0x0001u /* SDCLOCK = IMCLK/4 */ 00190 #define SD_DIV_2 0x0000u /* SDCLOCK = IMCLK/2 */ 00191 #define SD_DIV_1 0x00FFu /* SDCLOCK = IMCLK (option) */ 00192 00193 /* ---- SD clock define ---- */ /* max frequency */ 00194 #define SD_CLK_400kHz 0x0000u /* 400kHz */ 00195 #define SD_CLK_1MHz 0x0001u /* 1MHz */ 00196 #define SD_CLK_5MHz 0x0002u /* 5MHz */ 00197 #define SD_CLK_10MHz 0x0003u /* 10MHz */ 00198 #define SD_CLK_20MHz 0x0004u /* 20MHz */ 00199 #define SD_CLK_25MHz 0x0005u /* 25MHz */ 00200 #define SD_CLK_50MHz 0x0006u /* 50MHz (phys spec ver1.10) */ 00201 00202 /* ---- speed class ---- */ 00203 #define SD_SPEED_CLASS_0 0x00u /* not defined, or less than ver2.0 */ 00204 #define SD_SPEED_CLASS_2 0x01u /* 2MB/sec */ 00205 #define SD_SPEED_CLASS_4 0x02u /* 4MB/sec */ 00206 #define SD_SPEED_CLASS_6 0x03u /* 6MB/sec */ 00207 00208 /* ---- IO initialize flags define ---- */ /* add for IO */ 00209 #define SD_IO_INT_ENAB 0x10u /* interrupt enable */ 00210 #define SD_IO_POWER_INIT 0x04u /* power on initialized */ 00211 #define SD_IO_MEM_INIT 0x02u /* memory initialized */ 00212 #define SD_IO_FUNC_INIT 0x01u /* io func initialized */ 00213 00214 /* ---- IO function's information ---- */ /* add for IO */ 00215 #define SD_IO_FUNC_READY 0x80u /* io redy */ 00216 #define SD_IO_FUNC_NUM 0x70u /* number of io func */ 00217 #define SD_IO_FUNC_EXISTS 0x04u /* memory present */ 00218 00219 /* ---- SD port mode ---- */ 00220 #define SD_PORT_SERIAL 0x0000u /* 1bit mode */ 00221 #define SD_PORT_PARALLEL 0x0001u /* 4bits mode */ 00222 00223 /* ---- SD Card detect port ---- */ 00224 #define SD_CD_SOCKET 0x0000u /* CD pin */ 00225 #define SD_CD_DAT3 0x0001u /* DAT3 pin */ 00226 00227 /* ---- SD Card detect interrupt ---- */ 00228 #define SD_CD_INT_DISABLE 0x0000u /* card detect interrupt disable */ 00229 #define SD_CD_INT_ENABLE 0x0001u /* card detect interrupt enable */ 00230 00231 /* ---- format mode ---- */ 00232 #define SD_FORMAT_QUICK 0x0000u /* quick format */ 00233 #define SD_FORMAT_FULL 0x0001u /* full format */ 00234 00235 /* ---- lock/unlock mode ---- */ 00236 #define SD_FORCE_ERASE 0x08 00237 #define SD_LOCK_CARD 0x04 00238 #define SD_UNLOCK_CARD 0x00 00239 #define SD_CLR_PWD 0x02 00240 #define SD_SET_PWD 0x01 00241 00242 /* ==== API prototype ===== */ 00243 /* ---- access library I/F ---- */ 00244 int sd_init(int sd_port, unsigned long base, void *workarea, int cd_port); 00245 int sd_cd_int(int sd_port, int enable,int (*callback)(int, int)); 00246 int sd_check_media(int sd_port); 00247 int sd_format(int sd_port, int mode,int (*callback)(unsigned long,unsigned long)); 00248 int sd_format2(int sd_port, int mode,unsigned long volserial,int (*callback)(unsigned long,unsigned long)); 00249 int sd_mount(int sd_port, unsigned long mode,unsigned long voltage); 00250 int sd_read_sect(int sd_port, unsigned char *buff,unsigned long psn,long cnt); 00251 int sd_write_sect(int sd_port, unsigned char *buff,unsigned long psn,long cnt,int writemode); 00252 int sd_get_type(int sd_port, unsigned char *type,unsigned char *speed,unsigned char *capa); 00253 int sd_get_size(int sd_port, unsigned long *user,unsigned long *protect); 00254 int sd_iswp(int sd_port); 00255 int sd_unmount(int sd_port); 00256 void sd_stop(int sd_port); 00257 int sd_set_intcallback(int sd_port, int (*callback)(int, int)); 00258 void sd_int_handler(int sd_port); 00259 int sd_get_error(int sd_port); 00260 int sd_check_int(int sd_port); 00261 int sd_get_reg(int sd_port, unsigned char *ocr,unsigned char *cid,unsigned char *csd, unsigned char *dsr,unsigned char *scr); 00262 int sd_get_rca(int sd_port, unsigned char *rca); 00263 int sd_get_sdstatus(int sd_port, unsigned char *sdstatus); 00264 int sd_get_speed(int sd_port, unsigned char *clss,unsigned char *move); 00265 int sd_finalize(int sd_port); 00266 int sd_set_seccnt(int sd_port, short sectors); 00267 int sd_get_seccnt(int sd_port); 00268 int sd_get_ver(int sd_port, unsigned short *sdhi_ver,char *sddrv_ver); 00269 int sd_set_cdtime(int sd_port, unsigned short cdtime); 00270 int sd_set_responsetime(int sd_port, unsigned short responsetime); 00271 int sd_set_buffer(int sd_port, void *buff,unsigned long size); 00272 int sd_inactive(int sd_port); 00273 int sd_set_softwp(int sd_port, int is_set,unsigned long data); 00274 int sd_set_tmpwp(int sd_port, int is_set); 00275 int sd_lock_unlock(int sd_port, unsigned char code,unsigned char *pwd,unsigned char len); 00276 00277 int esd_get_partition_id(int sd_port, int *id); 00278 int esd_select_partition(int sd_port, int id); 00279 int esd_query_partition(int sd_port, int sub, unsigned char *data); 00280 00281 int sdio_read_direct(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr); 00282 int sdio_write_direct(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,unsigned long raw_flag); 00283 int sdio_check_int(int sd_port); 00284 void sdio_int_handler(int sd_port); 00285 int sdio_set_intcallback(int sd_port, int (*callback)(int)); 00286 int sdio_enable_int(int sd_port); 00287 int sdio_disable_int(int sd_port); 00288 int sdio_read(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,long cnt,unsigned long op_code); 00289 int sdio_write(int sd_port, unsigned char *buff,unsigned long func,unsigned long adr,long cnt,unsigned long op_code); 00290 int sdio_reset(int sd_port); 00291 int sdio_get_ioocr(int sd_port, unsigned long *ioocr); 00292 int sdio_get_ioinfo(int sd_port, unsigned char *ioinfo); 00293 int sdio_get_cia(int sd_port, unsigned char *reg, unsigned char *cis, unsigned long func_num, long cnt); 00294 int sdio_set_enable(int sd_port, unsigned char func_bit); 00295 int sdio_get_ready(int sd_port, unsigned char *func_bit); 00296 int sdio_set_int(int sd_port, unsigned char func_bit,int enab); 00297 int sdio_get_int(int sd_port, unsigned char *func_bit,int *enab); 00298 int sdio_set_blocklen(int sd_port, unsigned short len, unsigned long func_num); 00299 int sdio_get_blocklen(int sd_port, unsigned short *len, unsigned long func_num); 00300 void sdio_abort(int sd_port, unsigned long func_num); 00301 int sdio_set_blkcnt(int sd_port, short blocks); 00302 int sdio_get_blkcnt(int sd_port); 00303 00304 /* ---- target CPU I/F ---- */ 00305 int sddev_init(int sd_port); 00306 int sddev_power_on(int sd_port); 00307 int sddev_power_off(int sd_port); 00308 int sddev_read_data(int sd_port, unsigned char *buff,unsigned long reg_addr,long num); 00309 int sddev_write_data(int sd_port, unsigned char *buff,unsigned long reg_addr,long num); 00310 unsigned int sddev_get_clockdiv(int sd_port, int clock); 00311 int sddev_set_port(int sd_port, int mode); 00312 int sddev_int_wait(int sd_port, int msec); 00313 int sddev_init_dma(int sd_port, unsigned long buffadr,unsigned long regadr,long cnt,int dir); 00314 int sddev_wait_dma_end(int sd_port, long cnt); 00315 int sddev_disable_dma(int sd_port); 00316 int sddev_finalize(int sd_port); 00317 int sddev_loc_cpu(int sd_port); 00318 int sddev_unl_cpu(int sd_port); 00319 int sddev_cmd0_sdio_mount(int sd_port); 00320 int sddev_cmd8_sdio_mount(int sd_port); 00321 00322 #ifdef __cplusplus 00323 } 00324 #endif /* __cplusplus */ 00325 00326 #endif /* _SDDRV_H_ */ 00327 00328 /* End of File */ 00329
Generated on Sun Jul 17 2022 03:41:56 by
1.7.2