浏览代码

fix compile warnings in bsp/simulator

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2544 bbd45198-f89e-11dd-88c7-29a3b14d5316
goprife@gmail.com 12 年之前
父节点
当前提交
77f4ee3029

+ 1 - 1
bsp/simulator/applications/dfs_win32.c

@@ -187,7 +187,7 @@ static int dfs_win32_close(struct dfs_fd *file)
     if (oflag & DFS_O_DIRECTORY)
     {
         /* operations about dir */
-        if (_findclose(file->data) < 0)
+        if (_findclose((intptr_t)file->data) < 0)
             goto __err;
 
         return 0;

+ 0 - 2
bsp/simulator/applications/platform.c

@@ -25,7 +25,5 @@ void rt_platform_init(void)
 #ifdef _WIN32
     rt_thread_idle_sethook(rt_hw_win32_low_cpu);
 #endif
-    rt_thread_delay(50);
-    rt_device_init_all();
 }
 

+ 0 - 1
bsp/simulator/drivers/sd_sim.c

@@ -126,7 +126,6 @@ static rt_err_t rt_sdcard_control(rt_device_t dev, rt_uint8_t cmd, void *args)
 rt_err_t rt_hw_sdcard_init(const char *spi_device_name)
 {
     int size;
-    rt_uint32_t id, total_block;
     struct sdcard_device *sd;
     struct rt_device *device;
 

+ 14 - 6
bsp/simulator/drivers/serial.c

@@ -2,17 +2,19 @@
 ******************************************************************************
 * By   : parai
 * email:parai@foxmail.com
-* 这并不是一个真的串口设备,只是为了能够让内核打印信息而创建
+* virtual serial driver
 ******************************************************************************
 */
 
-#include "rtthread.h"
+#include <rthw.h>
+#include <rtthread.h>
 
 #define _DEBUG_SERIAL 0
 #include "serial.h"
 #include <stdio.h>
 struct rt_device serial_device;
 extern struct serial_int_rx serial_rx;
+static FILE *fp = RT_NULL;
 
 /*@{*/
 
@@ -107,8 +109,14 @@ static rt_size_t rt_serial_write(rt_device_t dev, rt_off_t pos, const void *buff
 #if _DEBUG_SERIAL==1
     printf("in rt_serial_write()\n");
 #endif
-    printf("%s", (char *)buffer);
-    return size;
+	if (fp == NULL)
+		fp = fopen("log.txt", "wb+");
+
+	if (fp != NULL)
+		fwrite(buffer, size, 1, fp);
+
+	printf("%s",(char*)buffer);
+	return size;
 }
 
 static rt_err_t rt_serial_control(rt_device_t dev, rt_uint8_t cmd, void *args)
@@ -152,11 +160,11 @@ static rt_err_t rt_hw_serial_register(rt_device_t device, const char *name, rt_u
     device->user_data       = RT_NULL;
 
     /* register a character device */
-    return rt_device_register(device, name, RT_DEVICE_FLAG_RDWR | flag);
+    return rt_device_register(device, name, (rt_uint16_t)(RT_DEVICE_FLAG_RDWR | flag));
 }
 
 rt_err_t rt_hw_serial_init(void)
 {
     return rt_hw_serial_register(&serial_device, RT_CONSOLE_DEVICE_NAME,
                                  RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM);
-}
+}

+ 2 - 0
bsp/simulator/drivers/usart_sim.c

@@ -1,7 +1,9 @@
+#include  <rthw.h>
 #include  <rtthread.h>
 #include  <windows.h>
 #include  <mmsystem.h>
 #include  <stdio.h>
+
 #include "serial.h"
 
 struct serial_int_rx serial_rx;

+ 9 - 1
bsp/simulator/rtconfig.h

@@ -10,6 +10,14 @@
 #define _CRT_ERRNO_DEFINED  //errno macro redefinition
 
 #define HEAP_SIZE   (1024*1024*2)
+
+/* disable some warning in MSC */
+#pragma warning(disable:4273)	/* to ignore: warning C4273: inconsistent dll linkage */
+#pragma warning(disable:4312)   /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */
+#pragma warning(disable:4311)   /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */
+#pragma warning(disable:4996)   /* to ignore: warning C4996: The POSIX name for this item is deprecated. */
+#pragma warning(disable:4267)   /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */
+#pragma warning(disable:4244)   /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */
 #endif
 
 /* SECTION: basic kernel options */
@@ -113,7 +121,7 @@
 #define RT_USING_DFS_NFS
 
 /* DFS: uffs nand file system options */
-/* #define RT_USING_DFS_UFFS */
+#define RT_USING_DFS_UFFS
 /* configuration for uffs, more to see dfs_uffs.h and uffs_config.h */
 /* use ecc soft, the uffs will do all the things about ecc */
 #define RT_CONFIG_UFFS_ECC_MODE  UFFS_ECC_SOFT