mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-11-16 04:24:33 +00:00
Compare commits
23 Commits
4e41e700f0
...
v2.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cfd101ace3 | ||
|
|
1bebbecd22 | ||
|
|
8483352591 | ||
|
|
922f69e363 | ||
|
|
a3a5840ee0 | ||
|
|
f41f784b75 | ||
|
|
8c3781ade9 | ||
|
|
540d6ebf54 | ||
|
|
dd7abc2a08 | ||
|
|
c1d2e97c78 | ||
|
|
1bd91f8b05 | ||
|
|
7da82cbf31 | ||
|
|
f8c82b05bb | ||
|
|
ccc89001e5 | ||
|
|
40570b92ac | ||
|
|
52e43eae9b | ||
|
|
bd2d62a1df | ||
|
|
8cd254b08f | ||
|
|
1c7f33c151 | ||
|
|
cb1654de75 | ||
|
|
80eedb8963 | ||
|
|
7962a5c46c | ||
|
|
677d5323e8 |
@@ -122,8 +122,8 @@
|
||||
// </section>
|
||||
|
||||
// <section name="LIBC" description="C Runtime library setting" default="always" >
|
||||
// <bool name="RT_USING_NEWLIB" description="Using newlib library, only available under GNU GCC" default="true" />
|
||||
//#define RT_USING_NEWLIB
|
||||
// <bool name="RT_USING_LIBC" description="Using C library" default="true" />
|
||||
#define RT_USING_LIBC
|
||||
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
|
||||
#define RT_USING_PTHREADS
|
||||
// </section>
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#include <board.h>
|
||||
#ifdef RT_USING_FINSH
|
||||
#include <shell.h>
|
||||
#include <finsh.h>
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
#include <components.h>
|
||||
#endif
|
||||
@@ -25,12 +29,8 @@ void rt_init_thread_entry(void *parameter)
|
||||
/* Initialization RT-Thread Components */
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
rt_components_init();
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_FINSH
|
||||
/* initialize finsh */
|
||||
#elif defined(RT_USING_FINSH)
|
||||
finsh_system_init();
|
||||
finsh_set_device(FINSH_DEVICE_NAME);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
// <section name="LIBC" description="C Runtime library setting" default="always" >
|
||||
// <bool name="RT_USING_LIBC" description="Using C library" default="true" />
|
||||
// #define RT_USING_LIBC
|
||||
#define RT_USING_LIBC
|
||||
// <bool name="RT_USING_PTHREADS" description="Using POSIX threads library" default="true" />
|
||||
#define RT_USING_PTHREADS
|
||||
// </section>
|
||||
|
||||
@@ -152,8 +152,6 @@ void USART1_IRQHandler(void)
|
||||
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
|
||||
/* clear interrupt */
|
||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||
}
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||
{
|
||||
@@ -186,8 +184,6 @@ void USART2_IRQHandler(void)
|
||||
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
|
||||
/* clear interrupt */
|
||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||
}
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||
{
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
|
||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
|
||||
#define PLL_M 25
|
||||
#define PLL_M (HSE_VALUE / 1000000)
|
||||
#define PLL_N 240
|
||||
|
||||
/* SYSCLK = PLL_VCO / PLL_P */
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
|
||||
/************************* PLL Parameters *************************************/
|
||||
/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
|
||||
#define PLL_M 25
|
||||
#define PLL_M (HSE_VALUE / 1000000)
|
||||
#define PLL_N 336
|
||||
|
||||
/* SYSCLK = PLL_VCO / PLL_P */
|
||||
|
||||
@@ -177,8 +177,6 @@ void USART1_IRQHandler(void)
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
|
||||
/* clear interrupt */
|
||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||
}
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||
{
|
||||
@@ -211,8 +209,6 @@ void USART2_IRQHandler(void)
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
|
||||
/* clear interrupt */
|
||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||
}
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||
{
|
||||
@@ -245,8 +241,6 @@ void USART3_IRQHandler(void)
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
|
||||
{
|
||||
rt_hw_serial_isr(&serial3, RT_SERIAL_EVENT_RX_IND);
|
||||
/* clear interrupt */
|
||||
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
|
||||
}
|
||||
if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ elif PLATFORM == 'armcc':
|
||||
LINK = 'armlink'
|
||||
TARGET_EXT = 'axf'
|
||||
|
||||
DEVICE = ' --cortex-m4.fp'
|
||||
DEVICE = ' --cpu Cortex-M4.fp'
|
||||
CFLAGS = DEVICE + ' --apcs=interwork -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx'
|
||||
AFLAGS = DEVICE
|
||||
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-stm32.map --scatter stm32_rom.sct'
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
#include <i386.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*******************************************************************/
|
||||
/* Timer Register */
|
||||
/*******************************************************************/
|
||||
|
||||
@@ -105,4 +105,8 @@ struct Pseudodesc {
|
||||
#define STS_IG32 0xe // 32-bit Interrupt Gate
|
||||
#define STS_TG32 0xf // 32-bit Trap Gate
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* File : crt.cpp
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2008-2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-03-07 Bernard Add copyright header.
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include "crt.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,27 @@
|
||||
/*
|
||||
* File : crt.h
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2008-2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2015-03-07 Bernard Add copyright header.
|
||||
*/
|
||||
|
||||
#ifndef CRT_H_
|
||||
#define CRT_H_
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : crt_init.c
|
||||
* This file is part of Device File System in RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2008-2011, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2008-2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#include <dfs_file.h>
|
||||
#include <dfs_def.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef RT_USING_NEWLIB
|
||||
#define O_RDONLY DFS_O_RDONLY
|
||||
#define O_WRONLY DFS_O_WRONLY
|
||||
@@ -79,6 +83,7 @@
|
||||
|
||||
#if defined(__CC_ARM)
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#elif defined(_MSC_VER)
|
||||
#include <stdio.h>
|
||||
#else
|
||||
@@ -126,5 +131,8 @@ int rmdir(const char *path);
|
||||
int chdir(const char *path);
|
||||
char *getcwd(char *buf, size_t size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -284,6 +284,7 @@ const char *dfs_subdir(const char *directory, const char *filename)
|
||||
|
||||
return dir;
|
||||
}
|
||||
RTM_EXPORT(dfs_subdir);
|
||||
|
||||
/**
|
||||
* this function will normalize a path according to specified parent directory
|
||||
@@ -410,5 +411,7 @@ up_one:
|
||||
|
||||
return fullpath;
|
||||
}
|
||||
RTM_EXPORT(dfs_normalize_path);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
* Date Author Notes
|
||||
* 2005-02-22 Bernard The first version.
|
||||
* 2011-12-08 Bernard Merges rename patch from iamcacy.
|
||||
* 2015-05-27 Bernard Fix the fd clear issue.
|
||||
*/
|
||||
|
||||
#include <dfs.h>
|
||||
@@ -97,7 +98,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
{
|
||||
/* clear fd */
|
||||
rt_free(fd->path);
|
||||
rt_memset(fd, 0, sizeof(*fd));
|
||||
fd->path = RT_NULL;
|
||||
|
||||
return -DFS_STATUS_ENOSYS;
|
||||
}
|
||||
@@ -106,7 +107,7 @@ int dfs_file_open(struct dfs_fd *fd, const char *path, int flags)
|
||||
{
|
||||
/* clear fd */
|
||||
rt_free(fd->path);
|
||||
rt_memset(fd, 0, sizeof(*fd));
|
||||
fd->path = RT_NULL;
|
||||
|
||||
dfs_log(DFS_DEBUG_INFO, ("open failed"));
|
||||
|
||||
@@ -143,7 +144,7 @@ int dfs_file_close(struct dfs_fd *fd)
|
||||
return result;
|
||||
|
||||
rt_free(fd->path);
|
||||
rt_memset(fd, 0, sizeof(struct dfs_fd));
|
||||
fd->path = RT_NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -632,15 +633,15 @@ static void copyfile(const char *src, const char *dst)
|
||||
read_bytes = dfs_file_read(&src_fd, block_ptr, BUF_SZ);
|
||||
if (read_bytes > 0)
|
||||
{
|
||||
int length;
|
||||
int length;
|
||||
|
||||
length = dfs_file_write(&fd, block_ptr, read_bytes);
|
||||
if (length != read_bytes)
|
||||
{
|
||||
/* write failed. */
|
||||
rt_kprintf("Write file data failed, errno=%d\n", length);
|
||||
break;
|
||||
}
|
||||
if (length != read_bytes)
|
||||
{
|
||||
/* write failed. */
|
||||
rt_kprintf("Write file data failed, errno=%d\n", length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (read_bytes > 0);
|
||||
|
||||
@@ -652,7 +653,6 @@ static void copyfile(const char *src, const char *dst)
|
||||
extern int mkdir(const char *path, mode_t mode);
|
||||
static void copydir(const char * src, const char * dst)
|
||||
{
|
||||
struct dfs_fd fd;
|
||||
struct dirent dirent;
|
||||
struct stat stat;
|
||||
int length;
|
||||
|
||||
@@ -230,6 +230,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||
break;
|
||||
|
||||
default:
|
||||
fd_put(d);
|
||||
rt_set_errno(-DFS_STATUS_EINVAL);
|
||||
|
||||
return -1;
|
||||
@@ -237,6 +238,7 @@ off_t lseek(int fd, off_t offset, int whence)
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
fd_put(d);
|
||||
rt_set_errno(-DFS_STATUS_EINVAL);
|
||||
|
||||
return -1;
|
||||
@@ -374,6 +376,36 @@ int fstat(int fildes, struct stat *buf)
|
||||
}
|
||||
RTM_EXPORT(fstat);
|
||||
|
||||
/**
|
||||
* this function is a POSIX compliant version, which shall request that all data
|
||||
* for the open file descriptor named by fildes is to be transferred to the storage
|
||||
* device associated with the file described by fildes.
|
||||
*
|
||||
* @param fildes the file description
|
||||
*
|
||||
* @return 0 on successful completion. Otherwise, -1 shall be returned and errno
|
||||
* set to indicate the error.
|
||||
*/
|
||||
int fsync(int fildes)
|
||||
{
|
||||
int ret;
|
||||
struct dfs_fd *d;
|
||||
|
||||
/* get the fd */
|
||||
d = fd_get(fildes);
|
||||
if (d == RT_NULL)
|
||||
{
|
||||
rt_set_errno(-DFS_STATUS_EBADF);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = dfs_file_flush(d);
|
||||
|
||||
fd_put(d);
|
||||
return ret;
|
||||
}
|
||||
RTM_EXPORT(fsync);
|
||||
|
||||
/**
|
||||
* this function is a POSIX compliant version, which will return the
|
||||
* information about a mounted file system.
|
||||
@@ -427,6 +459,7 @@ int mkdir(const char *path, mode_t mode)
|
||||
|
||||
if (result < 0)
|
||||
{
|
||||
fd_put(d);
|
||||
fd_put(d);
|
||||
rt_set_errno(result);
|
||||
|
||||
@@ -435,6 +468,7 @@ int mkdir(const char *path, mode_t mode)
|
||||
|
||||
dfs_file_close(d);
|
||||
fd_put(d);
|
||||
fd_put(d);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -181,6 +181,12 @@ rt_int32_t sdio_io_rw_extended(struct rt_mmcsd_card *card,
|
||||
rt_uint8_t *buf,
|
||||
rt_uint32_t blocks,
|
||||
rt_uint32_t blksize);
|
||||
rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func,
|
||||
rt_int32_t rw,
|
||||
rt_uint32_t addr,
|
||||
rt_int32_t op_code,
|
||||
rt_uint8_t *buf,
|
||||
rt_uint32_t len);
|
||||
rt_uint8_t sdio_io_readb(struct rt_sdio_function *func,
|
||||
rt_uint32_t reg,
|
||||
rt_int32_t *err);
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RT_DEVICE(device) ((rt_device_t)device)
|
||||
|
||||
/* completion flag */
|
||||
@@ -362,5 +366,9 @@ rt_inline void rt_work_init(struct rt_work* work, void (*work_func)(struct rt_wo
|
||||
#include "drivers/pin.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RT_DEVICE_H__ */
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ int rt_device_pin_register(const char *name, const struct rt_pin_ops *ops, void
|
||||
_hw_pin.parent.user_data = user_data;
|
||||
|
||||
/* register a character device */
|
||||
rt_device_register(&_hw_pin.parent, "pin", RT_DEVICE_FLAG_RDWR);
|
||||
rt_device_register(&_hw_pin.parent, name, RT_DEVICE_FLAG_RDWR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card,
|
||||
}
|
||||
else
|
||||
{
|
||||
req.stop = NULL;
|
||||
req.stop = RT_NULL;
|
||||
r_cmd = READ_SINGLE_BLOCK;
|
||||
w_cmd = WRITE_BLOCK;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ rt_inline rt_uint32_t sdio_max_block_size(struct rt_sdio_function *func)
|
||||
return MIN(size, 512u); /* maximum size for byte mode */
|
||||
}
|
||||
|
||||
static rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func,
|
||||
rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func,
|
||||
rt_int32_t rw,
|
||||
rt_uint32_t addr,
|
||||
rt_int32_t op_code,
|
||||
@@ -1325,6 +1325,7 @@ rt_int32_t sdio_register_driver(struct rt_sdio_driver *driver)
|
||||
return -RT_ENOMEM;
|
||||
}
|
||||
|
||||
sd->drv = driver;
|
||||
rt_list_insert_after(&sdio_drivers, &sd->list);
|
||||
|
||||
if (!rt_list_isempty(&sdio_cards))
|
||||
|
||||
@@ -58,7 +58,7 @@ int SensorBase::getConfig(SensorConfig *config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SensorBase::subscribe(SensorEventHandler_t *handler, void *user_data)
|
||||
int SensorBase::subscribe(SensorEventHandler_t handler, void *user_data)
|
||||
{
|
||||
this->evtHandler = handler;
|
||||
this->userData = user_data;
|
||||
@@ -66,12 +66,12 @@ int SensorBase::subscribe(SensorEventHandler_t *handler, void *user_data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SensorBase::publish(sensors_event_t *event)
|
||||
int SensorBase::publish(void)
|
||||
{
|
||||
if (this->evtHandler != NULL)
|
||||
{
|
||||
/* invoke subscribed handler */
|
||||
(*evtHandler)(event, this->userData);
|
||||
(*evtHandler)(this->userData);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -151,7 +151,7 @@ SensorBase *SensorManager::getDefaultSensor(int type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int SensorManager::subscribe(int type, SensorEventHandler_t *handler, void *user_data)
|
||||
int SensorManager::subscribe(int type, SensorEventHandler_t handler, void *user_data)
|
||||
{
|
||||
SensorBase *sensor;
|
||||
|
||||
@@ -194,7 +194,7 @@ rt_sensor_t rt_sensor_get_default(int type)
|
||||
return (rt_sensor_t)SensorManager::getDefaultSensor(type);
|
||||
}
|
||||
|
||||
int rt_sensor_subscribe(rt_sensor_t sensor, SensorEventHandler_t *handler, void *user_data)
|
||||
int rt_sensor_subscribe(rt_sensor_t sensor, SensorEventHandler_t handler, void *user_data)
|
||||
{
|
||||
SensorBase *sensor_base;
|
||||
if (sensor == NULL) return -1;
|
||||
|
||||
@@ -992,10 +992,10 @@ enum SensorAccelRange
|
||||
SENSOR_ACCEL_RANGE_8G,
|
||||
SENSOR_ACCEL_RANGE_16G,
|
||||
};
|
||||
#define SENSOR_ACCEL_SENSITIVITY_2G (0.001F)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_4G (0.002F)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_8G (0.004F)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_16G (0.012F)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_2G ((float)2/32768)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_4G ((float)4/32768)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_8G ((float)8/32768)
|
||||
#define SENSOR_ACCEL_SENSITIVITY_16G ((float)16/32768)
|
||||
|
||||
enum SensorGyroRange
|
||||
{
|
||||
@@ -1040,12 +1040,13 @@ typedef struct SensorConfig
|
||||
|
||||
union range
|
||||
{
|
||||
int range;
|
||||
enum SensorAccelRange accel_range;
|
||||
enum SensorGyroRange gyro_range;
|
||||
} range;
|
||||
}SensorConfig;
|
||||
|
||||
typedef void (*SensorEventHandler_t)(sensors_event_t *event, void *user_data);
|
||||
typedef void (*SensorEventHandler_t)(void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
class SensorBase;
|
||||
@@ -1074,8 +1075,8 @@ public:
|
||||
int setConfig(SensorConfig *config);
|
||||
int getConfig(SensorConfig *config);
|
||||
|
||||
int subscribe(SensorEventHandler_t *handler, void *user_data);
|
||||
int publish(sensors_event_t *event);
|
||||
int subscribe(SensorEventHandler_t handler, void *user_data);
|
||||
int publish(void);
|
||||
|
||||
protected:
|
||||
SensorBase *next;
|
||||
@@ -1084,7 +1085,7 @@ protected:
|
||||
/* sensor configuration */
|
||||
SensorConfig config;
|
||||
|
||||
SensorEventHandler_t *evtHandler;
|
||||
SensorEventHandler_t evtHandler;
|
||||
void *userData;
|
||||
|
||||
friend class SensorManager;
|
||||
@@ -1103,7 +1104,7 @@ public:
|
||||
static int unregisterSensor(SensorBase *sensor);
|
||||
|
||||
static SensorBase *getDefaultSensor(int type);
|
||||
static int subscribe(int type, SensorEventHandler_t *handler, void *user_data);
|
||||
static int subscribe(int type, SensorEventHandler_t handler, void *user_data);
|
||||
|
||||
static int sensorEventReady(SensorBase *sensor);
|
||||
static int pollSensor(SensorBase *sensor, sensors_event_t *events, int number, int duration);
|
||||
@@ -1120,7 +1121,7 @@ extern "C" {
|
||||
|
||||
rt_sensor_t rt_sensor_get_default(int type);
|
||||
|
||||
int rt_sensor_subscribe(rt_sensor_t sensor, SensorEventHandler_t *handler, void *user_data);
|
||||
int rt_sensor_subscribe(rt_sensor_t sensor, SensorEventHandler_t handler, void *user_data);
|
||||
int rt_sensor_activate (rt_sensor_t sensor, int enable);
|
||||
int rt_sensor_configure(rt_sensor_t sensor, SensorConfig *config);
|
||||
int rt_sensor_poll(rt_sensor_t sensor, sensors_event_t *event);
|
||||
|
||||
@@ -279,7 +279,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
serial->config.bufsz);
|
||||
RT_ASSERT(rx_fifo != RT_NULL);
|
||||
rx_fifo->buffer = (rt_uint8_t*) (rx_fifo + 1);
|
||||
rt_memset(rx_fifo->buffer, 0, RT_SERIAL_RB_BUFSZ);
|
||||
rt_memset(rx_fifo->buffer, 0, serial->config.bufsz);
|
||||
rx_fifo->put_index = 0;
|
||||
rx_fifo->get_index = 0;
|
||||
|
||||
@@ -302,6 +302,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
||||
|
||||
tx_dma = (struct rt_serial_tx_dma*) rt_malloc (sizeof(struct rt_serial_tx_dma));
|
||||
RT_ASSERT(tx_dma != RT_NULL);
|
||||
tx_dma->activated = RT_FALSE;
|
||||
|
||||
rt_data_queue_init(&(tx_dma->data_queue), 8, 4, RT_NULL);
|
||||
serial->serial_tx = tx_dma;
|
||||
@@ -519,12 +520,10 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
|
||||
rt_base_t level;
|
||||
struct rt_serial_rx_fifo* rx_fifo;
|
||||
|
||||
/* interrupt mode receive */
|
||||
rx_fifo = (struct rt_serial_rx_fifo*)serial->serial_rx;
|
||||
RT_ASSERT(rx_fifo != RT_NULL);
|
||||
|
||||
/* interrupt mode receive */
|
||||
RT_ASSERT(serial->parent.open_flag & RT_DEVICE_FLAG_INT_RX);
|
||||
|
||||
while (1)
|
||||
{
|
||||
ch = serial->ops->getc(serial);
|
||||
|
||||
@@ -3,6 +3,11 @@ from building import *
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
CPPPATH = [cwd + '/../include']
|
||||
|
||||
if not GetDepend('RT_USING_HEAP'):
|
||||
SrcRemove(src, 'dataqueue.c')
|
||||
SrcRemove(src, 'pipe.c')
|
||||
|
||||
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_DEVICE_IPC'], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
|
||||
@@ -39,6 +39,7 @@ void rt_completion_init(struct rt_completion *completion)
|
||||
rt_list_init(&completion->suspended_list);
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
RTM_EXPORT(rt_completion_init);
|
||||
|
||||
rt_err_t rt_completion_wait(struct rt_completion *completion,
|
||||
rt_int32_t timeout)
|
||||
@@ -95,16 +96,17 @@ rt_err_t rt_completion_wait(struct rt_completion *completion,
|
||||
result = thread->error;
|
||||
|
||||
level = rt_hw_interrupt_disable();
|
||||
/* clean completed flag */
|
||||
completion->flag = RT_UNCOMPLETED;
|
||||
}
|
||||
}
|
||||
/* clean completed flag */
|
||||
completion->flag = RT_UNCOMPLETED;
|
||||
|
||||
__exit:
|
||||
rt_hw_interrupt_enable(level);
|
||||
|
||||
return result;
|
||||
}
|
||||
RTM_EXPORT(rt_completion_wait);
|
||||
|
||||
void rt_completion_done(struct rt_completion *completion)
|
||||
{
|
||||
@@ -139,3 +141,5 @@ void rt_completion_done(struct rt_completion *completion)
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
RTM_EXPORT(rt_completion_done);
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ RTM_EXPORT(rt_usbh_adk_set_string);
|
||||
*/
|
||||
static rt_err_t rt_usbh_adk_get_protocol(struct uintf* intf, rt_uint16_t *protocol)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
uinst_t device;
|
||||
int timeout = 100;
|
||||
|
||||
@@ -101,7 +101,7 @@ static rt_err_t rt_usbh_adk_get_protocol(struct uintf* intf, rt_uint16_t *protoc
|
||||
static rt_err_t rt_usbh_adk_send_string(struct uintf* intf, rt_uint16_t index,
|
||||
const char* str)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
uinst_t device;
|
||||
int timeout = 100;
|
||||
|
||||
@@ -134,7 +134,7 @@ static rt_err_t rt_usbh_adk_send_string(struct uintf* intf, rt_uint16_t index,
|
||||
*/
|
||||
static rt_err_t rt_usbh_adk_start(struct uintf* intf)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
uinst_t device;
|
||||
int timeout = 100;
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ rt_err_t rt_usbh_detach_instance(uinst_t device)
|
||||
rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
|
||||
int nbytes)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
@@ -272,7 +272,7 @@ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer,
|
||||
*/
|
||||
rt_err_t rt_usbh_set_address(uinst_t device)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
RT_ASSERT(device != RT_NULL);
|
||||
@@ -306,7 +306,7 @@ rt_err_t rt_usbh_set_address(uinst_t device)
|
||||
*/
|
||||
rt_err_t rt_usbh_set_configure(uinst_t device, int config)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* check parameter */
|
||||
@@ -335,7 +335,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config)
|
||||
*/
|
||||
rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* check parameter */
|
||||
@@ -364,7 +364,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf)
|
||||
*/
|
||||
rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* check parameter */
|
||||
|
||||
@@ -43,7 +43,7 @@ static struct uclass_driver hub_driver;
|
||||
rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer,
|
||||
rt_size_t nbytes)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* parameter check */
|
||||
@@ -72,7 +72,7 @@ rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer
|
||||
*/
|
||||
rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint8_t* buffer)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
int length = 4;
|
||||
|
||||
@@ -104,7 +104,7 @@ rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint8_t* buffer)
|
||||
rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port,
|
||||
rt_uint8_t* buffer)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
int length = 4;
|
||||
|
||||
@@ -144,7 +144,7 @@ rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port,
|
||||
rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port,
|
||||
rt_uint16_t feature)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* parameter check */
|
||||
@@ -183,7 +183,7 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port,
|
||||
rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port,
|
||||
rt_uint16_t feature)
|
||||
{
|
||||
struct ureqest setup;
|
||||
struct urequest setup;
|
||||
int timeout = 100;
|
||||
|
||||
/* parameter check */
|
||||
|
||||
@@ -28,10 +28,10 @@ msh.c
|
||||
|
||||
CPPPATH = [cwd]
|
||||
if rtconfig.CROSS_TOOL == 'keil':
|
||||
LINKFLAGS = ' --keep __fsym_*'
|
||||
LINKFLAGS = ' --keep *.o(FSymTab)'
|
||||
|
||||
if not GetDepend('FINSH_USING_MSH_ONLY'):
|
||||
LINKFLAGS = LINKFLAGS + ' --keep __vsym_* '
|
||||
LINKFLAGS = LINKFLAGS + ' --keep *.o(VSymTab) '
|
||||
else:
|
||||
LINKFLAGS = ''
|
||||
|
||||
|
||||
@@ -623,7 +623,6 @@ int list_mod_detail(const char *name)
|
||||
return 0;
|
||||
}
|
||||
FINSH_FUNCTION_EXPORT(list_mod_detail, list module objects in system)
|
||||
MSH_CMD_EXPORT(list_mod_detail, list module objects in system)
|
||||
#endif
|
||||
|
||||
long list(void)
|
||||
|
||||
@@ -253,6 +253,7 @@ int system(const char *command)
|
||||
{
|
||||
return msh_exec_module(command, rt_strlen(command));
|
||||
}
|
||||
RTM_EXPORT(system);
|
||||
#endif
|
||||
|
||||
static int _msh_exec_cmd(char* cmd, rt_size_t length, int *retp)
|
||||
|
||||
@@ -280,6 +280,7 @@ FINSH_FUNCTION_EXPORT_ALIAS(cmd_time, __cmd_time, Execute command with time.);
|
||||
int cmd_free(int argc, char** argv)
|
||||
{
|
||||
extern void list_mem(void);
|
||||
extern void list_memheap(void);
|
||||
|
||||
#ifdef RT_USING_MEMHEAP_AS_HEAP
|
||||
list_memheap();
|
||||
|
||||
@@ -52,23 +52,23 @@
|
||||
static struct rt_thread finsh_thread;
|
||||
ALIGN(RT_ALIGN_SIZE)
|
||||
static char finsh_thread_stack[FINSH_THREAD_STACK_SIZE];
|
||||
struct finsh_shell* shell;
|
||||
struct finsh_shell *shell;
|
||||
|
||||
#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
|
||||
#if defined(RT_USING_DFS)
|
||||
#include <dfs_posix.h>
|
||||
#endif
|
||||
const char* finsh_get_prompt()
|
||||
const char *finsh_get_prompt()
|
||||
{
|
||||
#define _MSH_PROMPT "msh "
|
||||
#define _PROMPT "finsh "
|
||||
#define _MSH_PROMPT "msh "
|
||||
#define _PROMPT "finsh "
|
||||
static char finsh_prompt[RT_CONSOLEBUF_SIZE + 1] = {0};
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
if (msh_is_used()) strcpy(finsh_prompt, _MSH_PROMPT);
|
||||
else
|
||||
#endif
|
||||
strcpy(finsh_prompt, _PROMPT);
|
||||
strcpy(finsh_prompt, _PROMPT);
|
||||
|
||||
#if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR)
|
||||
/* get current working directory */
|
||||
@@ -98,7 +98,7 @@ static rt_err_t finsh_rx_ind(rt_device_t dev, rt_size_t size)
|
||||
*
|
||||
* @param device_name the name of new input device.
|
||||
*/
|
||||
void finsh_set_device(const char* device_name)
|
||||
void finsh_set_device(const char *device_name)
|
||||
{
|
||||
rt_device_t dev = RT_NULL;
|
||||
|
||||
@@ -113,7 +113,7 @@ void finsh_set_device(const char* device_name)
|
||||
/* check whether it's a same device */
|
||||
if (dev == shell->device) return;
|
||||
/* open this device and set the new device in finsh shell */
|
||||
if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX |\
|
||||
if (rt_device_open(dev, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX | \
|
||||
RT_DEVICE_FLAG_STREAM) == RT_EOK)
|
||||
{
|
||||
if (shell->device != RT_NULL)
|
||||
@@ -123,6 +123,10 @@ void finsh_set_device(const char* device_name)
|
||||
rt_device_set_rx_indicate(shell->device, RT_NULL);
|
||||
}
|
||||
|
||||
/* clear line buffer before switch to new device */
|
||||
memset(shell->line, 0, sizeof(shell->line));
|
||||
shell->line_curpos = shell->line_position = 0;
|
||||
|
||||
shell->device = dev;
|
||||
rt_device_set_rx_indicate(dev, finsh_rx_ind);
|
||||
}
|
||||
@@ -135,7 +139,7 @@ void finsh_set_device(const char* device_name)
|
||||
*
|
||||
* @return the finsh shell input device name is returned.
|
||||
*/
|
||||
const char* finsh_get_device()
|
||||
const char *finsh_get_device()
|
||||
{
|
||||
RT_ASSERT(shell != RT_NULL);
|
||||
return shell->device->parent.name;
|
||||
@@ -170,7 +174,7 @@ rt_uint32_t finsh_get_echo()
|
||||
return shell->echo_mode;
|
||||
}
|
||||
|
||||
static void shell_auto_complete(char* prefix)
|
||||
static void shell_auto_complete(char *prefix)
|
||||
{
|
||||
|
||||
rt_kprintf("\n");
|
||||
@@ -183,7 +187,7 @@ static void shell_auto_complete(char* prefix)
|
||||
#endif
|
||||
{
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
extern void list_prefix(char* prefix);
|
||||
extern void list_prefix(char * prefix);
|
||||
list_prefix(prefix);
|
||||
#endif
|
||||
}
|
||||
@@ -192,12 +196,12 @@ static void shell_auto_complete(char* prefix)
|
||||
}
|
||||
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
void finsh_run_line(struct finsh_parser* parser, const char *line)
|
||||
void finsh_run_line(struct finsh_parser *parser, const char *line)
|
||||
{
|
||||
const char* err_str;
|
||||
const char *err_str;
|
||||
|
||||
rt_kprintf("\n");
|
||||
finsh_parser_run(parser, (unsigned char*)line);
|
||||
finsh_parser_run(parser, (unsigned char *)line);
|
||||
|
||||
/* compile node root */
|
||||
if (finsh_errno() == 0)
|
||||
@@ -220,15 +224,15 @@ void finsh_run_line(struct finsh_parser* parser, const char *line)
|
||||
if (ch > 0x20 && ch < 0x7e)
|
||||
{
|
||||
rt_kprintf("\t'%c', %d, 0x%08x\n",
|
||||
(unsigned char)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
(unsigned char)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_kprintf("\t%d, 0x%08x\n",
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
(unsigned int)finsh_stack_bottom(),
|
||||
(unsigned int)finsh_stack_bottom());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,13 +241,13 @@ void finsh_run_line(struct finsh_parser* parser, const char *line)
|
||||
#endif
|
||||
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
static rt_bool_t shell_handle_history(struct finsh_shell* shell)
|
||||
static rt_bool_t shell_handle_history(struct finsh_shell *shell)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
int i;
|
||||
rt_kprintf("\r");
|
||||
|
||||
for(i=0; i<= 60; i++)
|
||||
for (i = 0; i <= 60; i++)
|
||||
putchar(' ');
|
||||
rt_kprintf("\r");
|
||||
|
||||
@@ -254,7 +258,7 @@ static rt_bool_t shell_handle_history(struct finsh_shell* shell)
|
||||
return RT_FALSE;
|
||||
}
|
||||
|
||||
static void shell_push_history(struct finsh_shell* shell)
|
||||
static void shell_push_history(struct finsh_shell *shell)
|
||||
{
|
||||
if (shell->line_position != 0)
|
||||
{
|
||||
@@ -266,7 +270,7 @@ static void shell_push_history(struct finsh_shell* shell)
|
||||
for (index = 0; index < FINSH_HISTORY_LINES - 1; index ++)
|
||||
{
|
||||
memcpy(&shell->cmd_history[index][0],
|
||||
&shell->cmd_history[index + 1][0], FINSH_CMD_SIZE);
|
||||
&shell->cmd_history[index + 1][0], FINSH_CMD_SIZE);
|
||||
}
|
||||
memset(&shell->cmd_history[index][0], 0, FINSH_CMD_SIZE);
|
||||
memcpy(&shell->cmd_history[index][0], shell->line, shell->line_position);
|
||||
@@ -290,7 +294,7 @@ static void shell_push_history(struct finsh_shell* shell)
|
||||
#ifndef RT_USING_HEAP
|
||||
struct finsh_shell _shell;
|
||||
#endif
|
||||
void finsh_thread_entry(void* parameter)
|
||||
void finsh_thread_entry(void *parameter)
|
||||
{
|
||||
char ch;
|
||||
|
||||
@@ -420,7 +424,10 @@ void finsh_thread_entry(void* parameter)
|
||||
char next;
|
||||
|
||||
if (rt_device_read(shell->device, 0, &next, 1) == 1)
|
||||
ch = next;
|
||||
{
|
||||
if (next == '\0') ch = '\r'; /* linux telnet will issue '\0' */
|
||||
else ch = next;
|
||||
}
|
||||
else ch = '\r';
|
||||
}
|
||||
/* handle tab key */
|
||||
@@ -475,26 +482,26 @@ void finsh_thread_entry(void* parameter)
|
||||
/* handle end of line, break */
|
||||
if (ch == '\r' || ch == '\n')
|
||||
{
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
#ifdef FINSH_USING_HISTORY
|
||||
shell_push_history(shell);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FINSH_USING_MSH
|
||||
#ifdef FINSH_USING_MSH
|
||||
if (msh_is_used() == RT_TRUE)
|
||||
{
|
||||
rt_kprintf("\n");
|
||||
msh_exec(shell->line, shell->line_position);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
{
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
/* add ';' and run the command line */
|
||||
shell->line[shell->line_position] = ';';
|
||||
|
||||
if (shell->line_position != 0) finsh_run_line(&shell->parser, shell->line);
|
||||
else rt_kprintf("\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
rt_kprintf(FINSH_PROMPT);
|
||||
@@ -526,46 +533,47 @@ void finsh_thread_entry(void* parameter)
|
||||
else
|
||||
{
|
||||
shell->line[shell->line_position] = ch;
|
||||
rt_kprintf("%c", ch);
|
||||
if (shell->echo_mode)
|
||||
rt_kprintf("%c", ch);
|
||||
}
|
||||
|
||||
ch = 0;
|
||||
shell->line_position ++;
|
||||
shell->line_curpos++;
|
||||
if (shell->line_position >= 80)
|
||||
{
|
||||
/* clear command line */
|
||||
shell->line_position = 0;
|
||||
shell->line_curpos = 0;
|
||||
}
|
||||
if (shell->line_position >= 80)
|
||||
{
|
||||
/* clear command line */
|
||||
shell->line_position = 0;
|
||||
shell->line_curpos = 0;
|
||||
}
|
||||
} /* end of device read */
|
||||
}
|
||||
}
|
||||
|
||||
void finsh_system_function_init(const void* begin, const void* end)
|
||||
void finsh_system_function_init(const void *begin, const void *end)
|
||||
{
|
||||
_syscall_table_begin = (struct finsh_syscall*) begin;
|
||||
_syscall_table_end = (struct finsh_syscall*) end;
|
||||
_syscall_table_begin = (struct finsh_syscall *) begin;
|
||||
_syscall_table_end = (struct finsh_syscall *) end;
|
||||
}
|
||||
|
||||
void finsh_system_var_init(const void* begin, const void* end)
|
||||
void finsh_system_var_init(const void *begin, const void *end)
|
||||
{
|
||||
_sysvar_table_begin = (struct finsh_sysvar*) begin;
|
||||
_sysvar_table_end = (struct finsh_sysvar*) end;
|
||||
_sysvar_table_begin = (struct finsh_sysvar *) begin;
|
||||
_sysvar_table_end = (struct finsh_sysvar *) end;
|
||||
}
|
||||
|
||||
#if defined(__ICCARM__) || defined(__ICCRX__) /* for IAR compiler */
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
#pragma section="FSymTab"
|
||||
#pragma section="VSymTab"
|
||||
#endif
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
#pragma section="FSymTab"
|
||||
#pragma section="VSymTab"
|
||||
#endif
|
||||
#elif defined(__ADSPBLACKFIN__) /* for VisaulDSP++ Compiler*/
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
extern "asm" int __fsymtab_start;
|
||||
extern "asm" int __fsymtab_end;
|
||||
extern "asm" int __vsymtab_start;
|
||||
extern "asm" int __vsymtab_end;
|
||||
#endif
|
||||
#ifdef FINSH_USING_SYMTAB
|
||||
extern "asm" int __fsymtab_start;
|
||||
extern "asm" int __fsymtab_end;
|
||||
extern "asm" int __vsymtab_start;
|
||||
extern "asm" int __vsymtab_end;
|
||||
#endif
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma section("FSymTab$a", read)
|
||||
const char __fsym_begin_name[] = "__start";
|
||||
@@ -604,9 +612,9 @@ int finsh_system_init(void)
|
||||
extern const int VSymTab$$Base;
|
||||
extern const int VSymTab$$Limit;
|
||||
finsh_system_function_init(&FSymTab$$Base, &FSymTab$$Limit);
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
#ifndef FINSH_USING_MSH_ONLY
|
||||
finsh_system_var_init(&VSymTab$$Base, &VSymTab$$Limit);
|
||||
#endif
|
||||
#endif
|
||||
#elif defined (__ICCARM__) || defined(__ICCRX__) /* for IAR Compiler */
|
||||
finsh_system_function_init(__section_begin("FSymTab"),
|
||||
__section_end("FSymTab"));
|
||||
@@ -626,10 +634,12 @@ int finsh_system_init(void)
|
||||
#elif defined(_MSC_VER)
|
||||
unsigned int *ptr_begin, *ptr_end;
|
||||
|
||||
ptr_begin = (unsigned int*)&__fsym_begin; ptr_begin += (sizeof(struct finsh_syscall)/sizeof(unsigned int));
|
||||
ptr_begin = (unsigned int *)&__fsym_begin;
|
||||
ptr_begin += (sizeof(struct finsh_syscall) / sizeof(unsigned int));
|
||||
while (*ptr_begin == 0) ptr_begin ++;
|
||||
|
||||
ptr_end = (unsigned int*) &__fsym_end; ptr_end --;
|
||||
ptr_end = (unsigned int *) &__fsym_end;
|
||||
ptr_end --;
|
||||
while (*ptr_end == 0) ptr_end --;
|
||||
|
||||
finsh_system_function_init(ptr_begin, ptr_end);
|
||||
@@ -638,7 +648,7 @@ int finsh_system_init(void)
|
||||
|
||||
/* create or set shell structure */
|
||||
#ifdef RT_USING_HEAP
|
||||
shell = (struct finsh_shell*)rt_malloc(sizeof(struct finsh_shell));
|
||||
shell = (struct finsh_shell *)rt_malloc(sizeof(struct finsh_shell));
|
||||
if (shell == RT_NULL)
|
||||
{
|
||||
rt_kprintf("no memory for shell\n");
|
||||
@@ -652,10 +662,10 @@ int finsh_system_init(void)
|
||||
|
||||
rt_sem_init(&(shell->rx_sem), "shrx", 0, 0);
|
||||
result = rt_thread_init(&finsh_thread,
|
||||
"tshell",
|
||||
finsh_thread_entry, RT_NULL,
|
||||
&finsh_thread_stack[0], sizeof(finsh_thread_stack),
|
||||
FINSH_THREAD_PRIORITY, 10);
|
||||
"tshell",
|
||||
finsh_thread_entry, RT_NULL,
|
||||
&finsh_thread_stack[0], sizeof(finsh_thread_stack),
|
||||
FINSH_THREAD_PRIORITY, 10);
|
||||
|
||||
if (result == RT_EOK)
|
||||
rt_thread_startup(&finsh_thread);
|
||||
|
||||
@@ -50,7 +50,9 @@
|
||||
#ifndef FINSH_THREAD_STACK_SIZE
|
||||
#define FINSH_THREAD_STACK_SIZE 2048
|
||||
#endif
|
||||
#ifndef FINSH_CMD_SIZE
|
||||
#define FINSH_CMD_SIZE 80
|
||||
#endif
|
||||
|
||||
#define FINSH_OPTION_ECHO 0x01
|
||||
#if defined(FINSH_USING_MSH) || (defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR))
|
||||
|
||||
@@ -9,6 +9,10 @@ CPPPATH = [cwd]
|
||||
CPPDEFINES = ['RT_USING_DLIBC']
|
||||
|
||||
if rtconfig.PLATFORM == 'iar':
|
||||
|
||||
if GetDepend('RT_USING_DFS'):
|
||||
CPPDEFINES = CPPDEFINES + ['_DLIB_FILE_DESCRIPTOR', '_DLIB_THREAD_SUPPORT']
|
||||
|
||||
group = DefineGroup('dlib', src, depend = ['RT_USING_LIBC'],
|
||||
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
|
||||
|
||||
|
||||
@@ -103,5 +103,9 @@ void sys_arch_assert(const char* file, int line);
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#define SYS_ARCH_DECL_PROTECT(level)
|
||||
#define SYS_ARCH_PROTECT(level) rt_enter_critical()
|
||||
#define SYS_ARCH_UNPROTECT(level) rt_exit_critical()
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
|
||||
|
||||
@@ -695,3 +695,17 @@ RTM_EXPORT(dhcp_stop);
|
||||
#include <lwip/netifapi.h>
|
||||
RTM_EXPORT(netifapi_netif_set_addr);
|
||||
#endif
|
||||
|
||||
#if LWIP_NETIF_LINK_CALLBACK
|
||||
RTM_EXPORT(netif_set_link_callback);
|
||||
#endif
|
||||
|
||||
#if LWIP_NETIF_STATUS_CALLBACK
|
||||
RTM_EXPORT(netif_set_status_callback);
|
||||
#endif
|
||||
|
||||
RTM_EXPORT(netif_find);
|
||||
RTM_EXPORT(netif_set_addr);
|
||||
RTM_EXPORT(netif_set_ipaddr);
|
||||
RTM_EXPORT(netif_set_gw);
|
||||
RTM_EXPORT(netif_set_netmask);
|
||||
|
||||
@@ -67,6 +67,12 @@
|
||||
#define netifapi_netif_set_link_up(n) netifapi_netif_common(n, netif_set_link_up, NULL)
|
||||
#define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL)
|
||||
|
||||
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
|
||||
#define RT_ETHERNETIF_THREAD_PREORITY 0x90
|
||||
#else
|
||||
#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY
|
||||
#endif
|
||||
|
||||
#ifndef LWIP_NO_TX_THREAD
|
||||
/**
|
||||
* Tx message structure for Ethernet interface
|
||||
@@ -79,7 +85,7 @@ struct eth_tx_msg
|
||||
|
||||
static struct rt_mailbox eth_tx_thread_mb;
|
||||
static struct rt_thread eth_tx_thread;
|
||||
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
|
||||
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
|
||||
static char eth_tx_thread_mb_pool[32 * 4];
|
||||
static char eth_tx_thread_stack[512];
|
||||
#else
|
||||
@@ -91,12 +97,10 @@ static char eth_tx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
|
||||
#ifndef LWIP_NO_RX_THREAD
|
||||
static struct rt_mailbox eth_rx_thread_mb;
|
||||
static struct rt_thread eth_rx_thread;
|
||||
#ifndef RT_LWIP_ETHTHREAD_PRIORITY
|
||||
#define RT_ETHERNETIF_THREAD_PREORITY 0x90
|
||||
#ifndef RT_LWIP_ETHTHREAD_MBOX_SIZE
|
||||
static char eth_rx_thread_mb_pool[48 * 4];
|
||||
static char eth_rx_thread_stack[1024];
|
||||
#else
|
||||
#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY
|
||||
static char eth_rx_thread_mb_pool[RT_LWIP_ETHTHREAD_MBOX_SIZE * 4];
|
||||
static char eth_rx_thread_stack[RT_LWIP_ETHTHREAD_STACKSIZE];
|
||||
#endif
|
||||
@@ -318,7 +322,7 @@ static void eth_tx_thread_entry(void* parameter)
|
||||
/* call driver's interface */
|
||||
if (enetif->eth_tx(&(enetif->parent), msg->buf) != RT_EOK)
|
||||
{
|
||||
rt_kprintf("transmit eth packet failed\n");
|
||||
/* transmit eth packet failed */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,7 +401,7 @@ int eth_system_device_init(void)
|
||||
|
||||
result = rt_thread_init(ð_rx_thread, "erx", eth_rx_thread_entry, RT_NULL,
|
||||
ð_rx_thread_stack[0], sizeof(eth_rx_thread_stack),
|
||||
RT_LWIP_ETHTHREAD_PRIORITY, 16);
|
||||
RT_ETHERNETIF_THREAD_PREORITY, 16);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
result = rt_thread_startup(ð_rx_thread);
|
||||
RT_ASSERT(result == RT_EOK);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* File : rtdef.h
|
||||
* This file is part of RT-Thread RTOS
|
||||
* COPYRIGHT (C) 2006 - 2012, RT-Thread Development Team
|
||||
* COPYRIGHT (C) 2006 - 2015, RT-Thread Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
/* RT-Thread version information */
|
||||
#define RT_VERSION 2L /**< major version number */
|
||||
#define RT_SUBVERSION 0L /**< minor version number */
|
||||
#define RT_REVISION 0L /**< revise version number */
|
||||
#define RT_REVISION 2L /**< revise version number */
|
||||
|
||||
/* RT-Thread version */
|
||||
#define RTTHREAD_VERSION ((RT_VERSION * 10000) + \
|
||||
|
||||
@@ -183,13 +183,11 @@ rt_hw_context_switch_to PROC
|
||||
LDR r0, =NVIC_INT_CTRL
|
||||
LDR r1, =NVIC_PENDSVSET
|
||||
STR r1, [r0]
|
||||
NOP
|
||||
|
||||
; restore MSP
|
||||
LDR r0, =SCB_VTOR
|
||||
LDR r0, [r0]
|
||||
LDR r0, [r0]
|
||||
NOP
|
||||
MSR msp, r0
|
||||
|
||||
; enable interrupts at processor level
|
||||
@@ -216,4 +214,6 @@ HardFault_Handler PROC
|
||||
POP {pc}
|
||||
ENDP
|
||||
|
||||
ALIGN 4
|
||||
|
||||
END
|
||||
|
||||
@@ -177,7 +177,6 @@ rt_hw_context_switch_to PROC
|
||||
rt_hw_interrupt_thread_switch PROC
|
||||
EXPORT rt_hw_interrupt_thread_switch
|
||||
BX lr
|
||||
NOP
|
||||
ENDP
|
||||
|
||||
IMPORT rt_hw_hard_fault_exception
|
||||
@@ -203,4 +202,6 @@ HardFault_Handler PROC
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
ALIGN 4
|
||||
|
||||
END
|
||||
|
||||
@@ -205,7 +205,6 @@ rt_hw_context_switch_to PROC
|
||||
LDR r0, =SCB_VTOR
|
||||
LDR r0, [r0]
|
||||
LDR r0, [r0]
|
||||
NOP
|
||||
MSR msp, r0
|
||||
|
||||
; enable interrupts at processor level
|
||||
@@ -218,7 +217,6 @@ rt_hw_context_switch_to PROC
|
||||
rt_hw_interrupt_thread_switch PROC
|
||||
EXPORT rt_hw_interrupt_thread_switch
|
||||
BX lr
|
||||
NOP
|
||||
ENDP
|
||||
|
||||
IMPORT rt_hw_hard_fault_exception
|
||||
@@ -235,4 +233,6 @@ HardFault_Handler PROC
|
||||
BX lr
|
||||
ENDP
|
||||
|
||||
ALIGN 4
|
||||
|
||||
END
|
||||
|
||||
@@ -1072,8 +1072,8 @@ rt_device_t rt_console_set_device(const char *name)
|
||||
}
|
||||
|
||||
/* set new console device */
|
||||
rt_device_open(new, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
|
||||
_console_device = new;
|
||||
rt_device_open(_console_device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_STREAM);
|
||||
}
|
||||
|
||||
return old;
|
||||
|
||||
@@ -304,6 +304,7 @@ void *rt_malloc(rt_size_t size)
|
||||
|
||||
/* create mem2 struct */
|
||||
mem2 = (struct heap_mem *)&heap_ptr[ptr2];
|
||||
mem2->magic = HEAP_MAGIC;
|
||||
mem2->used = 0;
|
||||
mem2->next = mem->next;
|
||||
mem2->prev = ptr;
|
||||
@@ -540,7 +541,7 @@ void rt_free(void *rmem)
|
||||
RT_ASSERT(mem->magic == HEAP_MAGIC);
|
||||
/* ... and is now unused. */
|
||||
mem->used = 0;
|
||||
mem->magic = 0;
|
||||
mem->magic = HEAP_MAGIC;
|
||||
|
||||
if (mem < lfree)
|
||||
{
|
||||
|
||||
@@ -517,6 +517,7 @@ void rt_memheap_free(void *ptr)
|
||||
|
||||
/* check magic */
|
||||
RT_ASSERT((header_ptr->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);
|
||||
RT_ASSERT(header_ptr->magic & RT_MEMHEAP_USED);
|
||||
/* check whether this block of memory has been over-written. */
|
||||
RT_ASSERT((header_ptr->next->magic & RT_MEMHEAP_MASK) == RT_MEMHEAP_MAGIC);
|
||||
|
||||
|
||||
@@ -401,8 +401,8 @@ rt_bool_t rt_object_is_systemobject(rt_object_t object)
|
||||
*/
|
||||
rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
||||
{
|
||||
struct rt_object *object;
|
||||
struct rt_list_node *node;
|
||||
struct rt_object *object = RT_NULL;
|
||||
struct rt_list_node *node = RT_NULL;
|
||||
struct rt_object_information *information = RT_NULL;
|
||||
|
||||
/* parameter check */
|
||||
|
||||
@@ -371,6 +371,7 @@ void rt_enter_critical(void)
|
||||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
RTM_EXPORT(rt_enter_critical);
|
||||
|
||||
/**
|
||||
* This function will unlock the thread scheduler.
|
||||
@@ -398,6 +399,7 @@ void rt_exit_critical(void)
|
||||
rt_hw_interrupt_enable(level);
|
||||
}
|
||||
}
|
||||
RTM_EXPORT(rt_exit_critical);
|
||||
|
||||
/**
|
||||
* Get the scheduler lock level
|
||||
@@ -408,5 +410,6 @@ rt_uint16_t rt_critical_level(void)
|
||||
{
|
||||
return rt_scheduler_lock_nest;
|
||||
}
|
||||
RTM_EXPORT(rt_critical_level);
|
||||
/*@}*/
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
# Change Logs:
|
||||
# Date Author Notes
|
||||
# 2015-01-20 Bernard Add copyright information
|
||||
# 2015-07-25 Bernard Add LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES for
|
||||
# group definition.
|
||||
#
|
||||
|
||||
import os
|
||||
@@ -112,6 +114,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||
|
||||
# add program path
|
||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||
# add rtconfig.h path
|
||||
env.Append(CPPPATH = [str(Dir('#').abspath)])
|
||||
|
||||
# add library build action
|
||||
act = SCons.Action.Action(BuildLibInstallAction, 'Install compiled library... $TARGET')
|
||||
@@ -186,7 +190,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||
AddOption('--target',
|
||||
dest='target',
|
||||
type='string',
|
||||
help='set target project: mdk/iar/vs/ua')
|
||||
help='set target project: mdk/mdk4/iar/vs/ua')
|
||||
|
||||
#{target_name:(CROSS_TOOL, PLATFORM)}
|
||||
tgt_dict = {'mdk':('keil', 'armcc'),
|
||||
@@ -196,7 +200,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||
'vs':('msvc', 'cl'),
|
||||
'vs2012':('msvc', 'cl'),
|
||||
'cb':('keil', 'armcc'),
|
||||
'ua':('keil', 'armcc')}
|
||||
'ua':('gcc', 'gcc')}
|
||||
tgt_name = GetOption('target')
|
||||
if tgt_name:
|
||||
# --target will change the toolchain settings which clang-analyzer is
|
||||
@@ -256,15 +260,30 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||
|
||||
return objs
|
||||
|
||||
def PrepareModuleBuilding(env, root_directory):
|
||||
def PrepareModuleBuilding(env, root_directory, bsp_directory):
|
||||
import rtconfig
|
||||
|
||||
global BuildOptions
|
||||
global Env
|
||||
global Rtt_Root
|
||||
|
||||
# patch for win32 spawn
|
||||
if env['PLATFORM'] == 'win32':
|
||||
win32_spawn = Win32Spawn()
|
||||
win32_spawn.env = env
|
||||
env['SPAWN'] = win32_spawn.spawn
|
||||
|
||||
Env = env
|
||||
Rtt_Root = root_directory
|
||||
|
||||
# parse bsp rtconfig.h to get used component
|
||||
PreProcessor = SCons.cpp.PreProcessor()
|
||||
f = file(bsp_directory + '/rtconfig.h', 'r')
|
||||
contents = f.read()
|
||||
f.close()
|
||||
PreProcessor.process_contents(contents)
|
||||
BuildOptions = PreProcessor.cpp_namespace
|
||||
|
||||
# add build/clean library option for library checking
|
||||
AddOption('--buildlib',
|
||||
dest='buildlib',
|
||||
@@ -324,6 +343,24 @@ def MergeGroup(src_group, group):
|
||||
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
||||
else:
|
||||
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
||||
|
||||
# for local CCFLAGS/CPPPATH/CPPDEFINES
|
||||
if group.has_key('LOCAL_CCFLAGS'):
|
||||
if src_group.has_key('LOCAL_CCFLAGS'):
|
||||
src_group['LOCAL_CCFLAGS'] = src_group['LOCAL_CCFLAGS'] + group['LOCAL_CCFLAGS']
|
||||
else:
|
||||
src_group['LOCAL_CCFLAGS'] = group['LOCAL_CCFLAGS']
|
||||
if group.has_key('LOCAL_CPPPATH'):
|
||||
if src_group.has_key('LOCAL_CPPPATH'):
|
||||
src_group['LOCAL_CPPPATH'] = src_group['LOCAL_CPPPATH'] + group['LOCAL_CPPPATH']
|
||||
else:
|
||||
src_group['LOCAL_CPPPATH'] = group['LOCAL_CPPPATH']
|
||||
if group.has_key('LOCAL_CPPDEFINES'):
|
||||
if src_group.has_key('LOCAL_CPPDEFINES'):
|
||||
src_group['LOCAL_CPPDEFINES'] = src_group['LOCAL_CPPDEFINES'] + group['LOCAL_CPPDEFINES']
|
||||
else:
|
||||
src_group['LOCAL_CPPDEFINES'] = group['LOCAL_CPPDEFINES']
|
||||
|
||||
if group.has_key('LINKFLAGS'):
|
||||
if src_group.has_key('LINKFLAGS'):
|
||||
src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
|
||||
@@ -362,13 +399,13 @@ def DefineGroup(name, src, depend, **parameters):
|
||||
group['src'] = src
|
||||
|
||||
if group.has_key('CCFLAGS'):
|
||||
Env.Append(CCFLAGS = group['CCFLAGS'])
|
||||
Env.AppendUnique(CCFLAGS = group['CCFLAGS'])
|
||||
if group.has_key('CPPPATH'):
|
||||
Env.Append(CPPPATH = group['CPPPATH'])
|
||||
Env.AppendUnique(CPPPATH = group['CPPPATH'])
|
||||
if group.has_key('CPPDEFINES'):
|
||||
Env.Append(CPPDEFINES = group['CPPDEFINES'])
|
||||
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
||||
if group.has_key('LINKFLAGS'):
|
||||
Env.Append(LINKFLAGS = group['LINKFLAGS'])
|
||||
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
||||
|
||||
# check whether to clean up library
|
||||
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
||||
@@ -385,13 +422,15 @@ def DefineGroup(name, src, depend, **parameters):
|
||||
else : group['LIBPATH'] = [GetCurrentDir()]
|
||||
|
||||
if group.has_key('LIBS'):
|
||||
Env.Append(LIBS = group['LIBS'])
|
||||
Env.AppendUnique(LIBS = group['LIBS'])
|
||||
if group.has_key('LIBPATH'):
|
||||
Env.Append(LIBPATH = group['LIBPATH'])
|
||||
Env.AppendUnique(LIBPATH = group['LIBPATH'])
|
||||
|
||||
# check whether to build group library
|
||||
if group.has_key('LIBRARY'):
|
||||
objs = Env.Library(name, group['src'])
|
||||
else:
|
||||
# only add source
|
||||
objs = group['src']
|
||||
|
||||
# merge group
|
||||
@@ -447,15 +486,46 @@ def BuildLibInstallAction(target, source, env):
|
||||
break
|
||||
|
||||
def DoBuilding(target, objects):
|
||||
|
||||
# merge all objects into one list
|
||||
def one_list(l):
|
||||
lst = []
|
||||
for item in l:
|
||||
if type(item) == type([]):
|
||||
lst += one_list(item)
|
||||
else:
|
||||
lst.append(item)
|
||||
return lst
|
||||
|
||||
# handle local group
|
||||
def local_group(group, objects):
|
||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
|
||||
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
|
||||
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
|
||||
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
|
||||
|
||||
for source in group['src']:
|
||||
objects.append(Env.Object(source, CCFLAGS = CCFLAGS,
|
||||
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES))
|
||||
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
objects = one_list(objects)
|
||||
|
||||
program = None
|
||||
# check whether special buildlib option
|
||||
lib_name = GetOption('buildlib')
|
||||
if lib_name:
|
||||
objects = [] # remove all of objects
|
||||
# build library with special component
|
||||
for Group in Projects:
|
||||
if Group['name'] == lib_name:
|
||||
lib_name = GroupLibName(Group['name'], Env)
|
||||
objects = Env.Object(Group['src'])
|
||||
if not local_group(Group, objects):
|
||||
objects = Env.Object(Group['src'])
|
||||
|
||||
program = Env.Library(lib_name, objects)
|
||||
|
||||
# add library copy action
|
||||
@@ -463,6 +533,18 @@ def DoBuilding(target, objects):
|
||||
|
||||
break
|
||||
else:
|
||||
# remove source files with local flags setting
|
||||
for group in Projects:
|
||||
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
|
||||
for source in group['src']:
|
||||
for obj in objects:
|
||||
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
|
||||
objects.remove(obj)
|
||||
|
||||
# re-add the source files to the objects
|
||||
for group in Projects:
|
||||
local_group(group, objects)
|
||||
|
||||
program = Env.Program(target, objects)
|
||||
|
||||
EndBuilding(target, program)
|
||||
@@ -491,7 +573,6 @@ def EndBuilding(target, program = None):
|
||||
else:
|
||||
print 'No template project file found.'
|
||||
|
||||
|
||||
if GetOption('target') == 'mdk4':
|
||||
from keil import MDK4Project
|
||||
MDK4Project('project.uvproj', Projects)
|
||||
@@ -586,6 +667,11 @@ def GlobSubDir(sub_dir, ext_name):
|
||||
dst.append(os.path.relpath(item, sub_dir))
|
||||
return dst
|
||||
|
||||
def PackageSConscript(package):
|
||||
from package import BuildPackage
|
||||
|
||||
return BuildPackage(package)
|
||||
|
||||
def file_path_exist(path, *args):
|
||||
return os.path.exists(os.path.join(path, *args))
|
||||
|
||||
|
||||
@@ -66,9 +66,21 @@ def MDK4AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
|
||||
file = SubElement(files, 'File')
|
||||
file_name = SubElement(file, 'FileName')
|
||||
name = os.path.basename(path)
|
||||
if ProjectFiles.count(name):
|
||||
|
||||
if name.find('.cpp') != -1:
|
||||
obj_name = name.replace('.cpp', '.o')
|
||||
elif name.find('.c') != -1:
|
||||
obj_name = name.replace('.c', '.o')
|
||||
elif name.find('.s') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
elif name.find('.S') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
else:
|
||||
obj_name = name
|
||||
|
||||
if ProjectFiles.count(obj_name):
|
||||
name = basename + '_' + name
|
||||
ProjectFiles.append(name)
|
||||
ProjectFiles.append(obj_name)
|
||||
file_name.text = name.decode(fs_encoding)
|
||||
file_type = SubElement(file, 'FileType')
|
||||
file_type.text = '%d' % _get_filetype(name)
|
||||
@@ -98,9 +110,19 @@ def MDK4AddGroup(ProjectFiles, parent, name, files, project_path):
|
||||
file = SubElement(files, 'File')
|
||||
file_name = SubElement(file, 'FileName')
|
||||
name = os.path.basename(path)
|
||||
if ProjectFiles.count(name):
|
||||
|
||||
if name.find('.cpp') != -1:
|
||||
obj_name = name.replace('.cpp', '.o')
|
||||
elif name.find('.c') != -1:
|
||||
obj_name = name.replace('.c', '.o')
|
||||
elif name.find('.s') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
elif name.find('.S') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
|
||||
if ProjectFiles.count(obj_name):
|
||||
name = basename + '_' + name
|
||||
ProjectFiles.append(name)
|
||||
ProjectFiles.append(obj_name)
|
||||
file_name.text = name.decode(fs_encoding)
|
||||
file_type = SubElement(file, 'FileType')
|
||||
file_type.text = '%d' % _get_filetype(name)
|
||||
@@ -201,9 +223,19 @@ def MDK5AddGroupForFN(ProjectFiles, parent, name, filename, project_path):
|
||||
file = SubElement(files, 'File')
|
||||
file_name = SubElement(file, 'FileName')
|
||||
name = os.path.basename(path)
|
||||
if ProjectFiles.count(name):
|
||||
|
||||
if name.find('.cpp') != -1:
|
||||
obj_name = name.replace('.cpp', '.o')
|
||||
elif name.find('.c') != -1:
|
||||
obj_name = name.replace('.c', '.o')
|
||||
elif name.find('.s') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
elif name.find('.S') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
|
||||
if ProjectFiles.count(obj_name):
|
||||
name = basename + '_' + name
|
||||
ProjectFiles.append(name)
|
||||
ProjectFiles.append(obj_name)
|
||||
file_name.text = name.decode(fs_encoding)
|
||||
file_type = SubElement(file, 'FileType')
|
||||
file_type.text = '%d' % _get_filetype(name)
|
||||
@@ -233,9 +265,21 @@ def MDK5AddGroup(ProjectFiles, parent, name, files, project_path):
|
||||
file = SubElement(files, 'File')
|
||||
file_name = SubElement(file, 'FileName')
|
||||
name = os.path.basename(path)
|
||||
if ProjectFiles.count(name):
|
||||
|
||||
if name.find('.cpp') != -1:
|
||||
obj_name = name.replace('.cpp', '.o')
|
||||
elif name.find('.c') != -1:
|
||||
obj_name = name.replace('.c', '.o')
|
||||
elif name.find('.s') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
elif name.find('.S') != -1:
|
||||
obj_name = name.replace('.s', '.o')
|
||||
else:
|
||||
obj_name = name
|
||||
|
||||
if ProjectFiles.count(obj_name):
|
||||
name = basename + '_' + name
|
||||
ProjectFiles.append(name)
|
||||
ProjectFiles.append(obj_name)
|
||||
file_name.text = name.decode(fs_encoding)
|
||||
file_type = SubElement(file, 'FileType')
|
||||
file_type.text = '%d' % _get_filetype(name)
|
||||
@@ -266,6 +310,7 @@ def MDK5Project(target, script):
|
||||
groups = tree.find('Targets/Target/Groups')
|
||||
if groups is None:
|
||||
groups = SubElement(tree.find('Targets/Target'), 'Groups')
|
||||
groups.clear() # clean old groups
|
||||
for group in script:
|
||||
group_xml = MDK4AddGroup(ProjectFiles, groups, group['name'], group['src'], project_path)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ SConscript_com = '''# RT-Thread building script for component
|
||||
from building import *
|
||||
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
src = Glob('*.c') + Glob('*.cpp')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
group = DefineGroup('COMPONENT_NAME', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Reference in New Issue
Block a user