doc diskio: RIOTized style and added doxygen

This commit is contained in:
Oleg Hahm 2016-03-23 18:31:03 +01:00
parent f0eaed7fb8
commit 0925737e28
5 changed files with 178 additions and 143 deletions

View File

@ -10,9 +10,9 @@
@ Fast Block Copy (declared in diskio.h) @ Fast Block Copy (declared in diskio.h)
@-----------------------------------------------------------@ @-----------------------------------------------------------@
.global Copy_un2al .global copy_un2al
.arm .arm
Copy_un2al: copy_un2al:
STMFD SP!, {R4-R8} STMFD SP!, {R4-R8}
ANDS IP, R1, #3 ANDS IP, R1, #3
BEQ lb_align BEQ lb_align
@ -46,9 +46,9 @@ lb_align:
BX LR BX LR
.global Copy_al2un .global copy_al2un
.arm .arm
Copy_al2un: copy_al2un:
STMFD SP!, {R4-R8} STMFD SP!, {R4-R8}
ANDS IP, R0, #3 ANDS IP, R0, #3
BEQ sb_align BEQ sb_align

View File

@ -80,7 +80,7 @@ extern unsigned long xtimer_now(void);
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
static volatile DSTATUS Stat = STA_NOINIT; /* Disk status */ static volatile diskio_sta_t Stat = DISKIO_STA_NOINIT; /* Disk status */
static unsigned short CardRCA; /* Assigned RCA */ static unsigned short CardRCA; /* Assigned RCA */
static unsigned char CardType, /* Card type flag */ static unsigned char CardType, /* Card type flag */
@ -363,7 +363,7 @@ static void power_off(void)
PINSEL4 &= ~((BIT22 | BIT23) | (BIT24 | BIT25) | (BIT26 | BIT27)); PINSEL4 &= ~((BIT22 | BIT23) | (BIT24 | BIT25) | (BIT26 | BIT27));
// Pins should be now configured as standard input (see board_init.c if you accidentally reconfigured them) // Pins should be now configured as standard input (see board_init.c if you accidentally reconfigured them)
Stat |= STA_NOINIT; Stat |= DISKIO_STA_NOINIT;
} }
@ -523,13 +523,13 @@ static void bswap_cp(unsigned char *dst, const unsigned long *src)
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Initialize Disk Drive */ /* Initialize Disk Drive */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
DSTATUS MCI_initialize(void) diskio_sta_t mci_initialize(void)
{ {
unsigned int cmd, n; unsigned int cmd, n;
unsigned long resp[4]; unsigned long resp[4];
unsigned char ty; unsigned char ty;
if (Stat & STA_NODISK) { if (Stat & DISKIO_STA_NODISK) {
return Stat; /* No card in the socket */ return Stat; /* No card in the socket */
} }
@ -666,12 +666,12 @@ DSTATUS MCI_initialize(void)
MCI_CLOCK = (MCI_CLOCK & 0xF00) | 0x200 | (PCLK / MCLK_RW / 2 - 1); /* Set MCICLK = MCLK_RW, power-save mode */ MCI_CLOCK = (MCI_CLOCK & 0xF00) | 0x200 | (PCLK / MCLK_RW / 2 - 1); /* Set MCICLK = MCLK_RW, power-save mode */
Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */ Stat &= ~DISKIO_STA_NOINIT; /* Clear DISKIO_STA_NOINIT */
return Stat; return Stat;
di_fail: di_fail:
power_off(); power_off();
Stat |= STA_NOINIT; /* Set STA_NOINIT */ Stat |= DISKIO_STA_NOINIT; /* Set DISKIO_STA_NOINIT */
return Stat; return Stat;
} }
@ -682,7 +682,7 @@ di_fail:
/* Get Disk Status */ /* Get Disk Status */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
DSTATUS MCI_status(void) diskio_sta_t mci_status(void)
{ {
return Stat; return Stat;
} }
@ -699,17 +699,17 @@ DSTATUS MCI_status(void)
* @param sector Start sector number (LBA) * @param sector Start sector number (LBA)
* @param count Sector count (1..127) * @param count Sector count (1..127)
*/ */
DRESULT MCI_read(unsigned char *buff, unsigned long sector, unsigned char count) diskio_result_t mci_read(unsigned char *buff, unsigned long sector, unsigned char count)
{ {
unsigned long resp; unsigned long resp;
unsigned int cmd; unsigned int cmd;
if (count < 1 || count > 127) { if (count < 1 || count > 127) {
return RES_PARERR; /* Check parameter */ return DISKIO_RES_PARERR; /* Check parameter */
} }
if (Stat & STA_NOINIT) { if (Stat & DISKIO_STA_NOINIT) {
return RES_NOTRDY; /* Check drive status */ return DISKIO_RES_NOTRDY; /* Check drive status */
} }
if (!(CardType & CT_BLOCK)) { if (!(CardType & CT_BLOCK)) {
@ -717,7 +717,7 @@ DRESULT MCI_read(unsigned char *buff, unsigned long sector, unsigned char count)
} }
if (!wait_ready(500)) { if (!wait_ready(500)) {
return RES_ERROR; /* Make sure that card is tran state */ return DISKIO_RES_ERROR; /* Make sure that card is tran state */
} }
ready_reception(count, 512); /* Ready to receive data blocks */ ready_reception(count, 512); /* Ready to receive data blocks */
@ -738,7 +738,7 @@ DRESULT MCI_read(unsigned char *buff, unsigned long sector, unsigned char count)
break; /* Abort if any error has occured */ break; /* Abort if any error has occured */
} }
Copy_al2un(buff, DmaBuff[rp], 512); /* Pop an block */ copy_al2un(buff, DmaBuff[rp], 512); /* Pop an block */
XferRp = rp = (rp + 1) % N_BUF; /* Next DMA buffer */ XferRp = rp = (rp + 1) % N_BUF; /* Next DMA buffer */
@ -756,7 +756,7 @@ DRESULT MCI_read(unsigned char *buff, unsigned long sector, unsigned char count)
stop_transfer(); /* Close data path */ stop_transfer(); /* Close data path */
return count ? RES_ERROR : RES_OK; return count ? DISKIO_RES_ERROR : DISKIO_RES_OK;
} }
@ -771,22 +771,22 @@ DRESULT MCI_read(unsigned char *buff, unsigned long sector, unsigned char count)
* @param sector Start sector number (LBA) * @param sector Start sector number (LBA)
* @param count Sector count (1..127) * @param count Sector count (1..127)
* */ * */
DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char count) diskio_result_t mci_write(const unsigned char *buff, unsigned long sector, unsigned char count)
{ {
unsigned long rc; unsigned long rc;
unsigned int cmd; unsigned int cmd;
unsigned char wp, xc; unsigned char wp, xc;
if (count < 1 || count > 127) { if (count < 1 || count > 127) {
return RES_PARERR; /* Check parameter */ return DISKIO_RES_PARERR; /* Check parameter */
} }
if (Stat & STA_NOINIT) { if (Stat & DISKIO_STA_NOINIT) {
return RES_NOTRDY; /* Check drive status */ return DISKIO_RES_NOTRDY; /* Check drive status */
} }
if (Stat & STA_PROTECT) { if (Stat & DISKIO_STA_PROTECT) {
return RES_WRPRT; /* Check write protection */ return DISKIO_RES_WRPRT; /* Check write protection */
} }
if (!(CardType & CT_BLOCK)) { if (!(CardType & CT_BLOCK)) {
@ -794,7 +794,7 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
} }
if (!wait_ready(500)) { if (!wait_ready(500)) {
return RES_ERROR; /* Make sure that card is tran state */ return DISKIO_RES_ERROR; /* Make sure that card is tran state */
} }
if (count == 1) { /* Single block write */ if (count == 1) { /* Single block write */
@ -805,7 +805,7 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
if (!send_cmd(cmd, count, 1, &rc) /* Preset number of blocks to write */ if (!send_cmd(cmd, count, 1, &rc) /* Preset number of blocks to write */
|| (rc & 0xC0580000)) { || (rc & 0xC0580000)) {
return RES_ERROR; return DISKIO_RES_ERROR;
} }
cmd = CMD25; cmd = CMD25;
@ -813,14 +813,14 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
if (!send_cmd(cmd, sector, 1, &rc) /* Send a write command */ if (!send_cmd(cmd, sector, 1, &rc) /* Send a write command */
|| (rc & 0xC0580000)) { || (rc & 0xC0580000)) {
return RES_ERROR; return DISKIO_RES_ERROR;
} }
wp = 0; wp = 0;
xc = count; xc = count;
do { /* Fill block FIFO */ do { /* Fill block FIFO */
Copy_un2al(DmaBuff[wp], (unsigned char *)(unsigned int)buff, 512); /* Push a block */ copy_un2al(DmaBuff[wp], (unsigned char *)(unsigned int)buff, 512); /* Push a block */
wp++; /* Next DMA buffer */ wp++; /* Next DMA buffer */
count--; count--;
buff += 512; /* Next user buffer address */ buff += 512; /* Next user buffer address */
@ -839,7 +839,7 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
break; /* Abort if block underrun or any MCI error has occured */ break; /* Abort if block underrun or any MCI error has occured */
} }
Copy_un2al(DmaBuff[wp], (unsigned char *)(unsigned int)buff, 512); /* Push a block */ copy_un2al(DmaBuff[wp], (unsigned char *)(unsigned int)buff, 512); /* Push a block */
XferWp = wp = (wp + 1) % N_BUF; /* Next DMA buffer */ XferWp = wp = (wp + 1) % N_BUF; /* Next DMA buffer */
if (XferStat & 0xC) { if (XferStat & 0xC) {
@ -862,7 +862,7 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
send_cmd(CMD12, 0, 1, &rc); send_cmd(CMD12, 0, 1, &rc);
} }
return count ? RES_ERROR : RES_OK; return count ? DISKIO_RES_ERROR : DISKIO_RES_OK;
} }
#endif /* _READONLY */ #endif /* _READONLY */
@ -873,26 +873,26 @@ DRESULT MCI_write(const unsigned char *buff, unsigned long sector, unsigned char
/* Miscellaneous Functions */ /* Miscellaneous Functions */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
DRESULT MCI_ioctl( diskio_result_t mci_ioctl(
unsigned char ctrl, /* Control code */ unsigned char ctrl, /* Control code */
void *buff /* Buffer to send/receive data block */ void *buff /* Buffer to send/receive data block */
) )
{ {
DRESULT res; diskio_result_t res;
unsigned char *ptr = (unsigned char *)buff; unsigned char *ptr = (unsigned char *)buff;
unsigned long resp[4], d, *dp, st, ed; unsigned long resp[4], d, *dp, st, ed;
if (Stat & STA_NOINIT) { if (Stat & DISKIO_STA_NOINIT) {
return RES_NOTRDY; return DISKIO_RES_NOTRDY;
} }
res = RES_ERROR; res = DISKIO_RES_ERROR;
switch(ctrl) { switch(ctrl) {
case CTRL_SYNC : /* Make sure that all data has been written on the media */ case CTRL_SYNC : /* Make sure that all data has been written on the media */
if (wait_ready(500)) { /* Wait for card enters tarn state */ if (wait_ready(500)) { /* Wait for card enters tarn state */
res = RES_OK; res = DISKIO_RES_OK;
} }
break; break;
@ -908,12 +908,12 @@ DRESULT MCI_ioctl(
*(unsigned long *)buff = d << (b - 9); *(unsigned long *)buff = d << (b - 9);
} }
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case GET_SECTOR_SIZE : /* Get sectors on the disk (unsigned short) */ case GET_SECTOR_SIZE : /* Get sectors on the disk (unsigned short) */
*(unsigned short *)buff = 512; *(unsigned short *)buff = 512;
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case GET_BLOCK_SIZE : /* Get erase block size in unit of sectors (unsigned long) */ case GET_BLOCK_SIZE : /* Get erase block size in unit of sectors (unsigned long) */
@ -929,7 +929,7 @@ DRESULT MCI_ioctl(
} }
} }
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case CTRL_ERASE_SECTOR : /* Erase a block of sectors */ case CTRL_ERASE_SECTOR : /* Erase a block of sectors */
@ -947,7 +947,7 @@ DRESULT MCI_ioctl(
} }
if (send_cmd(CMD32, st, 1, resp) && send_cmd(CMD33, ed, 1, resp) && send_cmd(CMD38, 0, 1, resp) && wait_ready(30000)) { if (send_cmd(CMD32, st, 1, resp) && send_cmd(CMD33, ed, 1, resp) && send_cmd(CMD38, 0, 1, resp) && wait_ready(30000)) {
res = RES_OK; res = DISKIO_RES_OK;
} }
break; break;
@ -956,38 +956,38 @@ DRESULT MCI_ioctl(
switch(ptr[0]) { switch(ptr[0]) {
case 0: /* Sub control code == 0 (POWER_OFF) */ case 0: /* Sub control code == 0 (POWER_OFF) */
power_off(); /* Power off */ power_off(); /* Power off */
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case 1: /* Sub control code == 1 (POWER_GET) */ case 1: /* Sub control code == 1 (POWER_GET) */
ptr[1] = (unsigned char)power_status(); ptr[1] = (unsigned char)power_status();
res = RES_OK; res = DISKIO_RES_OK;
break; break;
default : default :
res = RES_PARERR; res = DISKIO_RES_PARERR;
} }
break; break;
case MMC_GET_TYPE : /* Get card type flags (1 byte) */ case MMC_GET_TYPE : /* Get card type flags (1 byte) */
*ptr = CardType; *ptr = CardType;
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case MMC_GET_CSD : /* Get CSD (16 bytes) */ case MMC_GET_CSD : /* Get CSD (16 bytes) */
memcpy(buff, &CardInfo[0], 16); memcpy(buff, &CardInfo[0], 16);
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case MMC_GET_CID : /* Get CID (16 bytes) */ case MMC_GET_CID : /* Get CID (16 bytes) */
memcpy(buff, &CardInfo[16], 16); memcpy(buff, &CardInfo[16], 16);
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case MMC_GET_OCR : /* Get OCR (4 bytes) */ case MMC_GET_OCR : /* Get OCR (4 bytes) */
memcpy(buff, &CardInfo[32], 4); memcpy(buff, &CardInfo[32], 4);
res = RES_OK; res = DISKIO_RES_OK;
break; break;
case MMC_GET_SDSTAT : /* Receive SD status as a data block (64 bytes) */ case MMC_GET_SDSTAT : /* Receive SD status as a data block (64 bytes) */
@ -1000,8 +1000,8 @@ DRESULT MCI_ioctl(
while ((XferWp == 0) && !(XferStat & 0xC)) {} while ((XferWp == 0) && !(XferStat & 0xC)) {}
if (!(XferStat & 0xC)) { if (!(XferStat & 0xC)) {
Copy_al2un((unsigned char *)buff, DmaBuff[0], 64); copy_al2un((unsigned char *)buff, DmaBuff[0], 64);
res = RES_OK; res = DISKIO_RES_OK;
} }
} }
} }
@ -1012,7 +1012,7 @@ DRESULT MCI_ioctl(
break; break;
default: default:
res = RES_PARERR; res = DISKIO_RES_PARERR;
} }
return res; return res;

View File

@ -1,5 +1,6 @@
/* /*
* Copyright 2010 ChaN * Copyright 2010 ChaN
* Copyright 2016 INRIA
* *
* This file is subject to the terms and conditions of the GNU Lesser * This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level * General Public License v2.1. See the file LICENSE in the top level
@ -17,11 +18,11 @@
* *
* @file * @file
* *
* @author unknown * @author Oliver Hahm <oliver.hahm@inria.fr>
*/ */
#ifndef DEF_DISKIO #ifndef DISKIO_H_
#define DEF_DISKIO #define DISKIO_H_
#include <stdint.h> #include <stdint.h>
@ -29,105 +30,139 @@
extern "C" { extern "C" {
#endif #endif
#define DN_MCI 0 /* Physical drive number for MCI */ /* These functions are defined in asmfunc.S */
#define DN_NAND 1 /* Physical drive number for NAND flash */
/** /**
* @def MCI_PWRSAVE * @brief Copy aligned to unaligned
* @ingroup conf *
* @brief Powerdown mode to use between mci operations * @param[out] dst Pointer to unaligned destination address
* @param[in] src Pointer to aligned source address
* @param[in] count Number of bytes to copy
*/ */
#ifndef MCI_PWRSAVE void copy_al2un(unsigned char *dst, const unsigned long *src, int count);
#define MCI_PWRSAVE 0
#endif
/* These functions are defined in asmfunc.S */ /**
void Copy_al2un(unsigned char *dst, const unsigned long *src, int count); /* Copy aligned to unaligned. */ * @brief Copy unaligned to aligned
void Copy_un2al(unsigned long *dst, const unsigned char *src, int count); /* Copy unaligned to aligned. */ *
* @param[out] dst Pointer to unaligned destination address
* @param[in] src Pointer to aligned source address
* @param[in] count Number of bytes to copy
*/
void copy_un2al(unsigned long *dst, const unsigned char *src, int count);
/* Status of Disk Functions */ /** Results of Disk Functions */
typedef unsigned char DSTATUS;
/* Results of Disk Functions */
typedef enum { typedef enum {
RES_OK = 0, /* 0: Successful */ DISKIO_RES_OK = 0, /**< 0: Successful */
RES_ERROR, /* 1: R/W Error */ DISKIO_RES_ERROR, /**< 1: R/W Error */
RES_WRPRT, /* 2: Write Protected */ DISKIO_RES_WRPRT, /**< 2: Write Protected */
RES_NOTRDY, /* 3: Not Ready */ DISKIO_RES_NOTRDY, /**< 3: Not Ready */
RES_PARERR /* 4: Invalid Parameter */ DISKIO_RES_PARERR /**< 4: Invalid Parameter */
} DRESULT; } diskio_result_t;
/**
* @name Disk Status Bits
* @{
*/
typedef enum {
DISKIO_STA_NOINIT = 0x01, /**< Drive not initialized */
DISKIO_STA_NODISK = 0x02, /**< No medium in the drive */
DISKIO_STA_PROTECT = 0x04 /**< Write protected */
} diskio_sta_t;
/** @} */
/**
* @name Command code for disk_ioctrl fucntion
* @{
*/
/**
* @name Generic ioctl command (defined for FatFs)
* @{
*/
#define CTRL_SYNC 0 /**< Flush disk cache (for write functions) */
#define GET_SECTOR_COUNT 1 /**< Get media size (for only f_mkfs()) */
#define GET_SECTOR_SIZE 2 /**< Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
#define GET_BLOCK_SIZE 3 /**< Get erase block size (for only f_mkfs()) */
#define CTRL_ERASE_SECTOR 4 /**< Force erased a block of sectors (for only _USE_ERASE) */
/** @} */
/**
* @name Generic ioctl command
* @{
*/
#define CTRL_POWER 5 /**< Get/Set power status */
#define CTRL_LOCK 6 /**< Lock/Unlock media removal */
#define CTRL_EJECT 7 /**< Eject media */
/** @} */
/**
* @name MMC/SDC specific ioctl command
* @{
*/
#define MMC_GET_TYPE 10 /**< Get card type */
#define MMC_GET_CSD 11 /**< Get CSD */
#define MMC_GET_CID 12 /**< Get CID */
#define MMC_GET_OCR 13 /**< Get OCR */
#define MMC_GET_SDSTAT 14 /**< Get SD status */
/** @} */
/** @} */
/*---------------------------------------*/ /**
/* Prototypes for disk control functions */ * @brief Initialize media control interface (MCI)
*
* @returns 0 on success
* @returns a @ref diskio_sta_t value on error
*/
diskio_sta_t mci_initialize(void);
DSTATUS disk_initialize(unsigned char); /**
DSTATUS disk_status(unsigned char); * @brief Get the status of the media control interface (MCI)
DRESULT disk_read(unsigned char, unsigned char *, unsigned long, unsigned char); *
DRESULT disk_write(unsigned char, const unsigned char *, unsigned long, unsigned char); * @returns 0 on success
DRESULT disk_ioctl(unsigned char, unsigned char, void *); * @returns a @ref diskio_sta_t value on error
*/
diskio_sta_t mci_status(void);
/**
* @brief Read sectors over the media control interface (MCI)
*
* @param[out] buff Pointer to the data buffer to store read data
* @param[in] sector Start sector number (LBA)
* @param[in] count Sector count (1..127)
*
* @return @ref DISKIO_RES_OK on success
* @return any other @ref diskio_result_t value on error
*/
diskio_result_t mci_read(unsigned char *buff, unsigned long sector, unsigned char count);
/**
* @brief Write sectors over the media control interface (MCI)
* @param[in] buff Pointer to the data to be written
* @param[in] sector Start sector number (LBA)
* @param[in] count Sector count (1..127)
*
* @return @ref DISKIO_RES_OK on success
* @return any other @ref diskio_result_t value on error
*/
diskio_result_t mci_write(const unsigned char *buff, unsigned long sector, unsigned char count);
/* Disk Status Bits (DSTATUS) */ /**
* @brief IOCTL functions for the media control interface (MCI)
#define STA_NOINIT 0x01 /* Drive not initialized */ *
#define STA_NODISK 0x02 /* No medium in the drive */ * @param[in] ctrl Control code
#define STA_PROTECT 0x04 /* Write protected */ * @param[in,out] buff Buffer to send/receive data block
*
* @return @ref DISKIO_RES_OK on success
/* Command code for disk_ioctrl fucntion */ * @return any other @ref diskio_result_t value on error
*/
/* Generic ioctl command (defined for FatFs) */ diskio_result_t mci_ioctl(unsigned char ctrl, void *buff);
#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */
#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */
#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */
#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */
#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */
/* Generic ioctl command */
#define CTRL_POWER 5 /* Get/Set power status */
#define CTRL_LOCK 6 /* Lock/Unlock media removal */
#define CTRL_EJECT 7 /* Eject media */
/* MMC/SDC specific ioctl command */
#define MMC_GET_TYPE 10 /* Get card type */
#define MMC_GET_CSD 11 /* Get CSD */
#define MMC_GET_CID 12 /* Get CID */
#define MMC_GET_OCR 13 /* Get OCR */
#define MMC_GET_SDSTAT 14 /* Get SD status */
/* ATA/CF specific ioctl command */
#define ATA_GET_REV 20 /* Get F/W revision */
#define ATA_GET_MODEL 21 /* Get model name */
#define ATA_GET_SN 22 /* Get serial number */
/* NAND specific ioctl command */
#define NAND_FORMAT 30 /* Create physical format */
/*---------------------------------------------*/
/* Prototypes for each physical disk functions */
DSTATUS NAND_initialize(void);
DSTATUS NAND_status(void);
DRESULT NAND_read(unsigned char *, unsigned long, unsigned char);
DRESULT NAND_write(const unsigned char *, unsigned long, unsigned char);
DRESULT NAND_ioctl(unsigned char, void *);
DSTATUS MCI_initialize(void);
DSTATUS MCI_status(void);
DRESULT MCI_read(unsigned char *, unsigned long, unsigned char);
DRESULT MCI_write(const unsigned char *, unsigned long, unsigned char);
DRESULT MCI_ioctl(unsigned char, void *);
void MCI_timerproc(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/** @} */ /** @} */
#endif #endif /* DISKIO_H_ */

View File

@ -119,7 +119,7 @@ void auto_init(void)
#endif #endif
#ifdef MODULE_MCI #ifdef MODULE_MCI
DEBUG("Auto init mci module.\n"); DEBUG("Auto init mci module.\n");
MCI_initialize(); mci_initialize();
#endif #endif
#ifdef MODULE_PROFILING #ifdef MODULE_PROFILING
extern void profiling_init(void); extern void profiling_init(void);

View File

@ -27,7 +27,7 @@
static inline uint8_t sector_read(unsigned char *read_buf, unsigned long sector, unsigned long length, unsigned long offset) static inline uint8_t sector_read(unsigned char *read_buf, unsigned long sector, unsigned long length, unsigned long offset)
{ {
if (MCI_read(read_buf, sector, 1) == RES_OK) { if (mci_read(read_buf, sector, 1) == DISKIO_RES_OK) {
printf("[disk] Read sector %lu (%lu):\n", sector, offset); printf("[disk] Read sector %lu (%lu):\n", sector, offset);
for (unsigned long i = offset + 1; i <= offset + length; i++) { for (unsigned long i = offset + 1; i <= offset + length; i++) {
@ -51,7 +51,7 @@ int _get_sectorsize(int argc, char **argv)
(void) argv; (void) argv;
unsigned short ssize; unsigned short ssize;
if (MCI_ioctl(GET_SECTOR_SIZE, &ssize) == RES_OK) { if (mci_ioctl(GET_SECTOR_SIZE, &ssize) == DISKIO_RES_OK) {
printf("[disk] sector size is %u\n", ssize); printf("[disk] sector size is %u\n", ssize);
return 0; return 0;
@ -69,7 +69,7 @@ int _get_blocksize(int argc, char **argv)
(void) argv; (void) argv;
unsigned long bsize; unsigned long bsize;
if (MCI_ioctl(GET_BLOCK_SIZE, &bsize) == RES_OK) { if (mci_ioctl(GET_BLOCK_SIZE, &bsize) == DISKIO_RES_OK) {
printf("[disk] block size is %lu\n", bsize); printf("[disk] block size is %lu\n", bsize);
return 0; return 0;
@ -87,7 +87,7 @@ int _get_sectorcount(int argc, char **argv)
(void) argv; (void) argv;
unsigned long scount; unsigned long scount;
if (MCI_ioctl(GET_SECTOR_COUNT, &scount) == RES_OK) { if (mci_ioctl(GET_SECTOR_COUNT, &scount) == DISKIO_RES_OK) {
printf("[disk] sector count is %lu\n", scount); printf("[disk] sector count is %lu\n", scount);
return 0; return 0;
@ -107,7 +107,7 @@ int _read_sector(int argc, char **argv)
unsigned long sectornr = atol(argv[1]); unsigned long sectornr = atol(argv[1]);
if ((MCI_ioctl(GET_SECTOR_COUNT, &scount) == RES_OK) && (MCI_ioctl(GET_SECTOR_SIZE, &ssize) == RES_OK)) { if ((mci_ioctl(GET_SECTOR_COUNT, &scount) == DISKIO_RES_OK) && (mci_ioctl(GET_SECTOR_SIZE, &ssize) == DISKIO_RES_OK)) {
unsigned char read_buf[ssize]; unsigned char read_buf[ssize];
if (sector_read(read_buf, sectornr, ssize, 0)) { if (sector_read(read_buf, sectornr, ssize, 0)) {
@ -138,7 +138,7 @@ int _read_bytes(int argc, char **argv)
length = atoi(argv[2]); length = atoi(argv[2]);
/* get card info */ /* get card info */
if ((MCI_ioctl(GET_SECTOR_COUNT, &scount) == RES_OK) && (MCI_ioctl(GET_SECTOR_SIZE, &ssize) == RES_OK)) { if ((mci_ioctl(GET_SECTOR_COUNT, &scount) == DISKIO_RES_OK) && (mci_ioctl(GET_SECTOR_SIZE, &ssize) == DISKIO_RES_OK)) {
/* calculate sector and offset position */ /* calculate sector and offset position */
sector = (offset / ssize) + 1; sector = (offset / ssize) + 1;
offset = (offset % ssize); offset = (offset % ssize);