# HG changeset patch # User jeandet # Date 2013-02-25 17:10:05 # Node ID 58c317327c7ed4d5506b7f431ff4a898d3536862 # Parent 1f8d622aedf1755199bde4d8e90ab6cf0294de54 sync diff --git a/bsp/src/STM32F4Eval/bsp.c b/bsp/src/STM32F4Eval/bsp.c --- a/bsp/src/STM32F4Eval/bsp.c +++ b/bsp/src/STM32F4Eval/bsp.c @@ -249,7 +249,14 @@ void bsp_iic_init() void bsp_SD_init() { - + gpio_t SDIO_DBxList[]={PC8 ,PC9 ,PC10 ,PC11 ,PC12,PD2}; + for(int i=0;i<6;i++) + { + gpio_t SDIO_DBx = gpioopen(SDIO_DBxList[i]); + SDIO_DBx |= gpiohighspeed | gpioaf | gpiopushpulltype | gpionopulltype; + gpiosetconfig(&SDIO_DBx); + GPIO_PinAFConfig(GPIOGETPORT(SDIO_DBx), (uint8_t)(SDIO_DBx & 0xF), GPIO_AF_SDIO); + } } void vs10XXclearXCS(){} diff --git a/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c b/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c --- a/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c +++ b/lib/src/common/FILE_SYSTEM/SDCARD/sdcard.c @@ -19,7 +19,22 @@ -- Author : Alexis Jeandet -- Mail : alexis.jeandet@gmail.com -------------------------------------------------------------------------------*/ -#include "sdcard.h" +#include +#include + +int sdcardselect (blkdeviceptr _this); +void sdcarddeselect (blkdeviceptr _this); +int sdcardwait_ready (sdcardDev* sdcard); +int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token); +int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr); +char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg); + +DSTATUS sdcarddisk_status (blkdeviceptr _this); +DSTATUS sdcarddisk_initialize (blkdeviceptr _this); +DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count); +DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count); +DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff); + static volatile unsigned int Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */ diff --git a/lib/src/includes/sdcard-sdio.h b/lib/src/includes/sdcard-sdio.h new file mode 100644 --- /dev/null +++ b/lib/src/includes/sdcard-sdio.h @@ -0,0 +1,65 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef SDCARD-SDIO_H +#define SDCARD-SDIO_H +#include +#include +#include +#include + +extern void sdcardsdiomake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +extern void sdcardsdiomakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/includes/sdcard-spi.h b/lib/src/includes/sdcard-spi.h new file mode 100644 --- /dev/null +++ b/lib/src/includes/sdcard-spi.h @@ -0,0 +1,66 @@ +/*------------------------------------------------------------------------------ +-- This file is a part of the libuc, microcontroler library +-- Copyright (C) 2012, Alexis Jeandet +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program; if not, write to the Free Software +-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +------------------------------------------------------------------------------- +-- Author : Alexis Jeandet +-- Mail : alexis.jeandet@gmail.com +-------------------------------------------------------------------------------*/ +#ifndef SDCARD-SPI_H +#define SDCARD-SPI_H +#include +#include +#include +#include + + +extern void sdcardspimake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +extern void sdcardspimakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/src/includes/sdcard.h b/lib/src/includes/sdcard.h --- a/lib/src/includes/sdcard.h +++ b/lib/src/includes/sdcard.h @@ -67,21 +67,9 @@ struct sdcard_str typedef volatile struct sdcard_str sdcardDev; -extern void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); -extern void sdcardmakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); +//extern void sdcardmake(sdcardDev* sdcard,UHANDLE phy,void (*rcvr_mmc) (UHANDLE,char *,uint32_t ),void (*xmit_mmc) (UHANDLE,const char *,uint32_t ),void (*setspeed) (UHANDLE phy,uint32_t speed),uint32_t (*getspeed) (UHANDLE phy)); +//extern void sdcardmakeblkdev(blkdevice* dev,sdcardDev* sdcard, blkdevselect_t select,blkdevpower_t power,blkdevdetect_t detect,blkdevwriteprotected_t writeprotected); -extern int sdcardselect (blkdeviceptr _this); -extern void sdcarddeselect (blkdeviceptr _this); -extern int sdcardwait_ready (sdcardDev* sdcard); -extern int sdcardxmit_datablock (sdcardDev* sdcard,const char *buff,char token); -extern int sdcardrcvr_datablock (sdcardDev* sdcard,char *buff,uint32_t btr); -extern char sdcardsend_cmd (blkdeviceptr _this,char cmd,uint32_t arg); - -extern DSTATUS sdcarddisk_status (blkdeviceptr _this); -extern DSTATUS sdcarddisk_initialize (blkdeviceptr _this); -extern DRESULT sdcarddisk_read (blkdeviceptr _this,char *buff,uint32_t sector,char count); -extern DRESULT sdcarddisk_write (blkdeviceptr _this,const char *buff,uint32_t sector,char count); -extern DRESULT sdcarddisk_ioctl (blkdeviceptr _this,char ctrl,void *buff); #endif diff --git a/lib/src/stm32f4/stm32f4.pro b/lib/src/stm32f4/stm32f4.pro --- a/lib/src/stm32f4/stm32f4.pro +++ b/lib/src/stm32f4/stm32f4.pro @@ -5,7 +5,8 @@ SUBDIRS = CORE/core.pro \ GPIO/gpio.pro \ UART/uart.pro \ SPI/spi.pro \ - I2C/i2c.pro + I2C/i2c.pro \ + SDCARD-SDIO/sdcard-sdio.pro