/* * main.c * * Created on: Apr 25, 2015 * Author: mari */ #include #include #include #include #include #include #include #define OUTPUT(pin) (0x01 << (pin * 2)) FATFS SDfs; FIL file; DIR root; volatile int w; volatile uint32_t sdio_wait; int initreq = 0xFF; //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); GPIOA->ODR |= (1<<7); 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); 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) { 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); } void HardFault_Handler(uint32_t *stack) { // unsigned int stacked_r0; // unsigned int stacked_r1; // unsigned int stacked_r2; // unsigned int stacked_r3; // unsigned int stacked_r12; // unsigned int stacked_lr; // unsigned int stacked_pc; // unsigned int stacked_psr; // // stacked_r0 = stack[0]; // stacked_r1 = stack[1]; // stacked_r2 = stack[2]; // stacked_r3 = stack[3]; // // stacked_r12 = stack[4]; // stacked_lr = stack[5]; // stacked_pc = stack[6]; // stacked_psr = stack[7]; GPIOA->MODER |= OUTPUT(6) | OUTPUT(7); GPIOA->ODR |= (1<<6) | (1<<7); while(1); } void SysTick_Handler() { GPIOA->ODR ^= (1<<6)|(1<<7); w++; sdio_wait++; } void sdio_wait_ms(unsigned int i) { sdio_wait = 0; while(sdio_wait