mirror of
				https://github.com/rtlduino/RTL8710AF_GCC.git
				synced 2025-07-31 20:21:04 +00:00 
			
		
		
		
	rtlduino rtl8710af gcc base version
This commit is contained in:
		
							parent
							
								
									7675bdb95f
								
							
						
					
					
						commit
						9c0c9edf61
					
				
					 2097 changed files with 779974 additions and 2 deletions
				
			
		
							
								
								
									
										6
									
								
								component/common/file_system/fatfs/disk_if/inc/sdcard.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								component/common/file_system/fatfs/disk_if/inc/sdcard.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| #ifndef _SDCARD_H_ | ||||
| #define _SDCARD_H_ | ||||
| #include "fatfs_ext/inc/ff_driver.h" | ||||
| 
 | ||||
| extern ll_diskio_drv SD_disk_Driver; | ||||
| #endif | ||||
							
								
								
									
										8
									
								
								component/common/file_system/fatfs/disk_if/inc/usbdisk.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								component/common/file_system/fatfs/disk_if/inc/usbdisk.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,8 @@ | |||
| #ifndef _USBDISK_H_ | ||||
| #define _USBDISK_H_ | ||||
| 
 | ||||
| #include "fatfs_ext/inc/ff_driver.h" | ||||
| 
 | ||||
| extern ll_diskio_drv USB_disk_Driver; | ||||
| #endif | ||||
| 
 | ||||
							
								
								
									
										134
									
								
								component/common/file_system/fatfs/disk_if/src/sdcard.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										134
									
								
								component/common/file_system/fatfs/disk_if/src/sdcard.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,134 @@ | |||
| /*
 | ||||
|  *  Routines to associate SD card driver with FatFs | ||||
|  * | ||||
|  *  Copyright (c) 2014 Realtek Semiconductor Corp. | ||||
|  * | ||||
|  *  This module is a confidential and proprietary property of RealTek and | ||||
|  *  possession or use of this module requires written permission of RealTek. | ||||
|  */ | ||||
| #include "integer.h" | ||||
| #include <disk_if/inc/sdcard.h> | ||||
| 
 | ||||
| #if	FATFS_DISK_SD | ||||
| 
 | ||||
| #include "sd.h" // sd card driver with sdio interface | ||||
| 
 | ||||
| #define SD_BLOCK_SIZE	512 | ||||
| 
 | ||||
| static int interpret_sd_result(SD_RESULT result){ | ||||
| 	int ret = 0; | ||||
| 	if(result == SD_OK) | ||||
| 		ret = 0; | ||||
| 	else if(result == SD_NODISK) | ||||
| 		ret = STA_NODISK; | ||||
| 	else if(result == SD_INITERR) | ||||
| 		ret = STA_NOINIT; | ||||
| 	else if(result == SD_PROTECTED) | ||||
| 		ret = STA_PROTECT; | ||||
| 	return ret; | ||||
| } | ||||
| 
 | ||||
| DSTATUS SD_disk_status(void){ | ||||
| 	SD_RESULT res; | ||||
| 	res = SD_Status(); | ||||
| 	return interpret_sd_result(res);; | ||||
| } | ||||
| 
 | ||||
| DSTATUS SD_disk_initialize(void){ | ||||
| 	SD_RESULT res; | ||||
| 	res = SD_Init(); | ||||
| 	return interpret_sd_result(res); | ||||
| } | ||||
| 
 | ||||
| /* Read sector(s) --------------------------------------------*/ | ||||
| DRESULT SD_disk_read(BYTE *buff, DWORD sector, UINT count){ | ||||
| 	SD_RESULT res; | ||||
| 
 | ||||
| 	res = SD_ReadBlocks(sector, buff, count); | ||||
| 
 | ||||
| 	//__rtl_memDump_v1_00(buff, 512*count, "MMC_disk_read:");
 | ||||
| 	 | ||||
| 	return interpret_sd_result(res); | ||||
| } | ||||
| 
 | ||||
| /* Write sector(s) --------------------------------------------*/ | ||||
| #if _USE_WRITE == 1 | ||||
| DRESULT SD_disk_write(const BYTE *buff, DWORD sector, UINT count){ | ||||
| 	SD_RESULT res; | ||||
| 
 | ||||
| 	res = SD_WriteBlocks(sector, buff, count); | ||||
| 	 | ||||
| 	return interpret_sd_result(res); | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| /* Write sector(s) --------------------------------------------*/ | ||||
| #if _USE_IOCTL == 1 | ||||
| DRESULT SD_disk_ioctl (BYTE cmd, void* buff){ | ||||
| 	DRESULT res = RES_ERROR; | ||||
| 	SD_RESULT result; | ||||
| 	DWORD last_blk_addr, block_size; | ||||
| 
 | ||||
| 	switch(cmd){ | ||||
| 		/* Generic command (used by FatFs) */ | ||||
| 		 | ||||
| 		/* Make sure that no pending write process in the physical drive */ | ||||
| 		case CTRL_SYNC:		/* Flush disk cache (for write functions) */ | ||||
| 			result = SD_WaitReady(); | ||||
| 			res = interpret_sd_result(result); | ||||
| 			break; | ||||
| 		case GET_SECTOR_COUNT:	/* Get media size (for only f_mkfs()) */ | ||||
| 			result = SD_GetCapacity((unsigned long*) buff); | ||||
| 			res = interpret_sd_result(result); | ||||
| 			break; | ||||
| 		/* for case _MAX_SS != _MIN_SS */ | ||||
| 		case GET_SECTOR_SIZE:	/* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ | ||||
| 			//*(DWORD*)buff = 1024;//2048;//4096;
 | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case GET_BLOCK_SIZE:	/* Get erase block size (for only f_mkfs()) */ | ||||
| 			*(DWORD*)buff = SD_BLOCK_SIZE; | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case CTRL_ERASE_SECTOR:/* Force erased a block of sectors (for only _USE_ERASE) */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 
 | ||||
| 		/* MMC/SDC specific ioctl command */ | ||||
| 
 | ||||
| 		case MMC_GET_TYPE:	/* Get card type */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case MMC_GET_CSD:	/* Get CSD */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case MMC_GET_CID:	/* Get CID */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case MMC_GET_OCR:	/* Get OCR */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case MMC_GET_SDSTAT:/* Get SD status */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		default: | ||||
| 			res = RES_PARERR; | ||||
| 			break; | ||||
| 	} | ||||
| 	return res; | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| ll_diskio_drv SD_disk_Driver ={ | ||||
| 	.disk_initialize = SD_disk_initialize, | ||||
| 	.disk_status = SD_disk_status, | ||||
| 	.disk_read = SD_disk_read, | ||||
| #if _USE_WRITE == 1 | ||||
| 	.disk_write = SD_disk_write, | ||||
| #endif | ||||
| #if _USE_IOCTL == 1 | ||||
| 	.disk_ioctl = SD_disk_ioctl, | ||||
| #endif | ||||
| 	.TAG	= "SD" | ||||
| }; | ||||
| #endif | ||||
							
								
								
									
										122
									
								
								component/common/file_system/fatfs/disk_if/src/usbdisk.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										122
									
								
								component/common/file_system/fatfs/disk_if/src/usbdisk.c
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,122 @@ | |||
| /*
 | ||||
|  *  Routines to associate usb mass storage driver with FatFs | ||||
|  * | ||||
|  *  Copyright (c) 2014 Realtek Semiconductor Corp. | ||||
|  * | ||||
|  *  This module is a confidential and proprietary property of RealTek and | ||||
|  *  possession or use of this module requires written permission of RealTek. | ||||
|  */ | ||||
| #include "integer.h" | ||||
| #include <disk_if/inc/usbdisk.h> | ||||
| 
 | ||||
| #if FATFS_DISK_USB | ||||
| #include "us_intf.h" | ||||
| 
 | ||||
| DSTATUS USB_disk_status(void){ | ||||
| 	MSC_RESULT res; | ||||
| 	if(USB_STORAGE_READY){ | ||||
| 		res = us_getStatus(); | ||||
| 		if(res == MSC_W_PROTECT) | ||||
| 			return STA_PROTECT; | ||||
| 		else | ||||
| 			return 0; // every thing is ok
 | ||||
| 	} | ||||
| 	return STA_NOINIT; | ||||
| } | ||||
| 
 | ||||
| DSTATUS USB_disk_initialize(void){ | ||||
| 	MSC_RESULT res; | ||||
| 
 | ||||
| 	if(USB_STORAGE_READY) | ||||
| 		return 0; | ||||
| 	 | ||||
| 	res = us_init(); | ||||
| 
 | ||||
| 	if(res == MSC_OK) | ||||
| 		return 0; | ||||
| 	else  | ||||
| 		return STA_NOINIT; | ||||
| } | ||||
| 
 | ||||
| /* Read sector(s) --------------------------------------------*/ | ||||
| DRESULT USB_disk_read(BYTE *buff, DWORD sector, UINT count){ | ||||
| 	if(!USB_STORAGE_READY) | ||||
| 		return RES_NOTRDY; | ||||
| 	 | ||||
| 	if(us_read_blocks(buff, sector, count) == MSC_OK) | ||||
| 		return RES_OK; | ||||
| 	else | ||||
| 		return RES_ERROR; | ||||
| } | ||||
| 
 | ||||
| /* Write sector(s) --------------------------------------------*/ | ||||
| #if _USE_WRITE == 1 | ||||
| DRESULT USB_disk_write(const BYTE *buff, DWORD sector, UINT count){ | ||||
| 	if(!USB_STORAGE_READY) | ||||
| 		return RES_NOTRDY; | ||||
| 	 | ||||
| 	if(us_write_blocks(buff, sector, count) == MSC_OK) | ||||
| 		return RES_OK; | ||||
| 	else | ||||
| 		return RES_ERROR; | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| /* Write sector(s) --------------------------------------------*/ | ||||
| #if _USE_IOCTL == 1 | ||||
| DRESULT USB_disk_ioctl (BYTE cmd, void* buff){ | ||||
| 	DRESULT res = RES_ERROR; | ||||
| 	DWORD last_blk_addr, block_size; | ||||
| 
 | ||||
| 	if(!USB_STORAGE_READY) | ||||
| 		return RES_NOTRDY; | ||||
| 	 | ||||
| 	switch(cmd){ | ||||
| 		/* Generic command (used by FatFs) */ | ||||
| 
 | ||||
| 		case CTRL_SYNC:		/* Flush disk cache (for write functions) */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case GET_SECTOR_COUNT:	/* Get media size (for only f_mkfs()) */ | ||||
| 			if(us_getcap(&last_blk_addr, &block_size) == MSC_OK){ | ||||
| 				*(DWORD*)buff = last_blk_addr + 1; | ||||
| 				res = RES_OK; | ||||
| 			}else | ||||
| 				res = RES_ERROR; | ||||
| 			break; | ||||
| 		case GET_SECTOR_SIZE:	/* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ | ||||
| 			if(us_getcap(&last_blk_addr, &block_size) == MSC_OK){ | ||||
| 				*(DWORD*)buff = block_size; | ||||
| 				res = RES_OK; | ||||
| 			}else | ||||
| 				res = RES_ERROR; | ||||
| 			break; | ||||
| 		case GET_BLOCK_SIZE:	/* Get erase block size (for only f_mkfs()) */ | ||||
| 			*(DWORD*)buff = 512; | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		case CTRL_ERASE_SECTOR:/* Force erased a block of sectors (for only _USE_ERASE) */ | ||||
| 			res = RES_OK; | ||||
| 			break; | ||||
| 		default: | ||||
| 			res = RES_PARERR; | ||||
| 			break; | ||||
| 	} | ||||
| 	return res; | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| ll_diskio_drv USB_disk_Driver ={ | ||||
| 	.disk_initialize = USB_disk_initialize, | ||||
| 	.disk_status = USB_disk_status, | ||||
| 	.disk_read = USB_disk_read, | ||||
| #if _USE_WRITE == 1 | ||||
| 	.disk_write = USB_disk_write, | ||||
| #endif | ||||
| #if _USE_IOCTL == 1 | ||||
| 	.disk_ioctl = USB_disk_ioctl, | ||||
| #endif | ||||
| 	.TAG = "USB" | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue