68 lines
1.1 KiB
C
68 lines
1.1 KiB
C
/*
|
|
* main.c
|
|
*
|
|
* Created on: Apr 25, 2015
|
|
* Author: mari
|
|
*/
|
|
#include <stm32f4xx.h>
|
|
#include <cmsis/arm_math.h>
|
|
#include <fatfs/ff.h>
|
|
#include <fatfs/diskio.h>
|
|
#include <uart/uart.h>
|
|
#include <stdio.h>
|
|
|
|
#define OUTPUT(pin) (0b01 << (pin * 2))
|
|
|
|
FATFS SDfs;
|
|
FIL file;
|
|
DIR root;
|
|
volatile int w;
|
|
|
|
DSTATUS SDIO_initialize();
|
|
|
|
int initreq = 0xFF;
|
|
|
|
int main() {
|
|
char buff[100];
|
|
char *name;
|
|
FILINFO fno;
|
|
RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN;
|
|
__DSB();
|
|
GPIOD->MODER |= OUTPUT(12) | OUTPUT(13);
|
|
SysTick_Config(8*1680000);
|
|
// f_mount(&SDfs, "0:/", 1);
|
|
w = 0;
|
|
initUART();
|
|
setvbuf(stdout, NULL, _IONBF, 0);
|
|
while(w<10);
|
|
initreq = f_mount(&SDfs, "0:/", 1);
|
|
while(initreq);
|
|
|
|
initreq = f_opendir(&root, "/");
|
|
if (initreq == FR_OK) {
|
|
if (!f_readdir(&root, &fno))
|
|
{
|
|
name = fno.fname;
|
|
initreq = f_open(&file, _T("test.txt"), FA_READ);
|
|
if (initreq == FR_OK) {
|
|
f_gets(buff, sizeof(buff), &file);
|
|
printf("test.txt:\r\n%s\r\n", buff);
|
|
f_close(&file);
|
|
}
|
|
|
|
}
|
|
}
|
|
fflush(stdout);
|
|
|
|
while(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
void SysTick_Handler()
|
|
{
|
|
GPIOD->ODR ^= (1<<12);
|
|
w++;
|
|
}
|