23 #define SECTOR_SIZE 512 // sector size in bytes
46 NVIC_InitTypeDef NVIC_InitStructure;
47 NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
48 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
49 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
50 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
51 NVIC_Init( &NVIC_InitStructure );
53 NVIC_InitStructure.NVIC_IRQChannel = SD_SDIO_DMA_IRQn;
54 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
55 NVIC_Init( &NVIC_InitStructure );
72 if ( drv )
return STA_NOINIT;
94 __IO SDTransferState Status = SD_TRANSFER_OK;
97 if ( SD_WaitReadOperation() == SD_OK )
102 Status = SD_GetStatus();
104 while ( Status == SD_TRANSFER_BUSY );
106 if ( Status == SD_TRANSFER_OK )
145 __IO SDTransferState Status = SD_TRANSFER_OK;
148 if ( SD_WaitReadOperation() == SD_OK )
153 Status = SD_GetStatus();
155 while ( Status == SD_TRANSFER_BUSY );
157 if ( Status == SD_TRANSFER_OK )
204 dw = (( ( u32 )( year + 2000 - 1980) << 25 )
205 | ( u32 )( month << 21 )
206 | ( u32 )( day << 16 )
207 | ( u32 )( hours << 11 )
208 | ( u32 )( min << 5 )
209 | ( u32 )( sec >> 1 ));
217 uint32_t temp_block_mul = 0;
219 uint32_t DeviceSizeMul = 0;
222 if ( SD_GetStatus() != 0 )
235 SD_GetCSDRegister( &SD_csd );
236 DeviceSizeMul = SD_csd.DeviceSizeMul + 2;
237 temp_block_mul = ( 1 << SD_csd.RdBlockLen ) / 512;
238 *block_num = ( ( SD_csd.DeviceSize + 1 ) * ( 1 << ( DeviceSizeMul ) ) ) * temp_block_mul;
258 DRESULT res = RES_OK;
263 case GET_SECTOR_COUNT :
268 case GET_SECTOR_SIZE :
273 case GET_BLOCK_SIZE :
274 *( DWORD* )buff = 32;
298 case SD_WRITE_PROT_VIOLATION:
301 case SD_NOT_CONFIGURED:
304 case SD_INVALID_PARAMETER: