removed WAITPEND from CMD init, Module is able to send commands. Ready to test SD Card
This commit is contained in:
@@ -179,6 +179,8 @@ void SDIO_init_hw(){
|
||||
CLKPORT->MODER |= (2<<CLKPIN*2);
|
||||
D0PORT->MODER |= (2<<D0PIN*2);
|
||||
D0PORT->PUPDR |= (1<<D0PIN*2);
|
||||
CMDPORT->MODER |= (2<<CMDPIN*2);
|
||||
CMDPORT->PUPDR |= (1<<CMDPIN*2);
|
||||
#if BUSWIDTH==4
|
||||
D1PORT->MODER |= (2<<D1PIN*2);
|
||||
D1PORT->PUPDR |= (1<<D1PIN*2);
|
||||
@@ -189,6 +191,7 @@ void SDIO_init_hw(){
|
||||
#endif
|
||||
//CLKPORT->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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user