Bläddra i källkod

fix:修复i2c悬空发送时卡主问题

Dozingfiretruck 3 år sedan
förälder
incheckning
c416de3e77

+ 1 - 1
app/port/luat_i2c_air101.c

@@ -7,7 +7,7 @@
 #include <string.h>
 #include "wm_gpio_afsel.h"
 
-#define LUAT_LOG_TAG "luat.i2c"
+#define LUAT_LOG_TAG "i2c"
 #include "luat_log.h"
 
 int luat_i2c_exist(int id) {

+ 8 - 4
platform/drivers/gpio/wm_gpio_afsel.c

@@ -807,13 +807,15 @@ void wm_i2c_scl_config(enum tls_io_name io_name)
     switch(io_name)
     {
     case WM_IO_PA_01:
-        tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
+        // tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
         tls_io_cfg_set(io_name, WM_IO_OPTION2);
+        tls_bitband_write(HR_GPIOA_DATA_PULLEN,1, 0);
         break;
 
     case WM_IO_PB_20:
-        tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
+        // tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
         tls_io_cfg_set(io_name, WM_IO_OPTION4);
+        tls_bitband_write(HR_GPIOB_DATA_PULLEN,20, 0);
         break;
 
     default:
@@ -828,13 +830,15 @@ void wm_i2c_sda_config(enum tls_io_name io_name)
     switch(io_name)
     {
     case WM_IO_PA_04:
-        tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
+        // tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
         tls_io_cfg_set(io_name, WM_IO_OPTION2);
+        tls_bitband_write(HR_GPIOA_DATA_PULLEN,4, 0);
         break;
 
     case WM_IO_PB_19:
-        tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
+        // tls_gpio_cfg(io_name, WM_GPIO_DIR_OUTPUT, WM_GPIO_ATTR_PULLHIGH);
         tls_io_cfg_set(io_name, WM_IO_OPTION4);
+        tls_bitband_write(HR_GPIOB_DATA_PULLEN,19, 0);
         break;
 
     default:

+ 2 - 2
platform/drivers/i2c/wm_i2c.c

@@ -142,11 +142,11 @@ void tls_i2c_init(u32 freq)
 	u32 div = 0;
 	tls_sys_clk clk;
 	
-	if (freq < I2C_FREQ_MIN)
+	if (freq <= I2C_FREQ_MIN)
 	{
 		freq = I2C_FREQ_MIN;
 	}		
-	else if (freq > I2C_FREQ_MAX)
+	else if (freq >= I2C_FREQ_MAX)
 	{
 		freq = I2C_FREQ_MAX;
 	}

+ 152 - 168
platform/drivers/internalflash/wm_internal_fls.c

@@ -346,160 +346,6 @@ static unsigned int getFlashDensity(void)
     return 0;
 }
 
-/*sr start*/
-/************************************************************
-addr:
-For GD,		      address:0x000,0x100
-For ESMT,		address:0xFF000,0xFF100
-For WINBOND,	address:0x1000
-*************************************************************/
-int readSR(unsigned int cmd, unsigned long addr, unsigned char *buf, unsigned long sz)
-{
-    int i = 0;
-    int word = sz / 4;
-    int byte = sz % 4;
-    unsigned long addr_read;
-
-    M32(HR_FLASH_CMD_ADDR) = cmd | (((sz - 1) & 0x3FF) << 16);
-    M32(HR_FLASH_ADDR) = addr & 0x1FFFFFF;
-    M32(HR_FLASH_CMD_START) = CMD_START_Msk;
-
-    addr_read = RSA_BASE_ADDRESS;
-    for(i = 0; i < word; i ++)
-    {
-        M32(buf) = M32(addr_read);
-        buf += 4;
-        addr_read += 4;
-    }
-
-    if(byte > 0)
-    {
-        M32(buf) = M32(addr_read);
-        buf += 3;							//point last byte
-        while(byte)
-        {
-            *buf = 0;
-            buf --;
-            byte --;
-        }
-    }
-
-    return 0;
-}
-
-void flashSRRW(unsigned long offset, unsigned char *buf, unsigned long sz, unsigned char *backbuf, unsigned int backlen, unsigned int rd)
-{
-#define SR_TOTAL_SZ (512)
-#define SR_PROGRAM_SZE (256)
-    unsigned int i;
-    unsigned int j;
-    unsigned int baseaddr = 0;
-    unsigned int sectoroffset = 0;
-    unsigned int sectorsize = 0;
-    unsigned int sectornum = 0;
-    unsigned int remainsz;
-    unsigned int erasecmd = 0;
-    unsigned int readcmd  = 0;
-    unsigned int writecmd = 0;
-
-    unsigned char flashid = 0;
-    if (!buf || ((rd == 0) && ( !backbuf || (backlen < 512))))
-    {
-        return;
-    }
-
-    flashid = readRID();
-    switch(flashid)
-    {
-    case SPIFLASH_MID_GD:
-        baseaddr = 0x0;
-        sectoroffset = 256;
-        sectorsize = 256;
-        sectornum = 2;
-        erasecmd	 = 0x80000844;
-        readcmd 	 = 0xBC00C048;
-        writecmd	 = 0x80009042;
-        break;
-
-    case SPIFLASH_MID_ESMT:
-    {
-        baseaddr = 0xFF000;
-        sectoroffset = 0;
-        sectorsize = 512;
-        sectornum = 1;
-        erasecmd	 = 0x80000820;
-        readcmd 	 = 0xBC00C00B;
-        writecmd	 = 0x80009002;
-
-        M32(HR_FLASH_CMD_ADDR) = 0x3A;             /*enter OTP*/
-        M32(HR_FLASH_CMD_START) = CMD_START_Msk;
-    }
-    break;
-
-    case SPIFLASH_MID_PUYA:
-        baseaddr = 0x1000;
-        sectoroffset = 0;
-        sectorsize = 512;
-        sectornum = 1;
-        erasecmd	 = 0x80000844;
-        readcmd 	 = 0xBC00C048;
-        writecmd	 = 0x80009042;
-
-        break;
-
-    default:
-    {
-    }
-    break;
-    }
-
-    for (i = 0 ; i < sectornum; i++)
-    {
-        readSR(readcmd, baseaddr + sectoroffset * i, backbuf + i * sectorsize, sectorsize);
-    }
-
-    if (rd)
-    {
-        for(i = 0; i < sz; i++)				//Copy
-        {
-            buf[i] = backbuf[i + offset];
-        }
-    }
-    else
-    {
-        for (i = 0; i < sectornum ; i++)
-        {
-            eraseSR(erasecmd, baseaddr + sectoroffset * i);
-        }
-
-        remainsz = (sz < (SR_TOTAL_SZ - offset)) ? sz : (SR_TOTAL_SZ - offset);
-        for(i = 0; i < remainsz; i++)
-        {
-            backbuf[i + offset] = buf[i];
-        }
-
-        for ( i = 0; i < sectornum; i++)
-        {
-            for (j = 0; j < (sectorsize / SR_PROGRAM_SZE); j++)
-            {
-                programSR(writecmd, baseaddr + sectoroffset * i + j * SR_PROGRAM_SZE,  backbuf, SR_PROGRAM_SZE);
-                backbuf += SR_PROGRAM_SZE;
-            }
-        }
-    }
-
-
-
-    if (SPIFLASH_MID_ESMT == flashid)
-    {
-        /*Write Disable*/
-        M32(HR_FLASH_CMD_ADDR) = 0x4;
-        M32(HR_FLASH_CMD_START) = CMD_START_Msk;
-    }
-}
-
-/*sr end*/
-
 int __readByCMD(unsigned char cmd, unsigned long addr, unsigned char *buf, unsigned long sz)
 {
     int i = 0;
@@ -601,6 +447,17 @@ int readByCMD(unsigned char cmd, unsigned long addr, unsigned char *buf, unsigne
     return TLS_FLS_STATUS_OK;
 }
 
+int config_flash_decrypt_param(uint32_t code_decrypt, uint32_t dbus_decrypt, uint32_t data_decrypt)
+{
+	FLASH_ENCRYPT_CTRL_Type encrypt_ctrl;
+	encrypt_ctrl.w = M32(HR_FLASH_ENCRYPT_CTRL);
+	encrypt_ctrl.b.code_decrypt = code_decrypt;
+	encrypt_ctrl.b.dbus_decrypt = dbus_decrypt;
+	encrypt_ctrl.b.data_decrypt = data_decrypt;
+	M32(HR_FLASH_ENCRYPT_CTRL) = encrypt_ctrl.w;
+	return 0;
+}
+
 int flashRead(unsigned long addr, unsigned char *buf, unsigned long sz)
 {
 #define INSIDE_FLS_MAX_RD_SIZE (1024)
@@ -691,14 +548,19 @@ int flashRead(unsigned long addr, unsigned char *buf, unsigned long sz)
  *
  * @param	   None
  *
- * @return         None
+ * @return         0-success,non-zero-failure
  *
  * @note           None
  */
 int tls_flash_unlock(void)
 {
+	int ret = 0;
+    if (inside_fls == NULL)
+    {
+        return TLS_FLS_STATUS_EPERM;
+    }
     // return flashunlock();
-    return 0;
+    return ret;
 }
 
 /**
@@ -706,14 +568,19 @@ int tls_flash_unlock(void)
  *
  * @param	   None
  *
- * @return         None
+ * @return        0-success,non-zero-failure
  *
  * @note           None
  */
 int tls_flash_lock(void)
 {
+    	int ret = 0;
+    if (inside_fls == NULL)
+    {
+        return TLS_FLS_STATUS_EPERM;
+    }
     // return flashlock();
-    return 0;
+    return ret;
 }
 
 
@@ -777,6 +644,10 @@ int tls_fls_read_unique_id(unsigned  char *uuid)
 	unsigned char rid;
 	int word;
 	int byte;
+    if (inside_fls == NULL)
+    {
+    	return TLS_FLS_STATUS_EPERM;
+    }
 
 	memset(uuid, 0xFF, 18);
 	rid = readRID();
@@ -785,6 +656,7 @@ int tls_fls_read_unique_id(unsigned  char *uuid)
 		case SPIFLASH_MID_GD:
 		case SPIFLASH_MID_PUYA:
 		case SPIFLASH_MID_TSINGTENG:
+		case SPIFLASH_MID_TSINGTENG_1MB_4MB:
 			dumy_bytes = 4;
 			uni_bytes = 16;
 			break;
@@ -911,7 +783,7 @@ int tls_fls_otp_write(u32 addr, u8 *buf, u32 len)
 	uint32_t eraseAddr = 0;
 	uint16_t eraseSize = 0;
 	uint16_t pageSize = 0;
-	unsigned char flashid = 0;
+
 	int l = 0;
 	unsigned char *backbuf = NULL;
 	unsigned long size = 0;
@@ -993,6 +865,9 @@ int tls_fls_otp_lock(void)
 	case SPIFLASH_MID_TSINGTENG:
 		writeLbBit_for_1wreg((1<<10));
 		break;
+	case SPIFLASH_MID_TSINGTENG_1MB_4MB:
+		writeLbBit_for_1wreg((7<<11));
+		break;
 	case SPIFLASH_MID_FUDANMICRO:
 		writeLbBit_for_2wreg((1<<10));
 		break;
@@ -1033,7 +908,7 @@ int tls_fls_read(u32 addr, u8 *buf, u32 len)
         return TLS_FLS_STATUS_EPERM;
     }
 
-    if (((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  getFlashDensity()) || (len == 0) || (buf == NULL))
+    if (((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  inside_fls->density) || (len == 0) || (buf == NULL))
     {
         return TLS_FLS_STATUS_EINVAL;
     }
@@ -1077,7 +952,7 @@ int tls_fls_write(u32 addr, u8 *buf, u32 len)
         return TLS_FLS_STATUS_EPERM;
     }
 
-    if (((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  getFlashDensity()) || (len == 0) || (buf == NULL))
+    if (((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  inside_fls->density) || (len == 0) || (buf == NULL))
     {
         return TLS_FLS_STATUS_EINVAL;
     }
@@ -1124,9 +999,13 @@ int tls_fls_write(u32 addr, u8 *buf, u32 len)
             buf += secremain;   // 指针偏移
             len -= secremain;
             if(len > (INSIDE_FLS_SECTOR_SIZE))
+            {
                 secremain = INSIDE_FLS_SECTOR_SIZE; // 下一个扇区还是写不完
+            }
             else
+            {
                 secremain = len;					//Next section will finish
+            }
         }
     }
 
@@ -1135,6 +1014,96 @@ int tls_fls_write(u32 addr, u8 *buf, u32 len)
     return TLS_FLS_STATUS_OK;
 }
 
+/**
+ * @brief          This function is used to write data into the flash without erase.
+ *
+ * @param[in]      addr     Specifies the starting address to write to
+ * @param[in]      buf      Pointer to a byte array that is to be written
+ * @param[in]      len      Specifies the length of the data to be written
+ *
+ * @retval         TLS_FLS_STATUS_OK	        if write flash success
+ * @retval         TLS_FLS_STATUS_EPERM	        if flash struct point is null
+ * @retval         TLS_FLS_STATUS_ENODRV	    if flash driver is not installed
+ * @retval         TLS_FLS_STATUS_EINVAL	    if argument is invalid
+ *
+ * @note           Erase action should be excuted by API tls_fls_erase in user layer.
+ */
+int tls_fls_write_without_erase(u32 addr, u8 *buf, u32 len)
+{
+    u8 *cache;
+    unsigned int pagepos;
+    unsigned int pageoff;
+    unsigned int pageremain;
+    unsigned int i;
+    unsigned int offaddr;
+
+    if (inside_fls == NULL)
+    {
+        TLS_DBGPRT_ERR("flash driver module not beed installed!\n");
+        return TLS_FLS_STATUS_EPERM;
+    }
+
+    if (((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  inside_fls->density) || (len == 0) || (buf == NULL))
+    {
+        return TLS_FLS_STATUS_EINVAL;
+    }
+
+    tls_os_sem_acquire(inside_fls->fls_lock, 0);
+
+    cache = tls_mem_alloc(INSIDE_FLS_PAGE_SIZE);
+    if (cache == NULL)
+    {
+        tls_os_sem_release(inside_fls->fls_lock);
+        TLS_DBGPRT_ERR("allocate page cache memory fail!\n");
+        return TLS_FLS_STATUS_ENOMEM;
+    }
+
+    offaddr = addr & (INSIDE_FLS_BASE_ADDR - 1);	//Offset of 0X08000000
+    pagepos = offaddr / INSIDE_FLS_PAGE_SIZE;		//Page addr
+    pageoff = (offaddr % INSIDE_FLS_PAGE_SIZE);		//Offset in page
+    pageremain = INSIDE_FLS_PAGE_SIZE - pageoff;    // size remained in one page
+    if(len <= pageremain)
+    {
+        pageremain = len;							//Not bigger with remain size in one page
+    }
+
+	flashRead(pagepos * INSIDE_FLS_PAGE_SIZE, cache, INSIDE_FLS_PAGE_SIZE);
+    while (1)
+    {
+        for (i = 0; i < pageremain; i++)
+        {
+            cache[i + pageoff] = buf[i];
+        }
+
+        programPage(pagepos * INSIDE_FLS_PAGE_SIZE, INSIDE_FLS_PAGE_SIZE, &cache[0]); //Write
+        if(len == pageremain)// page program over
+        {
+            break;              
+        }
+        else                    
+        {
+            pagepos++;           // next page
+            pageoff = 0;         // page offset set to zero
+            buf += pageremain;   // buffer modified 
+            len -= pageremain;   // len decrease
+            if(len > (INSIDE_FLS_PAGE_SIZE))
+            {
+                pageremain = INSIDE_FLS_PAGE_SIZE; // size next to write
+            }
+            else
+            {
+                pageremain = len;					//last data to write
+               	flashRead(pagepos * INSIDE_FLS_PAGE_SIZE, cache, INSIDE_FLS_PAGE_SIZE);
+            }
+        }
+    }
+
+    tls_mem_free(cache);
+    tls_os_sem_release(inside_fls->fls_lock);
+    return TLS_FLS_STATUS_OK;
+}
+
+
 /**
  * @brief          	This function is used to erase the appoint sector
  *
@@ -1154,7 +1123,7 @@ int tls_fls_erase(u32 sector)
         return TLS_FLS_STATUS_EPERM;
     }
 
-    if (sector >= (getFlashDensity() / INSIDE_FLS_SECTOR_SIZE + INSIDE_FLS_BASE_ADDR / INSIDE_FLS_SECTOR_SIZE))
+    if (sector >= (inside_fls->density / INSIDE_FLS_SECTOR_SIZE + INSIDE_FLS_BASE_ADDR / INSIDE_FLS_SECTOR_SIZE))
     {
         TLS_DBGPRT_ERR("the sector to be erase overflow!\n");
         return TLS_FLS_STATUS_EINVAL;
@@ -1190,7 +1159,7 @@ static void tls_fls_flush_sector(void)
 {
     int i;
     u32 addr;
-    if (gsSector < (getFlashDensity() / INSIDE_FLS_SECTOR_SIZE + INSIDE_FLS_BASE_ADDR / INSIDE_FLS_SECTOR_SIZE))
+    if (gsSector < (inside_fls->density / INSIDE_FLS_SECTOR_SIZE + INSIDE_FLS_BASE_ADDR / INSIDE_FLS_SECTOR_SIZE))
     {
         addr = gsSector * INSIDE_FLS_SECTOR_SIZE;
 
@@ -1259,7 +1228,7 @@ void tls_fls_fast_write_destroy(void)
         else
         {
             tls_os_sem_acquire(inside_fls->fls_lock, 0);
-        tls_fls_flush_sector();
+        	tls_fls_flush_sector();
             tls_os_sem_release(inside_fls->fls_lock);
         }
 
@@ -1290,7 +1259,7 @@ int tls_fls_fast_write(u32 addr, u8 *buf, u32 length)
         TLS_DBGPRT_ERR("flash driver module not beed installed!\n");
         return TLS_FLS_STATUS_EPERM;
     }
-    if(((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  getFlashDensity()) || (length == 0) || (buf == NULL))
+    if(((addr & (INSIDE_FLS_BASE_ADDR - 1)) >=  inside_fls->density) || (length == 0) || (buf == NULL))
     {
         return TLS_FLS_STATUS_EINVAL;
     }
@@ -1363,7 +1332,7 @@ int tls_fls_chip_erase(void)
     }
 
 
-    for( i = 0; i < ( getFlashDensity() - (INSIDE_FLS_SECBOOT_ADDR & 0xFFFFF)) / INSIDE_FLS_SECTOR_SIZE; i ++)
+    for( i = 0; i < ( inside_fls->density - (INSIDE_FLS_SECBOOT_ADDR & 0xFFFFF)) / INSIDE_FLS_SECTOR_SIZE; i ++)
     {
         flashRead(INSIDE_FLS_SECBOOT_ADDR + i * INSIDE_FLS_SECTOR_SIZE, cache, INSIDE_FLS_SECTOR_SIZE);
         for (j = 0; j < INSIDE_FLS_SECTOR_SIZE; j++)
@@ -1419,7 +1388,7 @@ int tls_fls_get_param(u8 type, void *param)
         break;
 
     case TLS_FLS_PARAM_TYPE_SIZE:
-        *((u32 *) param) = getFlashDensity();
+        *((u32 *) param) = inside_fls->density;
         break;
 
     case TLS_FLS_PARAM_TYPE_PAGE_SIZE:
@@ -1480,11 +1449,25 @@ int tls_fls_init(void)
         return TLS_FLS_STATUS_ENOMEM;
     }
 	fls->flashid = readRID();
-	// printf("flashid %x\n", fls->flashid);
+	//printf("flashid %x\n", fls->flashid);
 	fls->density = getFlashDensity();
 	fls->OTPWRParam.pageSize = 256;
 	switch(fls->flashid)
 	{
+	case SPIFLASH_MID_TSINGTENG_1MB_4MB:
+		if (fls->density == 0x100000)
+		{
+			fls->OTPWRParam.eraseSize = 1024;
+		}
+		else if (fls->density == 0x400000)
+		{
+			fls->OTPWRParam.eraseSize = 2048;
+		}
+		else
+		{
+			fls->OTPWRParam.eraseSize = 256;
+		}
+		break;	
 	case SPIFLASH_MID_GD:
 		fls->OTPWRParam.eraseSize = 1024;
 		break;
@@ -1547,6 +1530,7 @@ void tls_fls_sys_param_postion_init(void)
         TLS_FLASH_PARAM2_ADDR 		  =	(FLASH_BASE_ADDR|density) - 0x3000;
         TLS_FLASH_PARAM1_ADDR 		  =	(FLASH_BASE_ADDR|density) - 0x4000;
         TLS_FLASH_PARAM_DEFAULT	      =	(FLASH_BASE_ADDR|density) - 0x5000;
+        TLS_FLASH_MESH_PARAM_ADDR     = (FLASH_BASE_ADDR|density) - 0x6000;
     }
     else
     {

+ 1 - 1
platform/drivers/uart/wm_uart.c

@@ -591,7 +591,7 @@ ATTRIBUTE_ISR void UART0_IRQHandler(void)
                 if (TLS_UART_FLOW_CTRL_HARDWARE == port->fcStatus)
                 {
                     tls_set_uart_rx_status(port->uart_no, TLS_UART_RX_DISABLE);
-                    rx_fifocnt = 0; // 锟斤拷锟斤拷锟接诧拷锟斤拷锟斤拷兀锟斤拷乇战锟斤拷眨锟斤拷锟斤拷锟斤拷一锟斤拷锟街凤拷锟脚斤拷锟斤拷锟斤拷buffer锟斤拷
+                    rx_fifocnt = 0; // 如果有硬件流控,关闭接收,把最后一个字符放进环形buffer中
                 }
                 else
                     break;

+ 2 - 2
platform/sys/wm_main.c

@@ -88,7 +88,7 @@ void _mutex_release (u32 *mutex)
 
 #endif
 
-#define     TASK_START_STK_SIZE         640     /* Size of each task's stacks (# of WORDs)  */
+#define     TASK_START_STK_SIZE         768     /* Size of each task's stacks (# of WORDs)  */
 /*If you want to delete main task after it works, you can open this MACRO below*/
 #define MAIN_TASK_DELETE_AFTER_START_FTR  1
 
@@ -97,7 +97,7 @@ tls_os_task_t tststarthdl = NULL;
 
 #define FW_MAJOR_VER           0x1
 #define FW_MINOR_VER           0x0
-#define FW_PATCH_VER           0x2
+#define FW_PATCH_VER           0x10
 
 const char FirmWareVer[4] =
 {

+ 114 - 2
src/app/fatfs/diskio.c

@@ -11,9 +11,9 @@
 #include "diskio.h"		/* Declarations of disk functions */
 
 /* Definitions of physical drive number for each drive */
-// #define DEV_RAM		1	/* Example: Map Ramdisk to physical drive 0 */
+#define DEV_RAM		1	/* Example: Map Ramdisk to physical drive 0 */
 #define DEV_MMC		0	/* Example: Map MMC/SD card to physical drive 1 */
-// #define DEV_USB		2	/* Example: Map USB MSD to physical drive 2 */
+#define DEV_USB		2	/* Example: Map USB MSD to physical drive 2 */
 
 
 /*-----------------------------------------------------------------------*/
@@ -32,11 +32,26 @@ extern int wm_sd_card_set_blocklen(uint32_t blocklen);
 static uint32_t fs_rca;
 
 
+static int RAM_disk_status(void)
+{
+	return 0;
+}
+
 static int MMC_disk_status(void)
 {
 	return 0;
 }
 
+static int USB_disk_status(void)
+{
+	return 0;
+}
+
+static int RAM_disk_initialize(void)
+{
+	return 0;
+}
+
 static int MMC_disk_initialize(void)
 {
 	int ret;
@@ -54,6 +69,16 @@ end:
 	return ret;
 }
 
+static int USB_disk_initialize(void)
+{
+	return 0;
+}
+
+static int RAM_disk_read(	BYTE *buff, LBA_t sector, UINT count)
+{
+	return 0;
+}
+
 static int MMC_disk_read(	BYTE *buff, LBA_t sector, UINT count)
 {
 	int ret, i;
@@ -95,6 +120,16 @@ static int MMC_disk_read(	BYTE *buff, LBA_t sector, UINT count)
 	return ret;
 }
 
+static int USB_disk_read(	BYTE *buff, LBA_t sector, UINT count)
+{
+	return 0;
+}
+
+static int RAM_disk_write(	BYTE *buff, LBA_t sector, UINT count)
+{
+	return 0;
+}
+
 static int MMC_disk_write(	BYTE *buff, LBA_t sector, UINT count)
 {
 	int ret, i;
@@ -135,6 +170,11 @@ static int MMC_disk_write(	BYTE *buff, LBA_t sector, UINT count)
 	return ret;
 }
 
+static int USB_disk_write(	BYTE *buff, LBA_t sector, UINT count)
+{
+	return 0;
+}
+
 /*-----------------------------------------------------------------------*/
 /* adaptor layer end                                                      */
 /*-----------------------------------------------------------------------*/
@@ -151,6 +191,12 @@ DSTATUS disk_status (
 	DSTATUS stat = STA_NOINIT;
 
 	switch (pdrv) {
+	case DEV_RAM :
+		RAM_disk_status();
+
+		// translate the reslut code here
+
+		return stat;
 
 	case DEV_MMC :
 		MMC_disk_status();
@@ -158,6 +204,13 @@ DSTATUS disk_status (
 		// translate the reslut code here
 		stat &= ~STA_NOINIT;
 
+		return stat;
+
+	case DEV_USB :
+		USB_disk_status();
+
+		// translate the reslut code here
+
 		return stat;
 	}
 	return STA_NOINIT;
@@ -177,12 +230,26 @@ DSTATUS disk_initialize (
 	int result;
 
 	switch (pdrv) {
+	case DEV_RAM :
+		result = RAM_disk_initialize();
+
+		// translate the reslut code here
+
+		return stat;
+
 	case DEV_MMC :
 		result = MMC_disk_initialize();
 
 		// translate the reslut code here
 		(result == 0)?(stat &= ~STA_NOINIT):(stat = STA_NOINIT);
 
+		return stat;
+
+	case DEV_USB :
+		result = USB_disk_initialize();
+
+		// translate the reslut code here
+
 		return stat;
 	}
 	return STA_NOINIT;
@@ -205,6 +272,14 @@ DRESULT disk_read (
 	int result;
 
 	switch (pdrv) {
+	case DEV_RAM :
+		// translate the arguments here
+
+		result = RAM_disk_read(buff, sector, count);
+
+		// translate the reslut code here
+
+		return res;
 
 	case DEV_MMC :
 		// translate the arguments here
@@ -214,6 +289,15 @@ DRESULT disk_read (
 		// translate the reslut code here
 		(result == 0)?(res = RES_OK):(res = RES_ERROR);
 
+		return res;
+
+	case DEV_USB :
+		// translate the arguments here
+
+		result = USB_disk_read(buff, sector, count);
+
+		// translate the reslut code here
+
 		return res;
 	}
 
@@ -239,6 +323,14 @@ DRESULT disk_write (
 	int result;
 
 	switch (pdrv) {
+	case DEV_RAM :
+		// translate the arguments here
+
+		result = RAM_disk_write((BYTE *)buff, sector, count);
+
+		// translate the reslut code here
+
+		return res;
 
 	case DEV_MMC :
 		// translate the arguments here
@@ -248,6 +340,15 @@ DRESULT disk_write (
 		// translate the reslut code here
 		(result == 0)?(res = RES_OK):(res = RES_ERROR);
 
+		return res;
+
+	case DEV_USB :
+		// translate the arguments here
+
+		result = USB_disk_write((BYTE *)buff, sector, count);
+
+		// translate the reslut code here
+
 		return res;
 	}
 
@@ -270,6 +371,11 @@ DRESULT disk_ioctl (
 	DRESULT res = 0;
 
 	switch (pdrv) {
+	case DEV_RAM :
+
+		// Process of the command for the RAM drive
+
+		return res;
 
 	case DEV_MMC :
 
@@ -301,6 +407,12 @@ DRESULT disk_ioctl (
 				break;
 		}
 
+		return res;
+
+	case DEV_USB :
+
+		// Process of the command the USB drive
+
 		return res;
 	}
 

+ 2 - 0
src/os/rtos/include/FreeRTOSConfig.h

@@ -101,6 +101,8 @@ to exclude the API function. */
 #define INCLUDE_vTaskSuspend			1
 #define INCLUDE_vTaskDelayUntil			1
 #define INCLUDE_vTaskDelay				1
+#define INCLUDE_xTaskGetHandle			1
+#define INCLUDE_xTaskResumeFromISR		1
 
 #define configUSE_COUNTING_SEMAPHORES    1
 #define configSUPPORT_STATIC_ALLOCATION  1