From dd0069d2c8bb37b776c43e8ffd448b48d82c6b17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Tue, 4 Dec 2012 18:17:20 +0000 Subject: [PATCH] further adaption --- SD_CARD/BaS_gcc/.project | 1 + SD_CARD/BaS_gcc/sources/mmcbb.c | 24 ++++++++++++------------ SD_CARD/BaS_gcc/sources/sysinit.h | 1 + 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/SD_CARD/BaS_gcc/.project b/SD_CARD/BaS_gcc/.project index 008ae57..377e4df 100644 --- a/SD_CARD/BaS_gcc/.project +++ b/SD_CARD/BaS_gcc/.project @@ -7,6 +7,7 @@ org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, ?children? diff --git a/SD_CARD/BaS_gcc/sources/mmcbb.c b/SD_CARD/BaS_gcc/sources/mmcbb.c index 6175e34..fa71c7c 100644 --- a/SD_CARD/BaS_gcc/sources/mmcbb.c +++ b/SD_CARD/BaS_gcc/sources/mmcbb.c @@ -1,3 +1,7 @@ +#include +#include +#include "sysinit.h" + /*------------------------------------------------------------------------*/ /* Firebee: MMCv3/SDv1/SDv2 (SPI mode) control module */ /*------------------------------------------------------------------------*/ @@ -95,8 +99,7 @@ #define CMD58 (58) /* READ_OCR */ -static volatile -DSTATUS Stat = STA_NOINIT; /* Physical drive status */ +static volatile DSTATUS Stat = STA_NOINIT; /* Physical drive status */ static volatile UINT Timer1, Timer2; /* 1kHz decrement timer stopped at zero (disk_timerproc()) */ @@ -169,7 +172,7 @@ static bool card_ready(void) */ static int wait_ready (UINT wt) { - return waitfor(card_ready, wt); + return waitfor(wt, card_ready); } @@ -177,13 +180,10 @@ static int wait_ready (UINT wt) /* * Deselect card and release SPI */ - -static -void deselect (void) +static void deselect (void) { CS_HIGH(); /* CS = H */ xchg_spi(0xFF); /* Dummy clock (force DO hi-z for multiple slave SPI) */ - } @@ -209,9 +209,10 @@ int select (void) /* 1:OK, 0:Timeout */ * Control SPI module (Platform dependent) */ -static -void power_on (void) /* Enable SSP module and attach it to I/O pads */ +static void power_on (void) /* Enable SSP module and attach it to I/O pads */ { + spi_init(); +#ifdef _NOT_USED_ __set_PCONP(PCSSPx, 1); /* Enable SSP module */ __set_PCLKSEL(PCLKSSPx, PCLKDIV_SSP); /* Select PCLK frequency for SSP */ SSPxCR0 = 0x0007; /* Set mode: SPI mode 0, 8-bit */ @@ -228,7 +229,7 @@ void power_on (void) /* Enable SSP module and attach it to I/O pads */ FIO0DIR |= _BV(9)|_BV(7)|_BV(6); /* Set SCK1, MOSI1 and CS# as output */ #endif CS_HIGH(); /* Set CS# high */ - +#endif /* _NOT_USED_ */ for (Timer1 = 10; Timer1; ) ; /* 10ms */ } @@ -304,8 +305,7 @@ int xmit_datablock ( /* 1:OK, 0:Failed */ /* Send a command packet to the MMC */ /*-----------------------------------------------------------------------*/ -static -BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */ +static BYTE send_cmd ( /* Return value: R1 resp (bit7==1:Failed to send) */ BYTE cmd, /* Command index */ DWORD arg /* Argument */ ) diff --git a/SD_CARD/BaS_gcc/sources/sysinit.h b/SD_CARD/BaS_gcc/sources/sysinit.h index a219e0c..43325b4 100644 --- a/SD_CARD/BaS_gcc/sources/sysinit.h +++ b/SD_CARD/BaS_gcc/sources/sysinit.h @@ -29,6 +29,7 @@ #define __SYSINIT_H__ extern void wait_10us(void); +extern inline bool waitfor(uint32_t us, int (*condition)(void)); /* send a 16-bit word out on the serial port */ #define uart_out_word(a) MCF_PSC0_PSCTB_8BIT = (a)