From 305082fc45e12a9167f7691aa23ec8d739470815 Mon Sep 17 00:00:00 2001 From: chinky Date: Wed, 15 Aug 2018 11:09:33 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 8215a8352305704afaf54b389343e9f41365b40e Merge: fe7734162 18510fa80 Author: Bernard Xiong Date: Wed Aug 15 08:47:26 2018 +0800 Merge pull request #1715 from heyuanjie87/syscall Syscall commit 18510fa80fef9751228935ef31e0b9fab9e3cdcc Author: heyuanjie87 Date: Tue Aug 14 09:33:22 2018 +0800 Update select.c commit c90b449dac29e3e5a46a20988b043d283d3405d6 Author: heyuanjie87 Date: Mon Aug 13 22:42:09 2018 +0800 Update select.c commit fe773416217b04d5873b9b6f4857b54e80b3d5e9 Merge: b571cd889 495927696 Author: Bernard Xiong Date: Mon Aug 13 19:02:34 2018 +0800 Merge pull request #1717 from geniusgogo/fix_iar_project fixed IAR project add LIBS commit 495927696e759c7ec531bee6d8f33d6f5dfea27b Author: xieyangrun Date: Mon Aug 13 16:54:02 2018 +0800 fixed IAR project add LIBS commit b571cd8899ff37341f184dbded101d6ef434d8c1 Merge: 68edd04cb 250de62d5 Author: ZYH Date: Sun Aug 12 20:56:30 2018 +0800 Merge pull request #1714 from xeonxu/fix_pwm [STM32 BSP]Fix PWM channel calculate argorithm. commit d948dba42a7b2a219508ac28cf78e6e44f835dcf Author: heyuanjie87 Date: Sun Aug 12 20:41:56 2018 +0800 update select.c commit fd209cb880f6d2d39b6265c09727182b55446bdf Author: heyuanjie Date: Sun Aug 12 20:26:16 2018 +0800 [lwp]添加select系统调用 commit 250de62d5c5ababe7c3ae2a752b0f53734fab0ad Author: Noe Xu Date: Sun Aug 12 19:54:19 2018 +0800 [STM32 BSP]Fix PWM channel calculate argorithm. Change-Id: Ie65437365784033dcee8d8e9f21dfc5727ba9d3c --- bsp/stm32f4xx-HAL/drivers/drv_pwm.c | 11 ++++--- components/dfs/src/select.c | 23 +++++++++++++-- components/lwp/lwp_syscall.c | 6 +++- tools/iar.py | 45 +++++++++++++++++------------ 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/bsp/stm32f4xx-HAL/drivers/drv_pwm.c b/bsp/stm32f4xx-HAL/drivers/drv_pwm.c index c5be0e126..f046090c9 100644 --- a/bsp/stm32f4xx-HAL/drivers/drv_pwm.c +++ b/bsp/stm32f4xx-HAL/drivers/drv_pwm.c @@ -38,18 +38,21 @@ static struct rt_pwm_ops drv_ops = static rt_err_t drv_pwm_enable(TIM_HandleTypeDef * htim, struct rt_pwm_configuration *configuration, rt_bool_t enable) { - rt_uint32_t channel = 0x04 * configuration->channel; + rt_uint32_t channel = 0x04 * (configuration->channel - 1); if(!enable) { HAL_TIM_PWM_Stop(htim, channel); } - HAL_TIM_PWM_Start(htim, channel); + else + { + HAL_TIM_PWM_Start(htim, channel); + } return RT_EOK; } static rt_err_t drv_pwm_get(TIM_HandleTypeDef * htim, struct rt_pwm_configuration *configuration) { - rt_uint32_t channel = 0x04 * configuration->channel; + rt_uint32_t channel = 0x04 * (configuration->channel - 1); rt_uint32_t tim_clock; #if (RT_HSE_HCLK > 100000000UL)//100M if(htim->Instance == TIM1 && htim->Instance == TIM8) @@ -81,7 +84,7 @@ static rt_err_t drv_pwm_set(TIM_HandleTypeDef * htim, struct rt_pwm_configuratio { rt_uint32_t period, pulse; rt_uint32_t tim_clock, psc; - rt_uint32_t channel = 0x04 * configuration->channel; + rt_uint32_t channel = 0x04 * (configuration->channel - 1); #if (RT_HSE_HCLK > 100000000UL)//100M if(htim->Instance == TIM1 && htim->Instance == TIM8) { diff --git a/components/dfs/src/select.c b/components/dfs/src/select.c index c72776399..cbbd15955 100644 --- a/components/dfs/src/select.c +++ b/components/dfs/src/select.c @@ -28,6 +28,23 @@ #include #include +static void fdszero(fd_set *set, int nfds) +{ + fd_mask *m; + int n; + + /* + The 'sizeof(fd_set)' of the system space may differ from user space, + so the actual size of the 'fd_set' is determined here with the parameter 'nfds' + */ + m = (fd_mask*)set; + for (n = 0; n < nfds; n += (sizeof(fd_mask) * 8)) + { + rt_memset(m, 0, sizeof(fd_mask)); + m ++; + } +} + int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout) { int fd; @@ -113,17 +130,17 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc /* Now set up the return values */ if (readfds) { - memset(readfds, 0, sizeof(fd_set)); + fdszero(readfds, nfds); } if (writefds) { - memset(writefds, 0, sizeof(fd_set)); + fdszero(writefds, nfds); } if (exceptfds) { - memset(exceptfds, 0, sizeof(fd_set)); + fdszero(exceptfds, nfds); } /* Convert the poll descriptor list back into selects 3 bitsets */ diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index 1b5aa411a..0150e50b6 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -27,6 +27,8 @@ #include #include +#include + #if (defined(RT_USING_SAL) && defined(SAL_USING_POSIX)) #include @@ -235,7 +237,7 @@ const static void* func_table[] = (void *)sys_gettimeofday, // 0x0b (void *)sys_settimeofday, // 0x0c - + (void *)sys_malloc, // 0x0d (void *)sys_free, // 0x0e (void *)sys_realloc, //0x0f @@ -256,6 +258,8 @@ const static void* func_table[] = SYSCALL_NET(send), // 0x1d SYSCALL_NET(sendto), // 0x1e SYSCALL_NET(socket), // 0x1f + + select, // 0x20 }; const void *lwp_get_sys_api(rt_uint32_t number) diff --git a/tools/iar.py b/tools/iar.py index 1ada15717..c77467a51 100644 --- a/tools/iar.py +++ b/tools/iar.py @@ -49,31 +49,31 @@ def IARAddGroup(parent, name, files, project_path): group = SubElement(parent, 'group') group_name = SubElement(group, 'name') group_name.text = name - + for f in files: fn = f.rfile() name = fn.name path = os.path.dirname(fn.abspath) - basename = os.path.basename(path) path = _make_path_relative(project_path, path) path = os.path.join(path, name) - + file = SubElement(group, 'file') file_name = SubElement(file, 'name') + if os.path.isabs(path): file_name.text = path.decode(fs_encoding) else: file_name.text = ('$PROJ_DIR$\\' + path).decode(fs_encoding) def IARWorkspace(target): - # make an workspace + # make an workspace workspace = target.replace('.ewp', '.eww') out = file(workspace, 'wb') xml = iar_workspace % target out.write(xml) out.close() - + def IARProject(target, script): project_path = os.path.dirname(os.path.abspath(target)) @@ -87,7 +87,19 @@ def IARProject(target, script): LINKFLAGS = '' CCFLAGS = '' Libs = [] - + lib_prefix = ['lib', ''] + lib_suffix = ['.a', '.o', ''] + + def searchLib(group): + for path_item in group['LIBPATH']: + for prefix_item in lib_prefix: + for suffix_item in lib_suffix: + lib_full_path = os.path.join(path_item, prefix_item + item + suffix_item) + if os.path.isfile(lib_full_path): + return lib_full_path + else: + return '' + # add group for group in script: IARAddGroup(root, group['name'], group['src'], project_path) @@ -95,29 +107,26 @@ def IARProject(target, script): # get each include path if group.has_key('CPPPATH') and group['CPPPATH']: CPPPATH += group['CPPPATH'] - + # get each group's definitions if group.has_key('CPPDEFINES') and group['CPPDEFINES']: CPPDEFINES += group['CPPDEFINES'] - + # get each group's link flags if group.has_key('LINKFLAGS') and group['LINKFLAGS']: LINKFLAGS += group['LINKFLAGS'] - + if group.has_key('LIBS') and group['LIBS']: for item in group['LIBS']: - lib_path = '' - - for path_item in group['LIBPATH']: - full_path = os.path.join(path_item, item + '.a') - if os.path.isfile(full_path): # has this library - lib_path = full_path - + lib_path = searchLib(group) if lib_path != '': lib_path = _make_path_relative(project_path, lib_path) Libs += [lib_path] + # print('found lib isfile: ' + lib_path) + else: + print('not found LIB: ' + item) - # make relative path + # make relative path paths = set() for path in CPPPATH: inc = _make_path_relative(project_path, os.path.normpath(path)) @@ -156,7 +165,7 @@ def IARProject(target, script): out.close() IARWorkspace(target) - + def IARVersion(): import subprocess import re