From b935f93ae1cce584e39180a3fec96ae7de489dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20H=C3=BCttel?= Date: Mon, 3 Apr 2017 01:35:20 +0200 Subject: [PATCH] removed WAITPEND from CMD init, Module is able to send commands. Ready to test SD Card --- fatfs/shimatta_sdio_driver/shimatta_sdio.c | 14 +++++++++---- main.c | 24 ++++++++++++---------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/fatfs/shimatta_sdio_driver/shimatta_sdio.c b/fatfs/shimatta_sdio_driver/shimatta_sdio.c index 8b4b7ab..a3f0c4e 100644 --- a/fatfs/shimatta_sdio_driver/shimatta_sdio.c +++ b/fatfs/shimatta_sdio_driver/shimatta_sdio.c @@ -179,6 +179,8 @@ void SDIO_init_hw(){ CLKPORT->MODER |= (2<MODER |= (2<PUPDR |= (1<MODER |= (2<PUPDR |= (1<MODER |= (2<PUPDR |= (1<AFR[(CLKPIN < 8 ? 0 : 1)] |= ALTFUNC << ((CLKPIN < 8 ? CLKPIN : (CLKPIN - 8)) * 4); SETAF(CLKPORT, CLKPIN, ALTFUNC); + SETAF(CMDPORT, CMDPIN, ALTFUNC); SETAF(D0PORT, D0PIN, ALTFUNC); #if BUSWIDTH==4 SETAF(D1PORT, D1PIN, ALTFUNC); @@ -245,12 +248,15 @@ int SDIO_send_cmd(uint8_t CMD, uint32_t arg, uint8_t expectedAns){ SDIO->ICR = SDIO_ICR_CCRCFAILC | SDIO_ICR_CMDRENDC | SDIO_ICR_CTIMEOUTC | SDIO_ICR_CMDSENTC; //Send command SDIO->ARG = arg; - SDIO->CMD = (CMD & SDIO_CMD_CMDINDEX) | SDIO_CMD_CPSMEN | SDIO_CMD_WAITPEND | ((expectedAns << 6) & SDIO_CMD_WAITRESP); + SDIO->CMD = (CMD & SDIO_CMD_CMDINDEX) | SDIO_CMD_CPSMEN | /*SDIO_CMD_WAITPEND |*/ ((expectedAns << 6) & SDIO_CMD_WAITRESP); return 0; } - +unsigned int debug; void SDIO_wait_cmd_sent() { - while (!(SDIO->STA & SDIO_STA_CMDSENT)); + while (!(SDIO->STA & SDIO_STA_CMDSENT)) + { + debug = SDIO->STA; + } SDIO->ICR |= SDIO_ICR_CMDSENTC; } @@ -361,7 +367,7 @@ int SDIO_send_relative_address_CMD3(uint16_t* rca) { } int SDIO_send_go_idle_CMD0() { - SDIO_send_cmd(0, 0, NO_ANS); + SDIO_send_cmd(0, 0x0, NO_ANS); SDIO_wait_cmd_sent(); return 0; } diff --git a/main.c b/main.c index 9d56d86..1385bf3 100644 --- a/main.c +++ b/main.c @@ -12,28 +12,30 @@ FATFS SDfs; FIL file; +volatile int w; + +void SDIO_wait_cmd_sent(); +int SDIO_switch_appmode_CMD55(); +int SDIO_send_all_send_cid_CMD2(); +int SDIO_send_relative_address_CMD3(uint16_t* rca); +int SDIO_send_go_idle_CMD0(); + +int SDIO_send_block_length_CMD16(uint32_t blocklen); +int SDIO_send_bus_width_ACMD6(uint8_t bus_width); -void test(char a, char b, char c, char d, char e,char f, char g, char h, char i, char j); -void gna(); int main() { RCC->AHB1ENR |= RCC_AHB1ENR_GPIODEN; __DSB(); - GPIOD->MODER = OUTPUT(12); + GPIOD->MODER |= OUTPUT(12); SysTick_Config(8*1680000); - f_mount(&SDfs, "0:/", 1); + // f_mount(&SDfs, "0:/", 1); while(1); } -void test(char a, char b, char c, char d, char e,char f, char g, char h, char i, char j) { - gna(); - //GPIOD->ODR ^= a+b+c+d+e+f+g+h+i+j; -} -void gna() { - GPIOD->ODR = 0; -} void SysTick_Handler() { GPIOD->ODR ^= (1<<12); + w++; }