Compare commits

...

9 Commits

9 changed files with 857 additions and 579 deletions

View File

@@ -28,12 +28,10 @@ DSTATUS disk_status (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_SD:
return SDIO_status();
return sdio_status();
}
return STA_NOINIT;
}
@@ -48,12 +46,9 @@ DSTATUS disk_initialize (
BYTE pdrv /* Physical drive nmuber to identify the drive */
)
{
DSTATUS stat;
int result;
switch (pdrv) {
case DEV_SD:
return SDIO_initialize();
return sdio_initialize();
}
return STA_NOINIT;
}
@@ -71,12 +66,9 @@ DRESULT disk_read (
UINT count /* Number of sectors to read */
)
{
DRESULT res;
int result;
switch (pdrv) {
case DEV_SD:
return SDIO_disk_read(buff, sector, count);
return sdio_disk_read(buff, sector, count);
}
return RES_PARERR;
}
@@ -96,12 +88,9 @@ DRESULT disk_write (
UINT count /* Number of sectors to write */
)
{
DRESULT res;
int result;
switch (pdrv) {
case DEV_SD:
return SDIO_disk_write(buff, sector, count);
return sdio_disk_write(buff, sector, count);
}
return RES_PARERR;
@@ -120,12 +109,9 @@ DRESULT disk_ioctl (
void *buff /* Buffer to send/receive control data */
)
{
DRESULT res;
int result;
switch (pdrv) {
case DEV_SD:
return SDIO_disk_ioctl(cmd, buff);
return sdio_disk_ioctl(cmd, buff);
}
return RES_PARERR;

File diff suppressed because it is too large Load Diff

View File

@@ -12,11 +12,12 @@
#include <fatfs/ff.h>
#include <stdint.h>
DSTATUS SDIO_status();
DSTATUS SDIO_initialize();
DRESULT SDIO_disk_read(BYTE *buff, DWORD sector, UINT count);
DRESULT SDIO_disk_write(const BYTE *buff, DWORD sector, UINT count);
DRESULT SDIO_disk_ioctl(BYTE cmd, void* buff);
DSTATUS sdio_status();
DSTATUS sdio_initialize();
DRESULT sdio_disk_read(BYTE *buff, DWORD sector, UINT count);
DRESULT sdio_disk_write(const BYTE *buff, DWORD sector, UINT count);
DRESULT sdio_disk_ioctl(BYTE cmd, void* buff);
DWORD get_fattime();
@@ -31,9 +32,7 @@ DWORD get_fattime();
#define CURRENT_STATE_PRG 7
#define CURRENT_STATE_DIS 8
typedef struct _CardStatus {
struct sd_card_status {
uint32_t reserved : 3;
uint32_t AKE_SEQ_ERROR : 1;
uint32_t reserved_2 : 1;
@@ -60,21 +59,19 @@ typedef struct _CardStatus {
uint32_t BLOCK_LEN_ERROR : 1;
uint32_t ADDRESS_ERROR : 1;
uint32_t OUT_OF_RANGE : 1;
}CardStatus_t;
};
typedef enum {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC} card_type_t;
enum sdio_card_type {CARD_NONE = 0, MMC, SD_V1, SD_V2_SC, SD_V2_HC};
// MMC not supported
typedef struct _SDInfo {
struct sd_info {
uint16_t rca;
card_type_t type;
enum sdio_card_type type;
uint32_t sector_count;
}SDInfo_t;
};
typedef union _StatusConv {
CardStatus_t statusstruct;
union sdio_status_conv {
struct sd_card_status statusstruct;
uint32_t value;
}StatusConv_t;
};
#endif /* FATFS_SHIMATTA_SDIO_DRIVER_SHIMATTA_SDIO_DRIVER_H_ */

View File

@@ -14,13 +14,16 @@
//Initial Transfer CLK (ca. 400kHz)
#define INITCLK 130 //120
//Working CLK (Maximum)
#define WORKCLK 50 //0
#define WORKCLK 2 //0
//Data Timeout in CLK Cycles
#define DTIMEOUT 0x3000 //150
#define DTIMEOUT 0x8000 //150
//DMA Stream used for TX and RX DMA2 Stream 3 or 6 possible
// Currently not used due to possible misalignment of the data buffer.
//#define DMASTREAM DMA2_Stream6
#define USE_DMA 1
#define DMASTREAM DMA2_Stream6
#define DMASTREAM_NO 6
/* Port Definitions */

View File

@@ -8,7 +8,7 @@
/ Function Configurations
/---------------------------------------------------------------------------*/
#define FF_FS_READONLY 1
#define FF_FS_READONLY 0
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()

34
main.c
View File

@@ -22,10 +22,16 @@ volatile uint32_t sdio_wait;
int initreq = 0xFF;
int main() {
char buff[1024];
//const char *write_string = "This is a write test. Okay... Writing seems to work. Let's close the file\n";
char buff[8192*6];
int main()
{
int i;
char *name;
FILINFO fno;
RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
__DSB();
GPIOA->MODER |= OUTPUT(6) | OUTPUT(7);
@@ -39,20 +45,20 @@ int main() {
initreq = f_mount(&SDfs, "0:/", 1);
while(initreq);
initreq = f_opendir(&root, "/");
for (i = 0; i < 8192*6; i++)
buff[i] = 'A';
initreq = f_open(&file, "foo.txt", FA_OPEN_APPEND | FA_WRITE);
if (initreq == FR_OK) {
if (!f_readdir(&root, &fno))
{
name = fno.fname;
initreq = f_open(&file, name, FA_READ);
if (initreq == FR_OK) {
f_gets(buff, sizeof(buff), &file);
printf("%s:\r\n%s\r\n",name, buff);
f_close(&file);
for (i = 0; i < 100; i++) {
initreq = f_write(&file, buff, 8192*6, NULL);
if (initreq) {
initreq++;
}
}
initreq = f_close(&file);
}
}
}
//fflush(stdout);
while(1);
@@ -92,7 +98,7 @@ void SysTick_Handler()
sdio_wait++;
}
void SDIO_wait_ms(unsigned int i) {
void sdio_wait_ms(unsigned int i) {
sdio_wait = 0;
while(sdio_wait<i);

8
program-device.gdb Normal file
View File

@@ -0,0 +1,8 @@
target extended-remote :2331
monitor speed 4000
monitor reset
load
monitor reset
kill
quit

18
program-device.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/bin/bash
JLinkGDBServer -if SWD -device STM32F407VE &
sleep 2
# Check if GDB server is still running
gdbpid=`pidof JLinkGDBServer`
if [[ $gdbpid == "" ]]; then
echo ""
echo "GDB Server not running! Check target connection."
exit
fi
arm-none-eabi-gdb -x program-device.gdb stm32f4sdio.elf
sleep 2
kill $gdbpid

View File

@@ -152,7 +152,7 @@ SECTIONS
/* Uninitialized data section */
. = ALIGN(4);
.bss :
.bss (NOLOAD):
{
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .; /* define a global symbol at bss start */
@@ -167,7 +167,7 @@ SECTIONS
} >RAM
/* User_heap_stack section, used to check that there is enough RAM left */
._user_heap_stack :
._user_heap_stack (NOLOAD):
{
. = ALIGN(4);
PROVIDE (heap_low = .); /* for _sbrk */